kunzmi / managedCuda

ManagedCUDA aims an easy integration of NVidia's CUDA in .net applications written in C#, Visual Basic or any other .net language.
Other
440 stars 79 forks source link

Crop NPP image #78

Closed serjl closed 4 years ago

serjl commented 4 years ago

Hello kunzmi,

I was trying to crop an NPP Image NPPImage_8uC1 src by the following code:

src.SetRoi(nppRect); NPPImage_8uC1 dest= new NPPImage_8uC1(nppRect.width, nppRect.height); dest.CopyToDevice(scr.DevicePointerRoi, dest.Pitch);

dest.CopyToHost(bitmap); As a result the bitmap is corrupted - kinda wrong pitch - pixels are spread wrong .

I guess I'm using CopyToDevice wrong.

What is the best and short way to crop the NPP image on GPU. (Of course I can write a kernel and run it). Can you please consult in the issue. Thank you a lot in advance.

kunzmi commented 4 years ago

dest.CopyToDevice(scr.DevicePointerRoi, dest.Pitch) -> use the src.Pitch as argument. Or simply use src.Copy(dest), that one handles all ROI settings.

Notice also, that if you want to copy the final image to a bitmap of different size you have to use CopyToHostRoi.

serjl commented 4 years ago

Thanks a lot for a quick reply! Both work nice as expected.