我是通过计算切点,但这样太太麻烦了,一大篇代码,还不能转....最好有点原码谢谢!!!!
解决方案 »
- sendmessage和postmessage的一些用法
- 辞职了。。。。。天亮了。。。。。早就想走了。。。。。。。
- 如何把fastreport未满一页的内容,用空行补全
- 问一个有关EDIT控件的问题
- 大四在公司实习有薪水拿吗?
- 如何根据tag确定某控件?
- 在一个数据集里怎样把某列的数据复制到另一列中。方法要有效。
- 哪里有DELPHI6的最新补丁包下载?宝兰站上的要注册的。
- Delphi中对控件的操作可以置visible为false么?
- bcb,我在调用线程的时提示“fffffffff"等一串的错误,我不太熟,你能给我一个你的程序吗?可以的话,email:[email protected],谢谢!!!
- 请问高手 如何给做好的数据库程序打包
- install source中的.pas,出现这样的错误,请帮忙看看
这样应该好些了:
Graphics::TBitmap *TmpBmp = new Graphics::TBitmap();
TmpBmp->Width = Image1->Height;
TmpBmp->Height = Image1->Width;
for(int i=0; i<TmpBmp->Height; i++)
{
for(int j=0; j<TmpBmp->Width; j++)
{
TmpBmp->Canvas->Pixels[j][i] =
Image1->Picture->Bitmap->Canvas->Pixels[i][TmpBmp->Width-j-1];
}
}
Image1->Width = TmpBmp->Width;
Image1->Height = TmpBmp->Height;
Image1->Picture->Bitmap->Assign(TmpBmp);
delete TmpBmp;
我用C++ builder遍的,旋转90度例子,如果你只要算法应该没问题
Angle: Integer; BColor: TColor; hPb: Integer);
const
PI=3.1415926;
var
r1, c1: Integer;
r2, c2: Integer;//raw and col control variable
w1, h1: Integer;
w2, h2: Integer;//width and height variable
x1, y1: Double;
x2, y2: Double;//coordinate
cn, sn: Double;
Radian: Double;
Colour: TColor;
SrcBitmap: TBitmap;
DstBitmap: TBitmap;
begin
if not FileExists(SrcFile) then Exit;
SrcBitmap := TBitmap.Create;
try SrcBitmap.LoadFromFile(SrcFile);
except SrcBitmap.Free; Exit; end;
//Calculate radian
Radian := Angle/180*PI;
//Calculate cos(a) and sin(a)
cn := Cos(Radian);
sn := Sin(Radian);
w1 := SrcBitmap.Width;
h1 := SrcBitmap.Height;
//Calculate new height and new width
w2 := Round(Abs(w1*cn)+Abs(h1*sn));
h2 := Round(Abs(w1*sn)+Abs(h1*cn));
//Prepare to show progress
SendMessage(hPB,PBM_SETRANGE,0,h2 shl 16);
SendMessage(hPB,PBM_SETPOS,0,0);
//Create a new bitmap
DstBitmap := TBitmap.Create;
DstBitmap.Width := w2;
DstBitmap.Height := h2;
for r2 := 0 to h2-1 do
begin
for c2 := 0 to w2-1 do
begin
x2 := c2 - w2/2;
y2 := r2 - h2/2;
x1 := x2*cn+y2*sn;
y1 :=-x2*sn+y2*cn;
c1 := Round(x1+w1/2);
r1 := Round(y1+h1/2);
if (c1 >= 0) and (c1 < w1) and (r1 >= 0) and ( r1 < h1 ) then
Colour := SrcBitmap.Canvas.Pixels[c1,r1]//插值自己做吧:)
else
Colour := BColor;
DstBitmap.Canvas.Pixels[c2,r2] := Colour;
end;
SendMessage(hPB,PBM_SETPOS,r2+1,0);
end;
DstBitmap.SaveToFile(DstFile);
SrcBitmap.Free;
DstBitmap.Free;
end;