网络搜集的 觉得有用的拿去吧  速度不错呢

//旋转90°
procedure Rotate(Bitmap: TBitmap);
type
THelpRGB = packed record
rgb: TRGBTriple;
dummy: byte;
end; pRGBArray = ^TRGBArray;
TRGBArray = array[0..32767] of TRGBTriple;
var
aStream: TMemorystream;
//内存流
header: TBITMAPINFO;
dc: hDC;
P: ^THelpRGB;
x, y, b, h: Integer;
RowOut: pRGBArray;
begin
//创建内存流
aStream := TMemoryStream.Create;
//设置大小,必须是4的倍数
aStream.SetSize(Bitmap.Height * Bitmap.Width * 4);
with header.bmiHeader do //操作位图文件
begin
biSize := SizeOf(TBITMAPINFOHEADER); //大小
biWidth := Bitmap.Width; //位图宽
biHeight := Bitmap.Height; //位图高
biPlanes := 1;
biBitCount := 32;
//无压缩
biCompression := 0;
biSizeimage := aStream.Size;
biXPelsPerMeter := 1; //水平分辨率
biYPelsPerMeter := 1; //竖直分辨率
biClrUsed := 0;
biClrImportant := 0;
end;
dc := GetDC(0);
P := aStream.Memory;
GetDIBits(dc, Bitmap.Handle, 0, Bitmap.Height, P, header, dib_RGB_Colors);
ReleaseDC(0, dc);
b := bitmap.Height; //源图高
h := bitmap.Width; //源图宽
//指定要创建的位图的大小尺寸
bitmap.Width := b;
bitmap.height := h;
for y := 0 to (h - 1) do
begin
rowOut := Bitmap.ScanLine[y]; //获取新的位图信息
P := aStream.Memory; //设置文件指针
inc(p, y); //指针移位
for x := 0 to (b - 1) do
begin
rowout[x] := p^.rgb; //进行数据转移
inc(p, h);
end;
end;
aStream.Free; //释放资源
end;

后面这个不好找

//反向旋转90°
procedure Rotate2(aBitmap: TBitmap);
var
nIdx, nOfs,
x, y, i, nMultiplier: integer;
nMemWidth, nMemHeight, nMemSize, nScanLineSize: LongInt;
aScnLnBuffer: PChar;
aScanLine: PByteArray;
begin
nMultiplier := 3;
nMemWidth := aBitmap.Height;
nMemHeight := aBitmap.Width;
//实际需要内存大小
nMemSize := nMemWidth * nMemHeight * nMultiplier;
//开辟内存
GetMem(aScnLnBuffer, nMemSize);
try
//Scanline的长度
nScanLineSize := aBitmap.Width * nMultiplier;
//为ScanLine分配内存
GetMem(aScanLine, nScanLineSize);
try
for y := 0 to aBitmap.Height - 1 do
begin
//进行数据块的移动
Move(aBitmap.ScanLine[y]^, aScanLine^, nScanLineSize);
for x := 0 to aBitmap.Width - 1 do
begin
nIdx := ((aBitmap.Width - 1) - x) * nMultiplier;
nOfs := (x * nMemWidth * nMultiplier) + (y * nMultiplier);
for i := 0 to nMultiplier - 1 do
Byte(aScnLnBuffer[nOfs + i]) := aScanLine[nIdx + i];
end;
end;
//宽和高交换开始,逆时针旋转
aBitmap.Height := nMemHeight;
aBitmap.Width := nMemWidth;
for y := 0 to nMemHeight - 1 do
begin
//数据移动
nOfs := y * nMemWidth * nMultiplier;
Move((@(aScnLnBuffer[nOfs]))^, aBitmap.ScanLine[y]^, nMemWidth *
nMultiplier);
end;
finally
//释放内存aScanLine
FreeMem(aScanLine, nScanLineSize);
end;
finally
//释放内存aScnLnBuffer
FreeMem(aScnLnBuffer, nMemSize);
end;
end;

  

  

delphi 图像旋转的更多相关文章

  1. NOI题库 09:图像旋转翻转变换

    NOI题库开始的题,也是略水,当然也是大水,所以彼此彼此 09:图像旋转翻转变换 总时间限制: 1000ms 内存限制: 65536kB 描述 给定m行n列的图像各像素点灰度值,对其依次进行一系列操作 ...

  2. 【OpenCV学习笔记】之六 手写图像旋转函数---万丈高楼平地起

    话说,平凡之处显真格,这一点也没错!  比如,对旋转图像进行双线性插值,很简单吧?  可,对我,折腾了大半天,也没有达到预期效果!  尤其是三个误区让我抓瞎好久: 1,坐标旋转公式.   这东西,要用 ...

  3. opencv 图像仿射变换 计算仿射变换后对应特征点的新坐标 图像旋转、缩放、平移

    常常需要最图像进行仿射变换,仿射变换后,我们可能需要将原来图像中的特征点坐标进行重新计算,获得原来图像中例如眼睛瞳孔坐标的新的位置,用于在新得到图像中继续利用瞳孔位置坐标. 仿射变换在:http:// ...

  4. Opencv2.4.4作图像旋转和缩放

    关于下面两个主要函数的讲解: cv::getRotationMatrix2D(center, angle, scale); cv::warpAffine(image, rotateImg, rotat ...

  5. 每日算法37:Rotate Image (图像旋转)

    You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...

  6. [google面试CTCI] 1-6.图像旋转问题

    [字符串与数组] Q:Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, wr ...

  7. pyhton:图像旋转

    最近一个作业中要用到图像旋转,分享一下学习过程.如有讲错的地方,恳请指正! 图像旋转,想想真简单啊,不就是将图像矩阵乘上一个旋转平移矩阵就完了吗?实际上还真没这么简单.首先这个旋转平移矩阵怎么获得?通 ...

  8. CCF CSP 201503-1 图像旋转 (降维)

    题目链接:http://118.190.20.162/view.page?gpid=T27 问题描述 试题编号: 201503-1 试题名称: 图像旋转 时间限制: 5.0s 内存限制: 256.0M ...

  9. 图像旋转、伸缩的自写matlab实现

    一.图像的旋转 今天的代码不是自己写的,缺少一些时间.但是认认真真推导了一下旋转的公式,代码的思想与原博博主一致,致敬! 愚以为,自己来实现图像旋转算法的关键点有二:其一,确定旋转后的图像边界.其二, ...

随机推荐

  1. 爬虫, 获取登录者的外网IP

    笔者学习了一下用爬虫, 获取登录者的外网IP. 首先导入Jsoup的jar包 public class RetrivePage { private static String url="ht ...

  2. 推荐Python Web开发测试驱动方法

    http://www.cnblogs.com/dkblog/archive/2013/06/14/3135914.html推荐 本人买的时候,京东打8.5折,现在降价啦,本书涵盖啦Django.Sel ...

  3. *HDU1150 二分图

    Machine Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. HDU1426 DFS

    Sudoku Killer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  5. Learn ZYNQ(10) – zybo cluster word count

    1.配置环境说明 spark:5台zybo板,192.168.1.1master,其它4台为slave hadoop:192.168.1.1(外接SanDisk ) 2.单节点hadoop测试: 如果 ...

  6. apache 虚拟目录

    补充:必须使用80端口才能正常使用  C:\Windows\System32\drivers\etc\hosts 最后添加上: 127.0.0.1 shenyi.com 127.0.0.1 offli ...

  7. NV SDK 10 (1) Clipmaps

    Clipmaps sample: Abstract Clipmaps are a feature first implemented on SGI workstations that allow ma ...

  8. IntelliJ IDEA使用小技巧

    1:设置类,接口,枚举注解模板 #if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NA ...

  9. 读书笔记:const和readonly、static readonly 那些事

    C#中表示不变的量(常量)的两种形式:const 和readonly const 是静态常量 readonly 是动态常量 严格的来讲:const 应该称为常量 而readonly 则应称为只读变量. ...

  10. 阿里云服务器Linux CentOS安装配置(五)jetty配置、部署

    阿里云服务器Linux CentOS安装配置(五)jetty配置.部署 1.官网下载jetty:wget http://repo1.maven.org/maven2/org/eclipse/jetty ...