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!