0
votes

this command line: QImage:: QImage (uchar * data, int width, int height, int bytesPerLine, Format format) Would use is it so? QImage image = new QImage (buffer, 600, 400, jpg) the bytesPerLine not they mean well, will the photo occupies kb? thanks

3

3 Answers

2
votes

If you do not want to use the bytesPerLine parameter, there is a

QImage::QImage ( uchar * data, int width, int height, Format format )

constructor.

However, Format is not what you might think. Theformatparameter specifies an enum value which decides over the bit depth etc. I.e. enteringjpgor"jpg"there won't work. Check Format-enum for a list of possible values.

0
votes

I will try to answer the best I can considering the fact that your question is very unclear to me.

From the Qt documentation:

bytesPerLine specifies the number of bytes per line (stride)

Also consider that the format argument, which you specified as jpg, must be given as one of the enum values specified in here.

Best regards

0
votes

That's how you would use this constructor:

int imageWidth = 800;
int imageHeight = 600;
int bytesPerPixel = 4; // 4 for RGBA, 3 for RGB
int format = QImage::Format_ARGB32; // this is the pixel format - check Qimage::Format enum type for more options
QImage image(yourData, imageWidth, imageHeight, imageWidth * bytesPerPixel, format);

You don't specify the image format (png, jpeg, etc.) but the pixel format (RGB, RGBA, etc.)