FMXTBitmapClear (Delphi)
From RAD Studio Code Examples
Contents |
Description
This example shows how to use the TBitmap clear functions and their results.
The TBitmap's clear functions are Clear and ClearRect.
To build and test this example, create a FireMonkey HD Application - Delphi, and add the following objects on the form:
- Two TImage objects
- Two labels
- A TGroupBox with two TRadioButton objects (a radio button for each function). Change the TRadioButton.Text property for each radio button with the name of a function.
Add a new bitmap as a global variable and name it MyBitmap. It will be used to save a copy of the initial bitmap.
Code
var Form1: TForm1; MyBitmap: TBitmap;
Add the following code to the OnCreate event handler of the form. The code loads the bitmap into Image1, so it can be manipulated, and initializes MyBitmap.
procedure TForm1.FormCreate(Sender: TObject); begin //creates an empty bitmap MyBitmap:=TBitmap.Create(0,0); //loads the initial bitmap (to be manipulated) to Image1 Image1.Bitmap.LoadFromFile('bitmap1.png'); end;
Add the following lines of code to the OnChange event handlers of each radio button. The result will be displayed on the Image2.
Code
procedure TForm1.RadioButton1Change(Sender: TObject); begin //a copy of the initial bitmap MyBitmap.Assign(Image1.Bitmap); //clears the bitmap MyBitmap.Clear(clablue); //displays the result of the Clear function Image2.Bitmap:=MyBitmap; end; procedure TForm1.RadioButton2Change(Sender: TObject); var MyRect: TRectF; begin //the rectangle to be cleared MyRect.Create(50,30,80,100); //a copy of the initial bitmap MyBitmap.Assign(Image1.Bitmap); //clears the bitmap MyBitmap.ClearRect(MyRect); //displays the result of the ClearRect function Image2.Bitmap:=MyBitmap; end;
The result should look like in the following images:
Uses
- FMX.Types.TBitmap.Clear ( fr | de | ja )
- FMX.Types.TBitmap.ClearRect ( fr | de | ja )
- System.Types.TRectF ( fr | de | ja )
- FMX.Controls.TTextControl.Text ( fr | de | ja )
- FMX.Objects.TImage.Bitmap ( fr | de | ja )
See Also
- FMX.Forms.TCommonCustomForm.OnCreate ( fr | de | ja )
- FMX.Objects.TImage ( fr | de | ja )
- FMX.StdCtrls.TRadioButton.OnChange ( fr | de | ja )

