Unsolved QImage scaledtoHeight does not work for QImage::Format_Grayscale16
-
Hi,
I wanted to scale the input image of format QImage::Format_Grayscale16. But the output image post transformation is garbage. Could anyone please provide a way to scale my images with the help of an inbuilt function?
Thanks
Sachin -
Hi,
I can provide more information if I am not clear with the problem?
The scaletoheight() uses transformation of images for scaling which I do not have any idea of implementation. I cannot convert the format to a format where the scaling is possible either. Or is there a way?
Thanks
Sachin -
@SachinBhat Please show your code where you scale the image...
-
Hi,
@jsulm Thank you for your reply.Below is the code snippet:
QImage img("file_location"); #if IMG_DEBUG writer1.write(img); #endif if (img.format() >= QImage::Format_RGBX64) { int width = DIV_ROUND(m_ptnWidth * PTN_IMG_HEIGHT, m_ptnHeight); delete m_ptnImageCache[cacheIndex].img; m_ptnImageCache[cacheIndex].img = new QImage(width, PTN_IMG_HEIGHT, QImage::Format_Grayscale16); } if(img.isNull()) return NULL; int scaleHeight = DIV_ROUND(PTN_IMG_HEIGHT * img.height(),m_ptnHeight); scaledImage = img.scaledToHeight(scaleHeight);
I get improper output.
Left is the input, right is the output imageI get proper outputs for other formats
Thanks
Sachin[Edit: Added code tags ~kshegunov]
-
It's possible this is a bug, seems that the pixel data alignment is broken for some reason. Could you prepare a very simple self-contained project (along with the test image) and upload it somewhere? Please strip the irrelevant code if you decide to do so (like the
m_ptnImageCache
).