PDA

View Full Version : how to save pixmap as GIF



timmu
8th December 2009, 16:55
I know how to save a QPixmap (map) as a bitmap:



map.save("image.bmp", 0, -1);


The above won't work for the *.gif image format because I need plugins for the image formats other than bitmap. I got this to work when I was linking statically with another program but now I'm linking dynamically. I think I need to modify my *.pro file and main.cpp somehow. I'm not sure how to do that. This is what I have so far:

My *.pro file:


TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += plugin
QTPLUGIN += qjpeg \
qgif \
qtiff
# Input
HEADERS += binary.h

SOURCES += functions.cpp \
main.cpp


I wonder if I need these at the beginning of my main.cpp or is this something you only use for static linking?:


Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qtiff)


Thanks so much!

spirit
8th December 2009, 19:00
you can load gifs using QMovie, but I don't see any method which allows to save into gif-format file.

timmu
9th December 2009, 10:07
I'm a little bit confused. I'm pretty sure I've seen people turn pixmaps into gif files with Qt but I just cannot figure out how or find the instructions.

spirit
9th December 2009, 10:15
as Qt Assistant says, Qt can only read gifs


Format Description Qt's support
GIF Graphic Interchange Format (optional) Read

take a look docs about QPixmap.

timmu
9th December 2009, 19:21
Thanks, but what about writing JPEGs. I need to write very large image files and the reason BMP won't work is because the file size is huge. I could also use JPEG. Do you know if writing JPEG is possible and what plugins are needed?

spirit
9th December 2009, 19:24
BMP Windows Bitmap Read/write
GIF Graphic Interchange Format (optional) Read
JPG Joint Photographic Experts Group Read/write
JPEG Joint Photographic Experts Group Read/write
PNG Portable Network Graphics Read/write
PBM Portable Bitmap Read
PGM Portable Graymap Read
PPM Portable Pixmap Read/write
XBM X11 Bitmap Read/write
XPM X11 Pixmap Read/write

this means that you can write JPG.