Registriert seit: 18. Dez 2002
38 Beiträge
Delphi 6 Personal
|
16. Jan 2003, 17:29
aus dem obigen vorgeschlagenen Code hab ich folgendes gemacht:
Delphi-Quellcode:
Procedure Turn(bitmap,dest:tBitmap;a:integer);
Type tLine = Array[0..0] of Byte;
pline = ^tLine;
Var Linesize,Linesize2, y, x : Integer;
Field,temp : pline;
Pixsize : Longint;
FieldSize : Longint;
Begin
if Bitmap.Pixelformat in [pf1Bit,pf4Bit] then Bitmap.PixelFormat:=pf16bit;
Dest.PixelFormat:=Bitmap.PixelFormat;
Case Bitmap.PixelFormat of
pf16Bit : Pixsize:=2;
pf24Bit : Pixsize:=3;
pf32Bit : Pixsize:=8;
End;
Linesize:=Bitmap.width * Pixsize;
FieldSize:=Linesize*Bitmap.Height;
GetMem(Field, fieldSize);
For y:=0 to Bitmap.height-1 do
Move(Bitmap.ScanLine[y]^, Field[y*Linesize], LineSize);
Case a of
0:BEgin
Dest.Width:=Bitmap.Width;
Dest.Height:=Bitmap.Height;
Linesize2:=Pixsize*Dest.width;
End;
90:BEgin
Dest.Width:=Bitmap.Height;
Dest.Height:=Bitmap.Width;
Linesize2:=Pixsize*Dest.width;
Getmem(temp,Fieldsize);
For y:=0 to Bitmap.Height-1 do
For x:=0 to Bitmap.width-1 do
Begin
Move(Field[(y)*Linesize + (x)*Pixsize],temp[(x)*Linesize2 + (bitmap.height -y -1)*Pixsize],Pixsize);
End;
Freemem(field,Fieldsize);
Field:=temp;
End;
180:Begin
Dest.Width:=Bitmap.Width;
Dest.Height:=Bitmap.Height;
Linesize2:=Pixsize*Dest.width;
Getmem(temp,Fieldsize);
For y:=0 to Bitmap.Height-1 do
For x:=0 to Bitmap.width-1 do
Begin
Move(Field[(Bitmap.height -y -1)*Linesize + (Bitmap.width - x -1)*Pixsize],temp[y*Linesize2 + x*Pixsize],Pixsize);
End;
Freemem(field,Fieldsize);
Field:=temp;
End;
270:BEgin
Dest.Width:=Bitmap.Height;
Dest.Height:=Bitmap.Width;
Linesize2:=Pixsize*Dest.width;
Getmem(temp,Fieldsize);
For y:=0 to Bitmap.Height-1 do
For x:=0 to Bitmap.width-1 do
Begin
Move(Field[(y)*Linesize + (x)*Pixsize],temp[(Bitmap.width - x -1)*Linesize2 + (y)*Pixsize],Pixsize);
End;
Freemem(field,Fieldsize);
Field:=temp;
End;
End;
For y:=0 to Dest.height-1 do
Move(Field[y*Linesize2],Dest.ScanLine[y]^,Linesize2);
Freemem(Field,Fieldsize);
End;
für verbesserungen hab ich immer ein offenes ohr
für 1 und 4 bittige bilder funzt das nicht deswegen wird dann auf 16bit gezwungwn (weil dann 0 < pixsize <1 )
|
|
Zitat
|