이미 프로젝트에서 리용하고있던 graphics32에 있는 데모를 고쳐서 대충 테스트해봤는데 큰 오류는 없는것 같습니다.
<!--CodeS-->
TForm1 = class(TForm)
Src: TImage32;
Dst: TImage32;
btn1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure btn1Click(Sender: TObject);
protected
public
PT: TProjectiveTransformation;
TT: TTransformation;
Vertices: array[0..3] of TPoint;
procedure DoTransform;
procedure GenTransform;
procedure PrepareSource;
procedure InitVertices; // for projective mapping
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Dst.SetupBitmap; // set the destination bitmap size to match the image size
PrepareSource;
PT := TProjectiveTransformation.Create;
TT := PT;
InitVertices;
DoTransform;
end;
procedure TForm1.PrepareSource;
begin
// make the border pixels transparent while keeping their RGB components
SetBorderTransparent(Src.Bitmap,
Rect(0, 0, Src.Bitmap.Width - 1, Src.Bitmap.Height - 1));
end;
procedure TForm1.DoTransform;
var
i, j: Integer;
P: PColor32;
begin
Application.ProcessMessages;
GenTransform;
Dst.BeginUpdate;
// Fill Dst with checkerboard pattern
P := Dst.Bitmap.PixelPtr[0, 0];
for j := 0 to Dst.Bitmap.Height - 1 do
for i := 0 to Dst.Bitmap.Width - 1 do
begin
if Odd(i shr 4) = Odd(j shr 4) then P^ := clGray32
else P^ := clWhite32;
Inc(P);
end;
procedure TForm1.btn1Click(Sender: TObject);
var i, w, h : Integer;
al : single;
begin
w := src.Bitmap.Width;
h := src.Bitmap.Height;
for i := 0 to 45 do
begin
al := 3.14 * i / 90;
Vertices[1].X := Trunc(w * Cos(al));
Vertices[1].Y := -Trunc(0.4 * w * Sin(al)) + 50;
Vertices[2].X := Trunc(w * Cos(al));
Vertices[2].Y := -Trunc(0.4 * w * Sin(al)) + h + 50;
DoTransform;
Sleep(20);
end;
오래전에 올리긴 했었는데요, OpenGL로 간단히 만든겁니다
부드럽게 하려면 수학 공식을 더 사용하면 할 수 도 있겠지요...더 만드시면 올려주세요
target=_blank>http://www.delphi.co.kr/zboard/view.php?id=component&page=1&sn1=on&divpage=1&sn=on&ss=off&sc=off&keyword=홍성락&select_arrange=headnum&desc=asc&no=1652