This is what I have so far:

QFile file(fileName);  
file.open(QIODevice::WriteOnly);  
QPixmap pixmap = QPixmap.loadFromData((const uchar *) imageBuffer_pointer, (sizeof(imageRows) * sizeof(imageCols));  
pixmap.save(&file, "JPG");  
pixmap.save(&file, "PNG");  

But it only produces 0 byte image files

有帮助吗?

解决方案

It is much easier to just give the save() function a file name as a first parameter:

QPixmap pixmap = QPixmap.loadFromData((const uchar *) imageBuffer_pointer, 
    (sizeof(imageRows) * sizeof(imageCols));
pixmap.save(fileName, "JPG");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top