opencl(六)----图像对象

图像对象同样使用cl_mem数据结构

创建图像对象

// 创建2D的图像对象
cl_mem clCreateImage2D ( cl_context context,
//上下文 cl_mem_flags flags, // 对象性质标签 const cl_image_format *image_format, //输入图像数据格式 size_t image_width, // size_t image_height, // size_t image_row_pitch, //每一行中的字节数 void *host_ptr, // 主机地址 cl_int *errcode_ret //错误代码 )
//创建3D的图像对象

cl_mem clCreateImage3D (
        cl_context context,
     cl_mem_flags flags,
     const cl_image_format *image_format,
     size_t image_width,           //
     size_t image_height,          //
     size_t image_depth,          //
     size_t image_row_pitch,    //每一行字节数
     size_t image_slice_pitch,    //每一层字节数
     void *host_ptr,
     cl_int *errcode_ret        //错误代码
)

// 当image_row_pitch设置为0:  默认image_width*像素点大小
// 当image_slice_pitch设置为0:  默认image_row_pitch*image_height
cl_image_format 图像格式
参考:https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/cl_image_format.html

typedef struct _cl_image_format

{

     cl_channel_order image_channel_order; //色彩通道,以及各通道顺序

     cl_channel_type image_channel_data_type; // 数据类型

}cl_image_format;

获取图像对象相关信息

cl_int clGetImageInfo 
(    
     cl_mem  image ,         //图像对象
     cl_image_info  param_name ,   //信息名称
     size_t  param_value_size ,       //所要保存的字节数
     void  *param_value ,              // 所要保存的地址
     size_t  *param_value_size_ret   // 信息应有的字节数
)
//cl_image_info 可获取的信息种类枚举参考: https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/clGetImageInfo.html
原文地址:https://www.cnblogs.com/feihu-h/p/12081652.html