Oder vielleicht so?
Delphi-Quellcode:
type
TTest = class
strict private
FBmp: TBitmap;
FIndex: Integer;
private
procedure GenerateBmp;
function GetSolid: TBitmap;
function GetTransparent: TBitmap;
public
constructor Create;
destructor Destroy; override;
public
property Solid: TBitmap read GetSolid;
property Transparent: TBitmap read GetTransparent;
property Index: Integer read FIndex write FIndex;
end;
implementation
constructor TTest.Create;
begin
inherited Create;
FBmp := TBitmap.Create;
FBmp.Width := 32;
FBmp.Height := 32;
FIndex := 0;
end;
destructor TTest.Destroy;
begin
FBmp.Free;
inherited Destroy;
end;
procedure TTest.GenerateBmp;
begin
FBmp.Canvas.TextOut(0, 0, IntToStr(FIndex));
FBmp.Dormant;
FBmp.FreeImage;
Inc(FIndex);
end;
function TTest.GetSolid: TBitmap;
begin
FBmp.Transparent := False;
GenerateBmp;
Result := FBmp;
end;
function TTest.GetTransparent: TBitmap;
begin
FBmp.Transparent := True;
GenerateBmp;
Result := FBmp;
end;
// updated, jaenickes Vorschlag integriert.