unit Unit1;
{$mode objfpc}{$H+}
{$define test2}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
BGRABitmap, BGRABitmapTypes{, BGRALayers};
type
{ TForm1 }
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var bmp: TBGRABitmap;
bmp1: TBGRABitmap;
bmp2: TBGRABitmap;
bmp3: TBGRABitmap;
w,h : integer;
begin
w := Image1.Width;
h := Image1.Height;
{$ifdef test1}
bmp := TBGRABitmap.Create(w, h, BGRABlack);
bmp.FillRect(20, 20, w div 2 + 20,h div 2 + 20, BGRAWhite, dmSet); //zeichnet ein weißes Quadrat ohne Transparenz
bmp.FillRect(w div 2 - 20, h div 2 - 20, w-20, h-20 ,BGRA(0,0,255,128), dmDrawWithTransparency); //zeichnet ein transparentes blaues Quadrat
bmp.FillRect(20, 20, w div 2 + 20,h div 2 + 20, BGRAWhite, dmSet); //zeichnet ein weißes Quadrat ohne Transparenz
{$endif}
{$ifdef test2}
bmp := TBGRABitmap.Create();
// Blaues Viereck
bmp1 := TBGRABitmap.Create(w, h, ColorToBGRA(clBlue));
// Trasparentes Schwarzes Kreuz
bmp2 := TBGRABitmap.Create(w, h, ColorToBGRA(clFuchsia));
bmp2.Canvas.FillRect(0, 0, w, h);
bmp2.Canvas.Pen.Width:=7;
bmp2.Canvas.Pen.Style:=psSolid;
bmp2.Canvas.Line(10, 10, w-10, h-10);
bmp2.Canvas.Line(10, h-10, w-10, 10);
bmp2.ReplaceColor(ColorToBGRA(clFuchsia),BGRAPixelTransparent);
// Bilder zu einem Bitmap zusammenfügen
// bmp2 soll mit transparenter Farbe gezeichnet werden.
bmp3 := TBGRABitmap.Create();
bmp3.SetSize(bmp1.Width, bmp1.Height);
bmp3.PutImage(0, 0, bmp1, dmSet );
{
bmp3. ....
HOW TO INSERT BMP2 WITH TRANSPARENT COLOR clFuchsia HERE ?
}
// Bild dem endgültigem Bitmap übergeben
bmp.SetSize(bmp3.Width, bmp3.Height);
bmp.Assign(bmp3);
{$endif}
// ---- Darstellen von bmp
Image1.Picture.Bitmap.Assign(bmp);
end;
end.