QImage, which format to use
-
Hello,
I'm trying to create a QImage from a uchar array, and I'm not sure what format to use. I tried using Format_RGB32, but the image wasn't created at all. I then tried Format_RGB16, which created an image, but not at all correct. I know that the data in the array is correct. The code for writing the image is like this:
@
QImage img(world->pixel_data, world->vp.h_res, world->vp.v_res, world->vp.h_res*3, QImage::Format_RGB16);
QString adr = QFileDialog::getSaveFileName(this);
img.save(adr, "PNG");
@Which format is best for rgb-data stored as uchar? I know that this question probably is a bit vague, but I'm not very familiar with this type of thing.
-
Of course they do range in that range, that is a uchar's very definition. uchar arrays are often used as containers to hold arbitrairy binairy data, such as images as you found out. You need to know what is stored in the array to do anything useful with it. I am glad you found out what's in there exactly in your case.