Search code examples
c++qtvips

Fast Way to Use VIPS Image as a QImage


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.


Solution

  • 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.