Results 1 to 4 of 4

Thread: can you save 8 bpp grayscale bitmaps?

  1. #1
    Join Date
    Nov 2007
    Posts
    57
    Thanks
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default can you save 8 bpp grayscale bitmaps?

    I know it's possible to save pixmaps like this:

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

    but the resulting file is 24 bpp rgb image.

    Is it also possible to make 8 bpp grayscale images this way?

  2. #2
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: can you save 8 bpp grayscale bitmaps?

    I needed to get a 1 bpp grayscale the other day for OCR purposes, but I never could get Qt to do this

  3. #3
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: can you save 8 bpp grayscale bitmaps?

    You will have to create an image plug-in that lets you do this: http://doc.trolltech.com/qq/qq17-imageio.html

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: can you save 8 bpp grayscale bitmaps?

    I guess you could abuse QIcon to produce a grayscaled image:
    Qt Code:
    1. QIcon icon;
    2. QPixmap pixmap("test.png");
    3. icon.addPixmap(pixmap);
    4. QImage image = icon.pixmap(pixmap.size(), QIcon::Disabled).toImage();
    5. image = image.convertToFormat(QImage::Format_Indexed8);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. What does "Save All" actually save?
    By Mariane in forum Newbie
    Replies: 7
    Last Post: 31st January 2006, 14: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.