Image1里是个指针图形。
解决方案 »
- 怎样让ReportMachine报表导EXcel时导到一个sheet里
- 请问个 TListItem 类的一个方法怎么用?
- delphi 7中 数据库编程关于 SQL插入语句转义的问题
- 如何用程序修改符点型字段的默认值(SQL2000)
- 用delphi进行GIS开发时,怎么改变字体???
- 小问题
- 紧急求救,编程修改桌面,不能马上出现,需要在桌面上手工刷新!
- 怎样释放一个链表,头都大了,数据结构没学过.研究了半天也没搞明白,请大家帮忙了!有100分.
- 没有月饼,只有分,请给点提示:我有几千个歌名,要发送到工作站,用户在工作站点播,我怎么处理?
- Delphi中类的属性可否是自定义类型?(续)
- 文件拖拽到ListBox的问题
- 在form页面中能否画出像html中的表格?
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, math;type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Image3: TImage;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Image4: TImage;
Button1: TButton;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
procedure bmp_rotate(src, dst: tbitmap; angle: extended);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}{ TForm1 }procedure TForm1.bmp_rotate(src, dst: tbitmap; angle: extended);
var
c1x, c1y, c2x, c2y: integer;
p1x, p1y, p2x, p2y: integer;
radius, n: integer;
alpha: extended;
c0, c1, c2, c3: tcolor;
begin
//将角度转换为PI值
angle := (angle / 180) * pi;
// 计算中心点,你可以修改它
c1x := src.width div 2;
c1y := src.height div 2;
c2x := dst.width div 2;
c2y := dst.height div 2; // 步骤数值number
if c2x < c2y then
n := c2y
else
n := c2x;
dec(n, 1); // 开始旋转
for p2x := 0 to n do begin
for p2y := 0 to n do begin
if p2x = 0 then
alpha := pi / 2
else
alpha := arctan2(p2y, p2x);
radius := round(sqrt((p2x * p2x) + (p2y * p2y)));
p1x := round(radius * cos(angle + alpha));
p1y := round(radius * sin(angle + alpha)); c0 := src.canvas.pixels[c1x + p1x, c1y + p1y];
c1 := src.canvas.pixels[c1x - p1x, c1y - p1y];
c2 := src.canvas.pixels[c1x + p1y, c1y - p1x];
c3 := src.canvas.pixels[c1x - p1y, c1y + p1x]; dst.canvas.pixels[c2x + p2x, c2y + p2y] := c0;
dst.canvas.pixels[c2x - p2x, c2y - p2y] := c1;
dst.canvas.pixels[c2x + p2y, c2y - p2x] := c2;
dst.canvas.pixels[c2x - p2y, c2y + p2x] := c3;
end;
application.processmessages
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i, j: integer;
begin
//确定旋转后位图的大小
image2.Picture.Bitmap.Height := image1.picture.width;
image2.Picture.Bitmap.Width := image1.picture.height;
for i := 0 to image1.Height do
for j := 0 to image1.Width do
image2.canvas.Pixels[(-i + image1.Height),
j] := image1.canvas.Pixels[j, i];
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i, j: integer;
begin
//确定旋转后位图的大小
image3.Picture.Bitmap.Height := image1.picture.Height;
image3.Picture.Bitmap.Width := image1.picture.Width;
for i := 0 to image1.Height do
for j := 0 to image1.Width do
image3.canvas.Pixels[(image1.Width
- j), (image1.Height - i)] := image1.canvas.Pixels[j, i];
end;
procedure TForm1.Button4Click(Sender: TObject);
var
i, j: integer;
begin
//确定旋转后位图的大小
image4.Picture.Bitmap.Height := image1.picture.Width;
image4.Picture.Bitmap.Width := image1.picture.Height;
for i := 0 to image1.Height do
for j := 0 to image1.Width do
image4.canvas.Pixels[i, (image1.Width-j)] := image1.canvas.Pixels[j, i];
end;end.
http://search.csdn.net/Expert/topic/1220/1220577.xml?temp=.4492609
http://search.csdn.net/Expert/topic/1030/1030970.xml
var
tmpbmp: TBitmap;
i, j, x, y, px, py: Integer;
cAngle, sAngle: extended;
p1, p2: Pchar;
begin
while angle < 0 do
angle := angle + 360;
angle := angle mod 360;
sAngle := sin(- angle * pi / 180);
cAngle := cos(- angle * pi / 180);
tmpbmp := tbitmap.create;
tmpbmp.assign(bmp);
for i := 0 to tmpbmp.height - 1 do
begin
p1 := pchar(tmpbmp.scanline[i]);
py := 2 * (i - center.y) - 1;
for j := 0 to tmpbmp.width - 1 do
begin
px := 2 * (j - center.x) - 1;
x := (round(px * cAngle - py * sAngle) - 1) div 2 + center.x;
y := (round(px * sAngle + py * cAngle) - 1) div 2 + center.y;
if (x>=0) and (x<tmpbmp.width) and (y>=0) and (y<=tmpbmp.height) then
begin
p2 := pchar(bmp.scanline[y]) + x * 3;
move(p1^, p2^, 3);
end;
inc(p1, 3);
end;
end;
//Assign(bmp); //出错
end;
var
c1x, c1y, c2x, c2y: integer;
p1x, p1y, p2x, p2y: integer;
radius, n: integer;
alpha: extended;
c0, c1, c2, c3: tcolor;
begin
//将角度转换为PI值
angle := (angle / 180) * pi;
// 计算中心点,你可以修改它
c1x := src.width div 2;
c1y := src.height div 2;
c2x := dst.width div 2;
c2y := dst.height div 2; // 步骤数值number
if c2x < c2y then
n := c2y
else
n := c2x;
dec(n, 1); // 开始旋转
for p2x := 0 to n do begin
for p2y := 0 to n do begin
if p2x = 0 then
alpha := pi / 2
else
alpha := arctan2(p2y, p2x);
radius := round(sqrt((p2x * p2x) + (p2y * p2y)));
p1x := round(radius * cos(angle + alpha));
p1y := round(radius * sin(angle + alpha)); c0 := src.canvas.pixels[c1x + p1x, c1y + p1y];
c1 := src.canvas.pixels[c1x - p1x, c1y - p1y];
c2 := src.canvas.pixels[c1x + p1y, c1y - p1x];
c3 := src.canvas.pixels[c1x - p1y, c1y + p1x]; dst.canvas.pixels[c2x + p2x, c2y + p2y] := c0;
dst.canvas.pixels[c2x - p2x, c2y - p2y] := c1;
dst.canvas.pixels[c2x + p2y, c2y - p2x] := c2;
dst.canvas.pixels[c2x - p2y, c2y + p2x] := c3;
end;
application.processmessages
end;
end;