Site icon Learn C++

How To Add A Sepia Image Effect In Your Apps With No Code

What is a sepia effect in a C++ app? Is there an easy way to add sepia effects to components? How can I add a sepia effect to alpha images in my applications? How can I use the TSepiaEffect component in C++ Builder? What are the visual tips to add a sepia effect in the development of C++ applications? Let’s answer these questions.

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. One of the greatest features of VCL and FMX UI frameworks are the effects on UI elements. There are many UI effects that can be used on most of the visual elements supported officially by the Embarcadero. There are many good effects that we can use: Sepia Effect, Reflection Effects, Shadow Effects, Emboss Effects, Glow Effects, etc. Let’s see how we can apply a sepia effect to our images in C++ Builder.

What is a Sepia Effect?

The sepia effect is a tonal editing technique that adds a warmer tone to a given image, so it appears to have a vintage or archival quality. Generally, Sepia effects have good results when used on photos. If you want to add some warmer style to your composition, the sepia effect works exceptionally well with black and white images. With C++ Builder, you can add a sepia effect to your color images by using TSepiaEffect. Let’s see how we can use TSepiaEffect.

How to use TSepiaEffect in C++ Builder?

TSepiaEffect is a class to create sepia effects for visible objects like images, shapes and similar items. TSepiaEffects affect the texture of visual objects. For further information, go to TImageFXEffect and FireMonkey Image Effects. Using these components, you can apply a sepia effect to screen elements and images with NO CODE at all!

The intensity of the sepia color applied over the texture can be set through the Amount property. The following table shows the result of the TSepiaEffect effect on a .png picture, placed on a form (using a TImage object). The default value (Amount=0.5) is used to set the sepia amount.

  1. Create a new Multi-Device C++ Builder Project, save all project files in a folder
  2. Drag a TImage component from Palette onto the Form,
  3. Load an Image by using its MultiResBitmap property
  4. Copy and paste this TImage (Image1), position the new one (Image2) to the left
  5. Now we have two same Images. Let’s add SepiaEffect to the right one.
  6. Drag TSepiaEffect from Palette to the new TImage (i.e.Image2). If you do this it will automatically add Sepia Effect on the new Image with the 0.5 amount which is the default.
  7. You can modify the Amount (0 to 1.0) of Sepia Effect from the Object Inspector if you want. Lower values add the lighter amount of sepia effect, higher values have much. The maximum is 1.0.

8. Finally, you can run the application by pressing F9 or Run button, Here is the result.

What are some additional tips on adding sepia effects to images at design or run time?

As you see the sepia effect can be a great tool if you want users to modify their images (like photo editors, photo effectors) by adding a sepia option with no, or almost no coding required by you. You can let users set the amount (really, the strength) of the sepia effect. Note that you can also develop a custom pixel manipulator in C++ if you want to develop more professional sepia effects with more optional parameters.

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.

Exit mobile version