PDA

View Full Version : Qt + ImageMagick



bpetty
13th April 2007, 20:49
EDIT:

I read a bunch of other peoples posts about the lack of Tiff support in Qt. Has anyone integrated ImageMagick with Qt to display images in a cross platform manner? I am wanting to diplay TIFFs with a QT MDI.

I am using Qt 4.2

spud
13th April 2007, 22:15
If tiff support is all you need, try TiffIO (http://artis.imag.fr/Software/TiffIO/)

wysota
13th April 2007, 22:48
Afaik recent versions of Qt4 have native support for TIFF. At least it seems so, looking at configure -help.

marcel
14th April 2007, 09:14
If all you want is tiff support, why not just take tiff support from ImageMagick or tifflibrary(better), or even Java Advanced Imaging (excellent support for less common tiff compression schemes ) and integrate it in your app?

I, for one, don't see the point in integrating complex libs with your app for just one small feature.


Regards

guilugi
16th April 2007, 09:15
Yes, I use ImageMagick in my main application now, it works pretty fine, and
it's not really that to use.

If you want more details about it, I can send you a little sample showing how to load / convert / scale an image with Magick API.

Guilugi.

PS : but as wysota and marcel said, you don't need to use Magick if you need only TIFF support :)

bpetty
18th April 2007, 20:23
I would like to use ImageMagick for TIFFs because I believe it supports more TIFF formats than what I can get out of QT. I also gain support for many other file formats that Qt does not support like PDF - cross platform.

Guilugi,
I would love to see an example of how you are using ImageMagick to display TIFFs.

guilugi
19th April 2007, 10:29
Okay,

Here is a loader / viewer, I made it really simple.

It uses Magick++ to load images.
It's been a while since I used this Magick ++API, I prefer MagickWand (C library), I found it more efficient.

So if you're not satisfied, I can always bring to you the C version :)

Basically the steps :

1 - Loading the image with a Magick object
2 - Setting it to XPM format (not the best, ARGB might be better)
3 - Displaying it with a QPixmap -> QLabel.

This code works fine on Linux, I didn't check on Windows though, you'll probably need to link statically the Magick++ lib.

Hope this helps,
Guilugi.

bpetty
23rd April 2007, 18:31
Thanks a lot for that snippet!

I was really interested in what you were using to view the image. I knew about the qlabel but it always seemed a little odd to me. So I am pretty much just converting a TIF into another format, in memory, that the QLabel can display?

I might see what it would be like to implement this using the QGraphicsView stuff in 4.2.

I am also curious about MagickWand. Why do you like it better than Magick++?

guilugi
23rd April 2007, 22:08
Yup that's it : I convert the image in PNG, so it can be opened through QPixmaps :)
The conversion is a little time consuming in high resolutions, but for thumbnails it works really really good :)

I'm currently using it through QGraphicsView to make a simple image editor (with basic layers), and so far it looks fine.

For MagickWand :
I had some problems at the beginning of my development (2 years 1/2 ago from now) with Magick++, mainly compilation and dynamic linking with MinGW...
I couldn't use static linking in those days, couldn't use Visual Studio too (don't like it :p), and dynamic linking was strictly forbidden with MinGW.

So I switched on MagickWand : really simple to use too, maybe too simple, but it seemed loadings were faster with MagickWand...I can't tell anymore, it's pretty similar.

If you can (want) to link statically to Magick++, you can use it, since it's object code, well fitted in Qt :)

Hope this helps !

Cheers,
Guilugi.