这个命令行: QImage::QImage (uchar * data,int width,int height,int bytesPerLine,Format format)会使用这样的格式吗?QImage图片=新的QImage ( bytesPerLine,600,400,jpg)图片不是他们的本意,照片会占用kb吗?谢谢
发布于 2011-09-26 18:47:04
如果不想使用bytesPerLine参数,有一个
QImage::QImage ( uchar * data, int width, int height, Format format )构造函数。
然而,格式并不是您所想的那样。format参数指定一个枚举值,该枚举值决定位深度等。例如,在此处输入jpg或"jpg"将不起作用。有关可能值的列表,请查看Format-enum。
发布于 2011-09-26 17:57:22
考虑到你的问题对我来说很不清楚,我会尽量回答得最好。
从Qt documentation
bytesPerLine指定每行的字节数(步长)
还要考虑到,您指定为jpg的格式参数必须作为in here指定的枚举值之一给出。
诚挚的问候
发布于 2011-09-26 18:52:58
这就是如何使用此构造函数:
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);您无需指定图像格式(png、jpeg等)。而是像素格式(RGB、RGBA等)
https://stackoverflow.com/questions/7552911
复制相似问题