unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,PNGIMage, StdCtrls;
type
TBMPArray=Array
of TBitMap;
TForm2 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
FOrgPng:TPngImage;
FBMPArray:TBMPArray;
FCurrBMP:Integer;
FYellowIndex:Integer;
procedure NewBMP(g: TGraphic);
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
uses exGDIPapi,ExGDIPobj,EXGdi;
{$R *.dfm}
Procedure TForm2.NewBMP(g:TGraphic);
var
bmp:TBitmap;
begin
SetLength(FBMPArray,High(FBMPArray)+2);
FCurrBMP := High(FBMPArray);
bmp:=TBitmap.Create;
bmp.Assign(g);
FBMPArray[FCurrBMP] := bmp;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
G:TGPGraphics;
B:TGPSolidBrush;
begin
NewBMP(FBMPArray[FCurrBMP]);
FYellowIndex := FCurrBMP;
G := GetGraphics(FBMPArray[FCurrBMP].Canvas);
B:= GetSolidBrush(clYellow,200);
try
g.FillRectangle(b,MakeRect(10.0,10.,50,50));
finally
b.Free;
G.Free;
end;
invalidate;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
G:TGPGraphics;
B:TGPSolidBrush;
begin
if FYellowIndex>-1
then
begin
NewBMP(FBMPArray[FYellowIndex]);
G := GetGraphics(FBMPArray[FCurrBMP].Canvas);
B:= GetSolidBrush(clRed,200);
try
g.FillRectangle(b,MakeRect(20.0,10.,30,50));
finally
b.Free;
G.Free;
end;
invalidate;
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
var
G:TGPGraphics;
B:TGPSolidBrush;
begin
NewBMP(FBMPArray[0]);
G := GetGraphics(FBMPArray[FCurrBMP].Canvas);
B:= GetSolidBrush(clBlue,200);
try
g.FillRectangle(b,MakeRect(20.0,20.,30,50));
finally
b.Free;
G.Free;
end;
invalidate;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
FYellowIndex := -1;
FORGPng := TPNGImage.Create;
FORGPng.LoadFromFile('
C:\Bilder\IconCollection\ix_ap_all\128x128\shadow\About.png');
NewBMP(FORGPng);
end;
procedure TForm2.FormDestroy(Sender: TObject);
var
i:Integer;
begin
FORGPng.Free;
for I := Low(FBMPArray)
to High(FBMPArray)
do FBMPArray[i].free;
end;
procedure TForm2.FormPaint(Sender: TObject);
begin
Canvas.Draw(0,0,FBMPArray[FCurrBMP]);
end;
end.