NPP library

Hi,

Trying to use NPP to resize a image and position it on a background image. I have the resize working but how do I copy and reposition. nppiCopy_8u_C4R seems to copy a portion of the image from the origin (0,0) how do I specify a offset for the ROI?

thanks,
Robert

Hi Robert,

you would use basic pointer arithmetic to move the ROI in the source or destination.

So if you wanted to copy a source image of some size into a destination image starting at pixel (10,20), you’d do this:

[font=“Courier New”]Npp8u * pDst; // the destination image, assume that this has been allocated and filled with something

Npp8u * pDstOffset_10_20 = pDst + 20 * nDstStep + 10 * 4 /* four-channel */ * sizeof(Npp8u);

nppiCopy_8u_C4R(pSrc, nSrcStep, pDstOffset, nDstStep , oSizeROI);[/font]

Note, that oSizeROI must not exceed the source image’s size AND the destination image’s size reduced by the offset, i.e. destWidth - 10, destHeight - 20.

Hope that helps,

–Frank