To write into an image in a kernel you have to use the function write_imageui.
Here is an example on how you can copy an image2d into another one using a kernel. (Note that that for this purpose it is better to use the clEnqueueCopyImage() into the “client” API.
__kernel void CopyImage(__read_only image2d_t imageIn,__write_only image2d_t imageOut)
const sampler_t sampler=CLK_NORMALIZED_COORDS_FALSE|CLK_ADDRESS_CLAMP|CLK_FI
int gid0 = get_global_id(0);
int gid1 = get_global_id(1);