1

私は 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.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,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

ここに画像の説明を入力

4

0 に答える 0