| Home | Libraries | People | FAQ | More

## Class image2d

boost::compute::image2d — An OpenCL 2D image object.

## Synopsis

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

    class image2d : public boost::compute::image_object {
    public:

      // public member functions
      image2d();
      image2d(const context &, size_t, size_t, const image_format &,
              cl_mem_flags = read_write, void * = 0, size_t = 0);
      image2d(const image2d &);
      image2d & operator=(const image2d &);
      image2d(image2d &&) noexcept;
      image2d & operator=(image2d &&) noexcept;
      ~image2d();
      extents< 2 > size() const;
      extents< 2 > origin() const;
      template<typename T> T get_info(cl_image_info) const;
      template<int Enum> unspecified get_info() const;
      image2d clone(command_queue &) const;

      // public static functions
      static std::vector< image_format >
      get_supported_formats(const context &, cl_mem_flags = read_write);
      static bool is_supported_format(const image_format &, const context &,
                                      cl_mem_flags = read_write);
    };

## Description

For example, to create a 640x480 8-bit RGBA image:

See Also: image_format, image3d

### `image2d` public member functions

1.     image2d();

   Creates a null image2d object.

2.     image2d(const context & context, size_t image_width, size_t image_height,
               const image_format & format, cl_mem_flags flags = read_write,
               void * host_ptr = 0, size_t image_row_pitch = 0);

   Creates a new image2d object.

   See the documentation for

3.     image2d(const image2d & other);

   Creates a new image2d as a copy of `other`.

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

   Copies the image2d from `other`.

5.     image2d(image2d && other) noexcept;

   Move-constructs a new image object from `other`.

6.     image2d & operator=(image2d && other) noexcept;

   Move-assigns the image from `other` to `*this`.

7.     ~image2d();

   Destroys the image2d object.

8.     extents< 2 > size() const;

   Returns the size (width, height) of the image.

9.     extents< 2 > origin() const;

   Returns the origin of the image (`0`, `0`).

10.     template<typename T> T get_info(cl_image_info info) const;

    Returns information about the image.

    See the documentation for

11.     template<int Enum> unspecified get_info() const;

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

12.     image2d clone(command_queue & queue) const;

    Creates a new image with a copy of the data in `*this`. Uses `queue` to perform the copy operation.

### `image2d` public static functions

1.     static std::vector< image_format >
       get_supported_formats(const context & context,
                             cl_mem_flags flags = read_write);

   Returns the supported image formats for the context.

   See the documentation for

2.     static bool is_supported_format(const image_format & format,
                                       const context & context,
                                       cl_mem_flags flags = read_write);

   Returns `true` if `format` is a supported 2D image format for `context`.