2
翻轉/鏡像QImage的正確方法是什麼?以下代碼段不起作用。如何翻轉QImage
//allocate buffer
BYTE* pRgb32Buffer = new BYTE[width*height* 4];
//create paint device
QImage img = QImage(pRgb32Buffer , width, height, getStride(width, pixelFormat), QImage::Format_RGB32);
//do some drawing on image (works!)
QPainter painter(&img);
painter.drawText(10, 50, QString("some text"));
//mirrore image (doesn't mirror the orignal buffer!!!)
img = img.mirrored(false,true);
//doesn't work either
//QImage mirrored = img.mirrored();
//img = mirrored;
//mirrored.detach();
故意做你'pRgb32Buffer'和'pBuffer':
可選,如果你想(請確保您有imageformats的DLL,或者不會寫),你可以保存文件? – fritzone 2015-02-09 12:03:51
對不起。已更正 – maxw 2015-02-09 12:04:50
您的意思是什麼不起作用? QImage :: mirrored()返回原始圖像的副本。鏡像不會影響pRgb32Buffer中的數據。除此之外,我看不出爲什麼它不起作用。 – 2015-02-09 12:20:41