QPixmap with .svg "couldn't create image from"? - qt

i try to get an .svg to an QPixmap and i get the Error "couldn't create Image from".
Code:
QString test = "/home/ftp/DM262-WIF-269-0.svg";
QPixmap design(test);
ui->scan_bild->setPixmap(design);
ui->scan_bild->setScaledContents(true);
is there a Resolution for my Problem?
Thx
Felix

The SVG loader of Qt supports only a subset of SVG. It seems that embedding of raster graphics images in SVGs is not supported. (If I remember right embedding of SVGs in other SVGs doesn't work as well. – Too sad.)
To prove that I don't tell something wrong, I tested an icon of our software.
The following image shows how the Explorer Preview plug-in (based on Qt) shows the image:
The same image loaded into Firefox:
When I import this image in GIMP, the embedded image is considered as well.
So, if you don't want to re-design your SVG icon I see only one solution: render the SVGs into raster graphics images (e.g. PNG or JPEG) which are better supported in Qt – may be, with multi-resolution icons (QIcon – High DPI icons) for a better result.

Related

Can't seem to disable anti-aliasing in Android

I'm new to Android, and I've finished a game which was meant to feature pixel art. I was going to scale up my images (imageviews and bitmaps drawn to canvas) from small pixelated png files. The thing is, I could not seem to disable anti-aliasing whatever method I tried. The image was always blurred.
All my images are in one 'drawable' folder.
I tried android:antialias="false" within the ImageView in the xml.
Tried the method described here: http://www.41post.com/4241/programming/android-disabling-anti-aliasing-for-pixel-art
\
Tried changing the paint (paint.setAntiAlias(false)) when drawing the bitmap onto a canvas.
And even tried linking the ImageView to a xml bitmap drawable with antialias="false"
Am I missing something? In the end I had to just settle with leaving some images blurry and having the big images as big images and not resizing in the xml file.
From the Hardware Acceleration Guide, it looks like Paint#setFilterBitmap() is always enabled and cannot be disabled when hardware acceleration is enabled. Try checking to see if your app is using hardware acceleration.
I've seen similar behavior in the emulator when enabling the "Use host GPU" option, and found that a device that didn't have the anti-aliasing behavior could be forced to have that behavior by using Paint#setFilterBitmap(true). I was not able to disable the behavior in the emulator though without disabling the host GPU option.

Images in svg file doesn't show up in Qt

I'm trying to display a svg image with Qt and it works well except that any image (.gif, .bmp, ...) in the svg image doesn't show up (lines, circles, texts works OK).
If I open the svg in firefox the image displays correctly.
I have put qgif4.dll in a folder imageformats and QtSvg4.dll besides the executable but to no avail.
I'm displaying the svg with the help of svgview.h/.cpp and I'm running on a WinXP machine (Qt version 4.7.2).
Any help greatly appreciated!
If you are loading it via a QIcon, it should work without assistance.
If you are trying to load it using a QPixmap or QImage - you can't. You have to use QSvgRenderer (or the related classes) in the svg module to rasterise the data.

what specification for jsTree node icons?

I want to create my own node icons for jsTree application. A jsTree sample could be found here
I want to know what specification the new icon has to have
size
transparent?
could you recommend any program (mac or pc)
anything else I forgot
Bit of a weird question, but anyway:
The icons are individually 16x16.
All the icons are inside one .png using alpha transparency (the background).
The CSS Sprites technique is being utilized:
http://static.jstree.com/v.1.0pre/themes/default/d.png
Which image editor to use?
I'd use Photoshop, but any image editor that can handle .png's alpha transparency will work.
Try: https://superuser.com/questions/25451/looking-for-a-good-free-image-editor

How can I shrink an image in HTML whilst maintaining its sharpness?

I have an image that I use many times. In several cases I want to shrink its size, but obviously it loses sharpness when I do this in HTML.
Is there a way to fix this? The image is located elsewhere and I can’t save it locally.
Thanks
As dheerosaur states, SVG graphics can be used when you need to have the same image in multiple sizes but don't want to compromise quality.
Another thing to do is use an online service, such as Resize.co. You pass them the URL for your image file, the attributes and they take care of everything else.
You cannot control the way the browser renders images when they are resized. Images will look better when being passed through Photoshop's filters (or those in another tool) upon resize.
There is three way that I know to reduce an image file size in bytes :
Convert the file into a format using lossy compression algorithm such as JPG. Obviously the image will lose sharpness
Convert the file into a format using lossless compression algorithm, like PNG. Only works if the image contains lots of region with flat colors
Resize/resample the image using Photoshop or GIMP. If the new image dimension (width x height) is exactly the same as the displayed image's dimension in HTML, then web users will still see a sharp image
Firefox and Internet Explorer actually do have CSS properties that adjust the way images are rendered when resized via HTML attributes or CSS properties:
Firefox: image-rendering
Internet Explorer: -ms-interpolation-mode
These won’t work in other browsers, and may not work great in all (or any) versions of IE and Firefox.
But it might be worth experimenting with them as a fallback in case resizer.co causes any issues.

bitmaps not looking smooth

I am loading raster files (png) in my viewer application. When I view these files in an application such as IrfanView everything looks very smooth. Somehow the antialiasing settings in my viewer application do not work: lines have very jagged edges.
I do set the SmoothingMode = Drawing2D.SmoothingMode.AntiAlias. I've tried different combinations of the various settings but to no avail.
Is GDI+ not capable of this like IrfanView is?
bitmaps aren't antialiased, text and vector images are - perhaps your problem is that the images are being stretched and resized

Resources