作者:奋斗兵 | 来源:互联网 | 2023-09-12 10:41
http:wiki.lazarus.freepascal.orgBGRABitmap_tutorial_1bgrabitmap是一套用来修改和创建图像的单元,可以使用alpha通道,直接
http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial_1
bgrabitmap是一套用来修改和创建图像的单元,可以使用alpha通道,直接像素访问,快速图像处理。经过在Windows、Ubuntu和Mac OS X环境下测试,(最后一个版本不能在Mac工作)。
第一个例子,在窗体上画一个黄色长方形:
代码:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
BGRABitmap, BGRABitmapTypes;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormPaint(Sender: TObject);
var
bmp: TBGRABitmap;
begin
bmp := TBGRABitmap.Create(ClientWidth, ClientHeight, BGRABlack);
bmp.FillRect(20, 20, 100, 40, BGRA(255,192,0), dmSet); //fill an orange rectangle
bmp.Draw(Canvas, 0, 0, True); //render BGRABitmap on the form
bmp.Free; //free memory
end;
end.