Results 1 to 4 of 4

Thread: Problem when saving bmp files

  1. #1
    Join Date
    Mar 2011
    Posts
    3
    Qt products
    Qt4

    Default Problem when saving bmp files

    Hi,

    I have a QImage generated from a char* data array. When trying to save it to the bmp the file is correctly created but is not readeable by the window wiewer (paint open it but the data is crappy).

    I guess that my QImage is not correctly initialised, but I don't find Where

    Here is a part of my code:
    Qt Code:
    1. // allocate the memory for the input picture
    2. unsigned char* Orig_Image = NULL;
    3. QImage Image;
    4. Orig_Image = new unsigned char[Nb_Lines * Nb_Pixels];
    5. memset(Orig_Image, 0, Nb_Lines * Nb_Pixels);
    6.  
    7. // create a B/W color table for the image
    8. QVector<QRgb> colorTable;
    9. for (int i = 0; i < 256; i++)
    10. colorTable.push_back(QColor(i, i, i).rgb());
    11.  
    12.  
    13. .... edit the data array here
    14.  
    15. Image = QImage(Orig_Image,Nb_Pixels,Nb_Lines,Nb_Pixels,QImage::Format_Indexed8);
    16. Image.setColorTable(colorTable);
    17.  
    18. if(!Image.isNull()) Image.save(QFileDialog::getSaveFileName(this, "Load a picture or file", QString(), "BMP"));
    19.  
    20. delete(Orig_Image);
    To copy to clipboard, switch view to plain text mode 



    Any clues are appreciated!

  2. #2
    Join Date
    Aug 2009
    Location
    Greece
    Posts
    69
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem when saving bmp files

    from the qt docs http://doc.qt.nokia.com/4.7-snapshot/qimage.html
    "Warning: Painting on a QImage with the format QImage::Format_Indexed8 is not supported."

  3. #3
    Join Date
    Mar 2011
    Posts
    3
    Qt products
    Qt4

    Default Re: Problem when saving bmp files

    hum ok... so there is no possibilities to save a 8bits bmp picture with Qt?

  4. #4
    Join Date
    Mar 2011
    Posts
    3
    Qt products
    Qt4

    Default Re: Problem when saving bmp files

    It is strange because on the doc it is also written:
    BMP Windows Bitmap Read/write

    if there is no solution on Qt is it possible whit another library?

Similar Threads

  1. qImage saving to jpg problem
    By sqarpi in forum Qt Programming
    Replies: 9
    Last Post: 1st September 2010, 15:43
  2. Problem saving JPG image
    By avis_phoenix in forum Newbie
    Replies: 1
    Last Post: 31st July 2009, 15:38
  3. Problem saving a plot
    By kalos80 in forum Qwt
    Replies: 2
    Last Post: 10th July 2008, 08:31
  4. Saving a QPixmap Object problem
    By StrikerX in forum General Programming
    Replies: 4
    Last Post: 15th November 2007, 02:19
  5. problem with saving QCstrings
    By nass in forum Qt Programming
    Replies: 3
    Last Post: 5th October 2006, 15:12

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.