DrawImageTransparent(Image: IGxImage; DestRect: IGxRect; SrcRect: IGxRect; TransColor: IGxColor);
Image. Image.
DestRect. Integer rectangle where a part of the image should be rendered. If the Null value is sent as a parameter, the image is rendered according to the size sent in the SrcRect parameter.
SrcRect. Integer rectangle determining a part of the image, which should be rendered in the DestRect area. If the Null value is sent as a parameter, the whole available image area is taken.
TransColor. Image color interpreted as transparent. Transparent color is not displayed on image rendering. If Null is passed as a parameter, all colors of the image are rendered.
The DrawImageTransparent method renders the image in the specified integer rectangle with the specified transparency.
Executing the example requires a form with the button named Button1, the ImageBox component named. The file system should contain the image C:\Image.gif. Add links to the Drawing, Forms system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
BMP: IGxBitmap;
Image: IGxImage;
Graph: IGxGraphics;
Rect1, Rect2: IGxRect;
Begin
BMP := GxBitmap.CreateNew(ImageBox1.ClientWidth, ImageBox1.ClientHeight, GxPixelFormat.Format24bppRgb);
Image := GxImage.FromFile("c:\Image.gif");
Rect1 := New GxRect.Create(0, 0, ImageBox1.ClientWidth, ImageBox1.ClientHeight);
Rect2 := New GxRect.Create(120, 120, 180, 180);
Graph := GxGraphicsClass.FromImage(BMP);
Graph.DrawImageTransparent(Image, Rect1, Rect2, Null);
ImageBox1.Image := BMP;
End Sub Button1OnClick;
After executing the example clicking the button in the ImageBox component displays a new bitmap with rendered part of the graphic file C:\Image.gif.
See also: