如何解决Graphics32:从GR32_PolygonsOld转换
我使用GR32库已有几年了,坚持使用一个不再维护的旧兼容性单元GR32_PolygonsOld。在某些时候,他们大量修改了Polygons单元,不再有TAntialiasMode和TPolygon32之类的东西,但是从来没有任何有关如何将旧代码迁移到新过程和类的文档。
如何将旧代码转换为可以使用2.0.0 Alpha及更高版本的新方法?
旧代码:(新代码不应使用不再属于其存储库的GR32_PolygonsOld单元,而是GR32_Polygons)
GR32官方图书馆:https://github.com/graphics32/graphics32
旧单元:https://github.com/graphicsmagicteam/graphicsmagic/blob/master/externals/Graphics32_3rd_Party/GR32_PolygonsOld.pas
unit Unit1;
interface
uses
Winapi.Windows,Winapi.Messages,System.SysUtils,System.Variants,System.Classes,Vcl.Graphics,Vcl.Controls,Vcl.Forms,Vcl.Dialogs,Vcl.ExtCtrls,GR32,GR32_PolygonsOld;
type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure b32DoRectangle(bitmap: TBitmap32; Coords: TRect; Color: TColor32; AA: Boolean; AAMode: TAntiAliasMode);
begin
With TPolygon32.Create do begin
Antialiased := AA;
if AA then AntialiasMode := AAMode;
Add(GR32.FixedPoint(Coords.Left,Coords.Top));
Add(GR32.FixedPoint(Coords.Right,Coords.Bottom));
Add(GR32.FixedPoint(Coords.Left,Coords.Bottom));
DrawFill(bitmap,Color);
Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
Var b32: TBitmap32;
begin
b32 := TBitmap32.Create;
b32.Width := 200;
b32.Height := 200;
b32.Clear(clWhite32);
b32DoRectangle(b32,Rect(20,20,70,70),SetAlpha(clRed32,20),True,am8times);
b32.DrawTo(Image1.Canvas.Handle,0);
b32.Free;
end;
end.
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 397
ClientWidth = 838
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Image1: TImage
Left = 32
Top = 32
Width = 305
Height = 209
end
end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。