pf1bit的bmp黑白图像逆时针旋转该怎么实现呢?这样的bmp图1个字节8个像素,一般的scanline好像都只针对字节操作的,我只好按像素赋值,但速度太慢,有什么快速的办法吗?
解决方案 »
- 如何给DBGrid添加一个单选框列
- 一个难题急盼您的解决,请您帮忙
- 一个小问题,为什么ADoQuery在BatchUpdate方式时,对于插入的多个空行后,再取消时老时会报错无法定位已删除的行?
- 如何得到DBGrid选中行的各个字段的值?谢谢
- 在輸入日期型字段時,要出現像DateTimePicker控件那樣進行選擇,怎麼做?
- 日期类型转换的低级问题?
- 能給點動態聯接數據庫的思路嗎?
- 急急急,怎样在delphi的activeform中关闭当前打开的IE窗口?
- 初学DELPHI的问题,非常急!!!!!!!!!!!
- 公司面试题! 与大家分享!有点意思!
- 是什么问题
- 一个有关用Adoquery控件向combobox中添加项目的问题??
var
c1x, c1y, c2x, c2y: integer;
p1x, p1y, p2x, p2y: integer;
radius, n: integer;
alpha: extended;
c0, c1, c2, c3: tcolor;
begin
if SrcBmp.Width > SrcBmp.Height then
begin
DestBmp.width := SrcBmp.Width;
DestBmp.height := SrcBmp.Width;
end
else
DestBmp.Width := SrcBmp.Height;
DestBmp.Height := SrcBmp.Height;
//将角度转换为PI值
angle := (angle / 180) * pi;
// 计算中心点,你可以修改它
c1x := SrcBmp.width div 2;
c1y := SrcBmp.height div 2;
c2x := DestBmp.width div 2;
c2y := DestBmp.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 := SrcBmp.canvas.pixels[c1x + p1x, c1y + p1y];
c1 := SrcBmp.canvas.pixels[c1x - p1x, c1y - p1y];
c2 := SrcBmp.canvas.pixels[c1x + p1y, c1y - p1x];
c3 := SrcBmp.canvas.pixels[c1x - p1y, c1y + p1x]; DestBmp.Canvas.pixels[c2x + p2x, c2y + p2y] := c0;
DestBmp.canvas.pixels[c2x - p2x, c2y - p2y] := c1;
DestBmp.canvas.pixels[c2x + p2y, c2y - p2x] := c2;
DestBmp.canvas.pixels[c2x - p2y, c2y + p2x] := c3;
end;
application.processmessages
end;
end;procedure TForm1.RotateangleClick(Sender: TObject);
var
newbmp: TBitmap;
Bitmap: TBitmap;
angle: integer;
begin
newbmp := TBitmap.Create;
Bitmap := TBitmap.Create;
screen.Cursor := crhourglass;
newbmp.Assign(image1.Picture.Bitmap);
//newbmp.pixelFormat:=pf8bit;
//Bitmap.pixelFormat:=pf8bit;
angle := strtoint(inputbox('旋转位图', '请输入旋转角度', '90'));
Bmp_Rotate(newbmp, bitmap, angle);
image1.picture.Bitmap.Assign(bitmap);
image1.Left := (self.Width div 2) - (bitmap.Width div 2);
image1.Top := (self.Height div 2) - (bitmap.Height div 2);
screen.Cursor := crdefault;
newbmp.Free;
Bitmap.Free;
end;