I am using Cudafy as c# wrapper
I need to get colour info InputBitmap0.GetPixel(x, y) of a bitmap and make an new bitmap for output .
I need the following work to be done in GPU.
IN CPU
OutputBitmap.SetPixel(object_point_x, object_point_y, InputBitmap0.GetPixel(x, y));
In short:
How to GetPixel() for each pixel point of the input Bitmap, SetPixel() for each pixel point of the outputbitmap Bitmap in GPU.
It took time but finally, I , cracked my case.
We have two
Bitmap: one for outputOutputBitmapand another for inputInputBitmap0Lets divide this task into parts:
InputBitmap0.GetPixel()forx,ycoordinateOutputBitmap.SetPixel()for a different coordinateobject_point_x, object_point_yCudafy does not support
BitmaporColortype data. So I converted the Bitmaps tobytetype.We have copied the content of the
InputBitmap0to thergbValuesarray. Now we need to do the work ofGetPixel()(get the values of R,G,B,A).We need to do the above work ( make array) for
OutputBitmaptoo because we will be doingSetPixel()in GPU but we will copy the array back to the bitmap later.Its GPU time for calculation. Lets initialize gpu.
Now send
input_ragba_colorandoutput_ragbato the gpu because we can iterate the array and do any calculation.Now inside GPU(kernel)
We now know that gpu has populated an array(
dev_output_rgba_color) for ourOutputBitmap.Copy the result back to the
OutputBitmapusing the memory pointer and unlock it from the memory.Now the
OutputBitmapcontains the updated values.