VIPS image skewed in QT
-
I am trying to load an image with lib vips and display this in Qt.
After loading the image and passing it to QImage - the image is skewed.Below you can download a minimal code sample and a test image.
Also two screenshots from using vips or qt internal function to load image.Any hint and help is welcome.
thx in advance Alexander -
I got help from VIPS maintainer. Here is what did the trick ...
/*
* Hint from vips guy for fixinf skewing:
* In your code, you are using QImage(pointer, width, height, format).
* Perhaps this has assumptions about scanline padding?
* I would try the constructor that lets you set bytesperline as well.
* Use VIPS_IMAGE_SIZEOF_LINE(image.get_image()) to get the line size.
*/vipsObject = VImage::new_from_file (imagePath.toStdString().c_str(), VImage::option ()->set ("access", VIPS_ACCESS_SEQUENTIAL)); imageObject = new QImage(); *imageObject = QImage((uchar*)vipsObject.data(), vipsObject.width(), vipsObject.height(), VIPS_IMAGE_SIZEOF_LINE(vipsObject.get_image()), QImage::Format_RGB888); image = QPixmap::fromImage(*imageObject);
-
I am trying to load an image with lib vips and display this in Qt.
After loading the image and passing it to QImage - the image is skewed.Below you can download a minimal code sample and a test image.
Also two screenshots from using vips or qt internal function to load image.Any hint and help is welcome.
thx in advance Alexander -
I got help from VIPS maintainer. Here is what did the trick ...
/*
* Hint from vips guy for fixinf skewing:
* In your code, you are using QImage(pointer, width, height, format).
* Perhaps this has assumptions about scanline padding?
* I would try the constructor that lets you set bytesperline as well.
* Use VIPS_IMAGE_SIZEOF_LINE(image.get_image()) to get the line size.
*/vipsObject = VImage::new_from_file (imagePath.toStdString().c_str(), VImage::option ()->set ("access", VIPS_ACCESS_SEQUENTIAL)); imageObject = new QImage(); *imageObject = QImage((uchar*)vipsObject.data(), vipsObject.width(), vipsObject.height(), VIPS_IMAGE_SIZEOF_LINE(vipsObject.get_image()), QImage::Format_RGB888); image = QPixmap::fromImage(*imageObject);
-
Hi,
One important thing: there's no need for imageObject to be allocated on the heap. You are likely leaking it with the way you use your code.
-
Hi,
One important thing: there's no need for imageObject to be allocated on the heap. You are likely leaking it with the way you use your code.
-