Results 1 to 6 of 6

Thread: how to save pixmap as GIF

  1. #1
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default how to save pixmap as GIF

    I know how to save a QPixmap (map) as a bitmap:

    Qt Code:
    1. map.save("image.bmp", 0, -1);
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5. CONFIG += plugin
    6. QTPLUGIN += qjpeg \
    7. qgif \
    8. qtiff
    9. # Input
    10. HEADERS += binary.h
    11.  
    12. SOURCES += functions.cpp \
    13. main.cpp
    To copy to clipboard, switch view to plain text mode 

    I wonder if I need these at the beginning of my main.cpp or is this something you only use for static linking?:
    Qt Code:
    1. Q_IMPORT_PLUGIN(qjpeg)
    2. Q_IMPORT_PLUGIN(qgif)
    3. Q_IMPORT_PLUGIN(qtiff)
    To copy to clipboard, switch view to plain text mode 

    Thanks so much!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to save pixmap as GIF

    you can load gifs using QMovie, but I don't see any method which allows to save into gif-format file.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to save pixmap as GIF

    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.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to save pixmap as GIF

    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to save pixmap as GIF

    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?

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to save pixmap as GIF

    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. The following user says thank you to spirit for this useful post:

    timmu (10th December 2009)

Similar Threads

  1. Qt 4.4 - Problem displaying pixmap in release mode
    By spawn9997 in forum Qt Programming
    Replies: 0
    Last Post: 19th August 2009, 19:40
  2. Performance problems with small pixmap
    By RThaden in forum Qt Programming
    Replies: 4
    Last Post: 9th July 2008, 15:14
  3. Save content of widget to pixmap
    By vql in forum Qt Programming
    Replies: 2
    Last Post: 4th April 2008, 22:26
  4. finding maximum scaling of a pixmap
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 31st March 2008, 14:32
  5. What does "Save All" actually save?
    By Mariane in forum Newbie
    Replies: 7
    Last Post: 31st January 2006, 13:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.