FireMonkey TBitmap Clear C++ Code Sample

By: Tim DelChiaro

Abstract: This example shows how to use the TBitmap clear functions and their results

    FMXTBitmapClear (C++)





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 - C++, and add the following objects on the form:

Add a new bitmap as a global variable and name it MyBitmap. It will be used to save a copy of the initial bitmap.


#pragma resource "*.fmx"
TForm1 *Form1;
TBitmap *MyBitmap;

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.

void __fastcall TForm1::FormCreate(TObject *Sender)
 //Creates an empty bitmap
  MyBitmap = new TBitmap(0,0);
  //Loads the initial bitmap (to be manipulated) to Image1

Add the following lines of code to the OnChange event handlers of each radio button. The result will be displayed on the Image2.


void __fastcall TForm1::RadioButton1Change(TObject *Sender)
	//A copy of the initial bitmap
  //Clears the bitmap
  //Displays the result of the Clear function
  Image2->Bitmap =MyBitmap;
void __fastcall TForm1::RadioButton2Change(TObject *Sender)
  //The rectangle to be cleared
 TRectF MyRect=TRectF(50,30,80,100);
  //A copy of the initial bitmap
  //Clears the bitmap
  //Displays the result of the ClearRect function

The result should look like in the following images:




    See Also

Server Response from: ETNASC01