This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Comctrls;
Type
TForm1 = Class (Tform)
Trackbar1:ttrackbar;
Trackbar2:ttrackbar;
Trackbar3:ttrackbar;
Label1:tlabel;
Label2:tlabel;
Label3:tlabel;
Button1:tbutton;
Procedure Formpaint (Sender:tobject);
Procedure Formcreate (Sender:tobject);
Procedure Formdestroy (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
Procedure Trackbar2change (Sender:tobject);
Procedure Trackbar3change (Sender:tobject);
Procedure Button1Click (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Var
Img:tgpimage;
Var
Colormatrix:tcolormatrix = (
(1.0, 0.0, 0.0, 0.0, 0.0),
(0.0, 1.0, 0.0, 0.0, 0.0),
(0.0, 0.0, 1.0, 0.0, 0.0),
(0.0, 0.0, 0.0, 1.0, 0.0),
(0.0, 0.0, 0.0, 0.0, 1.0));
Procedure Tform1.formcreate (Sender:tobject);
Begin
IMG: = tgpimage.create (' c:\temp\test.png ');
Trackbar1.height: = 23;
Trackbar1.showselrange: = False;
Trackbar1.min: =-100;
Trackbar1.max: = 100;
Trackbar1.position: = 0;
Trackbar2.height: = 23;
Trackbar2.showselrange: = False;
Trackbar2.min: =-100;
Trackbar2.max: = 100;
Trackbar2.position: = 0;
Trackbar3.height: = 23;
Trackbar3.showselrange: = False;
Trackbar3.min: =-100;
Trackbar3.max: = 100;
Trackbar3.position: = 0;
DoubleBuffered: = True;
End
Procedure Tform1.formdestroy (Sender:tobject);
Begin
Img. Free;
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
Imageattributes:tgpimageattributes;
Begin
G: = Tgpgraphics.create (Canvas.handle);
ImageAttributes: = tgpimageattributes.create;
colormatrix[4,0]: = trackbar1.position/100; {Add or Subtract red}
colormatrix[4,1]: = trackbar2.position/100; {Add or Subtract green}
colormatrix[4,2]: = trackbar3.position/100; {Add or Subtract blue}
Imageattributes.setcolormatrix (ColorMatrix);
G.drawimage (IMG, {image to draw}
Makerect, IMG. GetWidth, IMG. GetHeight), {The image will be indented to fit this rectangle}
0, 0, {drawing position}
Img. GetWidth, IMG. GetHeight, {size}
Unitpixel, {unit}
ImageAttributes {Image Properties}
);
Imageattributes.free;
G.free;
End
Procedure Tform1.trackbar1change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar2change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar3change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.button1click (Sender:tobject);
Begin
Trackbar1.position: = 0;
Trackbar2.position: = 0;
Trackbar3.position: = 0;
Repaint;
End
End.