IGxImage.CopyRect

Syntax

CopyRect(Rect: IGxRect): IGxImage;

Parameters

Rect - rectangle that bounds the current image part that is necessary to get.

Description

The CopyRect method returns the part of the current image bound by the rectangle passed by the Rect parameter.

Comments

The method returns the image part placed in the specified rectangular part. The size of the rectangle passed in the Rect parameter should not be greater than the current image.

Example

Executing the example requires a form that contains the ImageButton button named ImageButton1 and the ImageBox component named ImageBox1. The ImageBox1 component occupies the whole client area of the form creating the form background. Any image is loaded to the component.

Sub ImageButton1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    r: IGxRect;
    Img: IGxImage;
Begin
    r := New GxRect.Create(ImageButton1.Left,
        ImageButton1.Top,
        ImageButton1.Left + ImageButton1.Width,
        ImageButton1.Top + ImageButton1.Height);
    Img := ImageBox1.GetImage;
    Img := Img.CopyRect(r);
    ImageButton1.NormalLook.Background := Img;
End Sub ImageButton1OnClick;

After starting, the form may look as follows:

After the button is clicked, the part of the image that the button occupies over the ImageBox1 component is set as the button's background. Due to this, the button becomes transparent:

See also:

IGxImage