0

I need to work with tiled images in Qt. What would would be a fast way of converting between the two Objects, or otherwise using the VIPS Image in QImage methods? One solution would be to save the VIPS image as a TIFF file, or any other image format in Qt, and then load the files as QImages. I would have to do this for 20+ tiles on the fly, so I don't saving the images as files would be a quick enough process.

CrippledTable
  • 784
  • 5
  • 20
  • If the VIPS image provides the raw data and it has any compatible format (concerning `QImage`), you may use the VIPS image raw data in `QImage` directly. Of course, you have to be a bit carefully concerning the life time of the image instances. I recently wrote an answer concerning `QImage` and its data: [SO: Creating ARGB QImage from uint32 or uchar array](https://stackoverflow.com/a/45552097/7478597) which might be helpful. – Scheff's Cat Aug 17 '17 at 14:47
  • Interesting, so I could cast the VIPS image to an int and then potentially use the code in that link to create the QImage? – CrippledTable Aug 17 '17 at 15:17

1 Answers1

1

Here's a tiny (300 line) example program:

https://github.com/jcupitt/vipsdisp-tiny

That displays the result of a libvips pipeline in a window. It uses gtk+ and Cairo, but it should be simple to adapt for QImage.

It's interesting because it's asynchronous. The libvips pipeline will run in a set of background threads, and tiles will be painted as they are computed. It can display huge images and complex computations and the interface will stay responsive.

Here's the same thing, but as a slightly more complete image viewer:

https://github.com/jcupitt/vipsdisp

With zoom and all that. Again, it's using gtk3, but the ideas should move to Qt easily. It needs a bit of work still, I must find some time.

jcupitt
  • 10,213
  • 2
  • 23
  • 39