Gabriel
"Mark Kimball" <maki...@hotmail.com> wrote in message
news:436e...@newsgroups.borland.com...
Here is the fastest way to do it: 4 times rotatate in 0milliseconds (0.8ms)
procedure TForm1.Button1Click(Sender: TObject);
Var
T1,T2 : DWord;
begin
T1:=gettickcount;
// Image1 must contain the picture to rotate, remember: no strect
Image2.Canvas.CopyRect(Rect(0,0,217,185),Image1.Canvas,Rect(217,0,0,185));
Image3.Canvas.CopyRect(Rect(0,0,217,185),Image2.Canvas,Rect(0,185,217,0));
Image4.Canvas.CopyRect(Rect(0,0,217,185),Image3.Canvas,Rect(217,0,0,185));
T2:=gettickcount;
Label1.caption:=' Time '+inttoStr(T2-T1);
end;
Regards
Jorgen Bauer
www.dncflex.dk please sign the guestbook to do a country test for me
Sorry that was mirror / flip
Just turn the pixels around. You need to work with intermediate bitmaps
to do the pixel processing.
procedure Rotate90(Source: TGraphic; Target: TJpegImage);
var
SourceBmp, TargetBmp: TBitmap;
r, c: Integer;
x, y: Integer;
begin
SourceBmp := TBitmap.Create;
SourceBmp.Assign(Source);
TargetBmp := TBitmap.Create;
TargetBmp.Width := SourceBmp.Height;
TargetBmp.Height := SourceBmp.Width;
for r := 0 to SourceBmp.Height - 1 do
begin
for c := 0 to SourceBmp.Width - 1 do
begin
//x := (SourceBmp.Height-1) - r; // -90
//y := c; //-90
x := r; //90
y := (SourceBmp.Width-1) - c; //90
// look into Bitmap.ScanLine for faster pixel access
TargetBmp.Canvas.Pixels[x, y] := SourceBmp.Canvas.Pixels[c, r];
end;
end;
Target.Assign(TargetBmp);
SourceBmp.Free;
TargetBmp.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Jpeg: TJPEGImage;
begin
Jpeg := TJPEGImage.Create;
Rotate90(Image1.Picture.Graphic, Jpeg);
Image1.Picture.Assign(Jpeg);
Jpeg.Free;
end;
http://codecentral.borland.com/Item.aspx?id=19723
It rotates Jpegs losslessly so that you don't lose any quality doing it.
Recommended!
Cheers,
Nicholas Sherlock
var
MySourceImage: tBitmap32;
MyDestImage: tBitmap32;
begin
.
.
MySourceImage.Rotate90(MyDestImage);
.
.
end;
both images need to be tBitMap32.
-scott
"Mark Kimball" <maki...@hotmail.com> wrote in message
news:436e...@newsgroups.borland.com...
>