FMX.ImageFilters Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample demonstrates how to apply filter effects to images.


You can find the ImageFilters sample project at:

  • Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to:
    • CPP\Multi-Device Samples\User Interface\ImageFilters
  • Subversion Repository:
    • You can find C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.


The ImageFilters sample demonstrates how to apply the Sepia filter to an image. The sample uses TOpenDialog to let the user select an image. Then, the sample uses TFilterSepia to apply a sepia effect to the image, and TSaveDialog to save the filtered image.

How to Use the Sample

  1. Navigate to the location given above and open CppImageFilters.cbproj.
  2. Select the target platform.
  3. Press F9 or choose Run > Run.
  4. Interact with the sample:
    • Click on the Open Bitmap button to open the file selection dialog.
    • Select an image.
    • Move the track bar to select the intensity of the sepia color that is applied over the image.
    • Click on the Save Filtered Bitmap button to open the dialog box for saving files.
    • Save the filtered image.


File in C++ Contains


The project itself.


The main form where the components are located.

CppImageFiltersPCH.h, MainForm.cpp

Used to define and implement the sample.


TForm1 is the main form that represents the main window of the sample. It contains the following components:


  • The sample uses TImage to display and define 2D image components.
  • The sample uses TTrackBar to adjust the intensity properties of the sepia effect.
  • The sample usesTOpenDialog to display a file selection dialog.
  • The sample usesTSaveDialog to display a dialog box for saving files.
  • The sample uses TButton to call the open and save dialogs.

When you run the application, the sample shows two buttons labeled as Open Bitmap and Save Filtered Bitmap. Click on the Open Bitmap button to call the TOpenDialog class and to display the selection file dialog. When you choose an image, the sample displays the selected image two times on your FireMonkey form. The image displayed at the left side of your FireMonkey form is the original image, while the image displayed at the right side of your FireMonkey form is the sepia filtered image. You can change the intensity property of the sepia effect by changing the value of the track bar. To change the value of the track bar move the slide indicator or click on a particular location of the bar. To save the filtered image, click on the Save Filtered Bitmap button. It calls the TSaveDialog class and displays the save as dialog box.


See Also