Hello,
There are at least two different ways this can be accomplished. The first would be to use the
CopyRectangleCommand. Since you know the coordinates of the area you want to display, you can use this image processing command copy that specific area. The command will create a new image of just that rectangle, which you can then use to display.
Another alternative would be to do some image processing on the source image directly. With the
AlphaBlendCommand, you can create another image that is the same size as your source image. You would then use the
FillCommand to make the area you do not want displayed to be white. The area you want to be displayed will be black. Then combine the two images with AlphaBlend.
Here is some pseudo-code (Note: this will not compile):
//Get a handle the image
RasterImage srcImage = rasterImageViewer1.Image;
//Make copy
RasterImage maskImage = new RasterImage(srcImage);
FillCommand fillCmd = new FillCommand(white);
//Fill the whole image with white
fillCmd.Run(maskImage);
LeadRect rect = new LeadRect(100, 100, 100, 200);
//Create a rectangle in the image to only be filled
maskImage.AddRectangleToRegion(rect, RasterRegionCombineMode.Set);
//Fill the area we want to remain visible with black
fillCmd.Color = new RasterColor(black);
fillCmd.Run(maskImage);
//get rid of the prior set rectangle
maskImage.MakeRegionEmpty();
//Combine the images
AlphaBlendCommand alphaBlendCmd = new AlphaBlendCommand();
alphaBlendCmd.DestinationRectangle = new LeadRect(0, 0, maskImage.Width, maskImage.Height);
alphaBlendCmd.SourceImage = maskImage;
alphaBlendCmd.Opacity = 255;
alphaBlendCmd.Run(srcImage);
There may be other ways to accomplish this, but I think these two would be the easiest depending on which resultant output you would prefer.
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.