How do I created a new cropped image from a selected area?

I’m using C# and trying to create a new Cvb.Image.IMG from an selected area of and existing displayed image but cannot work out what to call to use the GetSelectedArea() values for the new image.

1 Like

Hi @Shane

The GetSelectedArea() function gives you the three corner points of the selected ROI of the display.
These points can then be used to extract a sub image from the original one:

Image DLL Reference: Image Handling

cvbbool_t CreateImageMap ( IMG ImageIn ,
cvbval_t InLeft ,
cvbval_t InTop ,
cvbval_t InRight ,
cvbval_t InBottom ,
cvbval_t OutWidth ,
cvbval_t OutHeight ,
IMG & ImageOut

Creates a new mapped image object based on the rectangular area of interest and scales it to a destination size.

The rectangular AOI ( InLeft , InTop , InRight , InBottom ) will be scaled to the given OutWidth and OutHeight .

This function does not copy data and therefore will be extremely fast. It only creates a view of the original ImageIn using its pixel buffer. Newly created are only one VPAT per plane and a TCoordinateMap.

Taken from our documentation at %CVB%Doc.

:exclamation: Anyway, we strongly recommend using our modern, object oriented CVB.Net API.
You can find a very good intro to the API in this post.



Great thanks, that’s exactly what I was looking for.


1 Like