| Home | Libraries | People | FAQ | More

## Class image_format

boost::compute::image_format — A OpenCL image format.

## Synopsis

    // In header: <boost/compute/image/image_format.hpp>

    class image_format {
    public:

      enum channel_order { r = CL_R, a = CL_A, intensity = CL_INTENSITY,
                           luminance = CL_LUMINANCE, rg = CL_RG, ra = CL_RA,
                           rgb = CL_RGB, rgba = CL_RGBA, argb = CL_ARGB,
                           bgra = CL_BGRA };

      enum channel_data_type { snorm_int8 = CL_SNORM_INT8,
                               snorm_int16 = CL_SNORM_INT16,
                               unorm_int8 = CL_UNORM_INT8,
                               unorm_int16 = CL_UNORM_INT16,
                               unorm_short_565 = CL_UNORM_SHORT_565,
                               unorm_short_555 = CL_UNORM_SHORT_555,
                               unorm_int_101010 = CL_UNORM_INT_101010,
                               signed_int8 = CL_SIGNED_INT8,
                               signed_int16 = CL_SIGNED_INT16,
                               signed_int32 = CL_SIGNED_INT32,
                               unsigned_int8 = CL_UNSIGNED_INT8,
                               unsigned_int16 = CL_UNSIGNED_INT16,
                               unsigned_int32 = CL_UNSIGNED_INT32,
                               float16 = CL_HALF_FLOAT, float32 = CL_FLOAT };

      // public member functions
      explicit image_format(cl_channel_order, cl_channel_type);
      explicit image_format(const cl_image_format &);
      image_format(const image_format &);
      image_format & operator=(const image_format &);
      ~image_format();
      const cl_image_format * get_format_ptr() const;
      bool operator==(const image_format &) const;
      bool operator!=(const image_format &) const;
    };

## Description

For example, to create a format for a 8-bit RGBA image:

    boost::compute::image_format rgba8(CL_RGBA, CL_UNSIGNED_INT8);

After being constructed, image_format objects are usually passed to the constructor of the various image classes (e.g. image2d, image3d) to create an image object on a compute device.

Image formats supported by a context can be queried with the static get_supported_formats() in each image class. For example:

    std::vector<image_format> formats = image2d::get_supported_formats(ctx);

See Also: image2d

### `image_format` public member functions

1.     explicit image_format(cl_channel_order order, cl_channel_type type);

   Creates a new image format object with `order` and `type`.

2.     explicit image_format(const cl_image_format & format);

   Creates a new image format object from `format`.

3.     image_format(const image_format & other);

   Creates a new image format object as a copy of `other`.

4.     image_format & operator=(const image_format & other);

   Copies the format from `other` to `*this`.

5.     ~image_format();

   Destroys the image format object.

6.     const cl_image_format * get_format_ptr() const;

   Returns a pointer to the `cl_image_format` object.

7.     bool operator==(const image_format & other) const;

   Returns `true` if `*this` is the same as `other`.

8.     bool operator!=(const image_format & other) const;

   Returns `true` if `*this` is not the same as `other`.