Load images

In order to create an image object and according to the function’s arguments:

cl_mem clCreateImage ( cl_context context,
cl_mem_flags flags,
const cl_image_format *image_format,
const cl_image_desc *image_desc,
void *host_ptr,
cl_int *errcode_ret)

Which is the best way to build the host_ptr pointer? I mean, load an image file from disc.

I’m using libpng but only with RGBA channel-order (32-bit depth). It doesn’t work when I try to load a RGB image. Also, I need to work with another image formats (bmp, jpg, gif).

Thanks in advance for the help.

OpenCL doesn’t provide any built-in functionality for loading image data from disk.

However, you could use libraries like Qt or OpenCV to load the files from disk and then use the interop code in Boost.Compute to create OpenCL image objects. For example, see the qimage_blur demo program which loads a file with Qt, applies a gaussian blur kernel, and displays it (doing the same thing with OpenCV is also very simple).

Thanks for the information Kyle. I have read something about OpenCV for loading images, but not with Qt. I’ll try it.

What about FreeImage and ImageMagick (MagickWand) libraries? Has someone used them?