unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure RotateBMP(BMP:TBitmap);
var
TempBmp:TBitmap;
i,j,W,temp:Integer;
begin
temp:=Integer(BMP.PixelFormat);
BMP.PixelFormat:=pf32bit;
TempBmp:=TBitmap.Create;
try
TempBmp.Assign(BMP);
W:=BMP.Width;
BMP.Width:=BMP.Height;
BMP.Height:=W;
Dec(W);
for i:=0 to BMP.Height-1 do
for j:=0 to BMP.Width-1 do
PInteger(Integer(BMP.ScanLine[W-i])+j*4)^:=
PInteger(Integer(TempBmp.ScanLine[j])+i*4)^;
BMP.PixelFormat:=TPixelFormat(temp);
finally
TempBmp.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
RotateBMP(Image1.Picture.Bitmap);
end;
end.
[
]散分吧!!!