您的位置:首页 > 其它

BGRABitmap图像操作1:最简单的例子,在窗体上画一个长方体

2016-08-31 14:25 423 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  TBGRABitmap