unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,GR32, GR32_Image;
type
TForm1 =
class(TForm)
Button1: TButton;
Image321: TImage32;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
procedure PaintCover(DestBitmap:TBitmap32;x,y,width,height:integer;perspectiv:single;angle:integer;picture:TBitmap32);
var lo,lu,ro,ru:TPoint;
mo,mu:extended;
i,j:integer;
dummy:integer;
begin
//vier Eckpunkte des Covers berechnen:
lo.x:=x;
lo.Y:=y;
lu.X:=x;
lu.Y:=y+height;
ru.x:=round(lu.x+width*cos(abs(angle)/360*2*Pi));
ru.y:=round(lu.y-perspectiv*height/2*sin(abs(angle)/360*2*Pi));
ro.X:=ru.x;
ro.Y:=round(ru.y-height+perspectiv*height*sin(abs(angle)/360*2*Pi));
if angle<0
then
begin
dummy:=ro.y;
ro.y:=lo.y;
lo.y:=dummy;
dummy:=ru.y;
ru.y:=lu.y;
lu.y:=dummy;
dummy:=(width-(ro.x-lo.x));
lo.x:=lo.x+dummy;
lu.x:=lu.X+dummy;
ro.x:=ro.X+dummy;
ru.x:=ru.x+dummy;
end;
//Steigung der oberen und unteren Kante berechnen:
mo:=-(ro.Y-lo.Y)/(ro.x-lo.X);
mu:=-(ru.Y-lu.Y)/(ru.x-lu.x);
//bild zeichnen:
DestBitmap.BeginUpdate;
DestBitmap.Clear(clblack);
for i:=0
to (ro.X-lo.x)
do
for j:=round(-i*mo)
to round((lu.Y-lo.y)+i*mo)
do
DestBitmap.Pixel[lo.X+i,lo.Y+j]:=round(picture.Pixels[round(picture.Width/(ro.x-lo.X)*i),round(picture.Height/((lu.Y-lo.y)+2*i*mo)*(j+i*mo))]);
//Rechteck zeichnen:
with DestBitmap
do
begin
pencolor:=clsilver;
moveto(lo.x,lo.y);
linetos(lu.x,lu.y);
linetos(ru.x,ru.y);
linetos(ro.x,ro.y);
linetos(lo.x,lo.y);
end;
DestBitmap.EndUpdate;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var aBmp32:TBitmap32;
begin
aBmp32:=TBitmap32.create;
//erstmal das Objekt erstellen
aBmp32.loadfromfile('
cover.bmp');
PaintCover(Image321.Bitmap,0,0,50,50,0.5,30,aBmp32)
end;
end.