This example effect chart:
Code files:
Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, DIB, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Dxpaintbox1:tdxpaintbox;
Button1:tbutton;
Button2:tbutton;
Colorbox1:tcolorbox;
Colorbox2:tcolorbox;
Procedure Formcreate (Sender:tobject);
Procedure Formdestroy (Sender:tobject);
Procedure Button1Click (Sender:tobject);
Procedure Button2click (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Const STR = ' Spring ';
Var
Dib,dib1,dib2:tdib;
Procedure Tform1.formcreate (Sender:tobject);
Const
ImgPath1 = ' C:\Temp\DX.jpg ';
Begin
Dib: = Tdib. Create;
DIB1: = Tdib. Create;
DIB2: = Tdib. Create;
Dib. LoadFromFile (IMGPATH1);
Dxpaintbox1.clientwidth: = Dib. Width;
Dxpaintbox1.clientheight: = Dib. Height;
DXPaintBox1.DIB.Assign (DIB);
Dib1. Assign (DIB);
Dib2. SetSize (DIB). Width, Dib. Height, 24);
Dib2. Canvas.Brush.Style: = Bsclear;
Dib2. Canvas.Font.Name: = ' black body ';
Dib2. Canvas.Font.Size: = 90;
Dib2. Canvas.Font.Style: = [Fsbold];
colorbox1.selected: = Clblack;
colorbox2.selected: = Clyellow;
End
Procedure Tform1.formdestroy (Sender:tobject);
Begin
Dib. Free;
Dib1. Free;
Dib2. Free;
End
Procedure Tform1.button1click (Sender:tobject);
Begin
Dib1. Assign (DIB);
Dib2. Fill (colorbox1.selected);
Dib2. Canvas.Font.Color: = colorbox2.selected;
Dib2. Canvas.textout (0, 0, str);
Dib1. Drawalphamask (dib2, DIB1, 0, 0, Dib. Width, Dib. Height, 0, 0);
DXPaintBox1.DIB.Assign (DIB1);
Dxpaintbox1.repaint;
End
Procedure Tform1.button2click (Sender:tobject);
Begin
Dib1. Assign (DIB);
Dib2. Fill (colorbox2.selected);
Dib2. Canvas.Font.Color: = colorbox1.selected;
Dib2. Canvas.textout (0, 0, str);
Dib1. Drawalphamask (dib2, DIB1, 0, 0, Dib. Width, Dib. Height, 0, 0);
DXPaintBox1.DIB.Assign (DIB1);
Dxpaintbox1.repaint;
End
End.