How to get pixel of image1d_t?

I tried to work with 1d image in my kernel, but I’m not sure that I know, how the pixels are stored in memory. I created a buffer as follow:

cl_image_desc desc;
    desc.image_type = CL_MEM_OBJECT_IMAGE1D;
    desc.image_width = img.width();
    desc.image_height = img.height();
    desc.image_array_size = 0;
    desc.image_depth = 0;
    desc.image_row_pitch = 0;
    desc.image_slice_pitch = 0;
    desc.num_mip_levels = 0;
    desc.num_samples = 0;
    desc.buffer = nullptr;

    cl_mem inputImage = clCreateImage(context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, &format, &desc, img.bits(), &error);

I supposed that rows of an image are next to each other, so I thought that pixel with coordinates [x,y] is at [y*image_width + x] position in 1d image. So how to read_imagef() pixel of image1d_t in kernel?

You don’t access images like memory, you use read_imagef and pass the coordinate of the pixel you want to read. There are many examples online. Why are you talking about “y” for a 1D image? Only “x” applies for 1D. If your height is not 1 then you should use a 2D image.