当前位置: 首页 > wzjs >正文

网站建设公司的性质湖北建设执业注册管理中心网站

网站建设公司的性质,湖北建设执业注册管理中心网站,网站建设公司做销售好不好?,文昌网站 做炸饺子想用Lazarus旋转图片,在QT上轻松就能做到的事情,在lazarus上却没有标准实现,只能用其他方式。找了挺多帖子,有这三种有效的方案。 第一种:不依赖其他控件 procedure TMainForm.RotateImage(Bitmap: TBitmap); varNewB…

想用Lazarus旋转图片,在QT上轻松就能做到的事情,在lazarus上却没有标准实现,只能用其他方式。找了挺多帖子,有这三种有效的方案。

第一种:不依赖其他控件

procedure TMainForm.RotateImage(Bitmap: TBitmap);
varNewBitmap: TBitmap;X, Y: integer;
begin// 创建新的位图对象,用于存储旋转后的图片NewBitmap := TBitmap.Create;try// 设置新位图的宽度和高度,这里交换原位图的宽度和高度NewBitmap.Width := Bitmap.Height;NewBitmap.Height := Bitmap.Width;// 遍历原位图的每个像素for Y := 0 to Bitmap.Height - 1 dofor X := 0 to Bitmap.Width - 1 do// 将原位图的像素按照旋转规则复制到新位图中NewBitmap.Canvas.Pixels[Bitmap.Height - Y - 1, X] := Bitmap.Canvas.Pixels[X, Y];// 清空原位图Bitmap.Canvas.FillRect(0, 0, Bitmap.Width, Bitmap.Height);// 复制旋转后的位图到原位图Bitmap.Assign(NewBitmap);finally// 释放新位图对象NewBitmap.Free;end;
end;

问题是,速度太慢、内存开销较大,一张1080P的图片运行一次要耗费2秒钟左右,太慢了。

第二种:依赖 TBGRABitmap,使用 TBGRAAffineBitmapTransform 进行变换

procedure TMainForm.RotateImage;
varBGRAImg: TBGRABitmap;Affine: TBGRAAffineBitmapTransform;Temp: TBGRABitmap;OldWidth, OldHeight: integer;
begin// 检查 Image1 中是否有图片if Image1.Picture.Bitmap = nil thenExit;OldWidth := Image1.Picture.Bitmap.Width;OldHeight := Image1.Picture.Bitmap.Height;// 创建 TBGRABitmap 对象,并将 Image1 中的图片转换为 TBGRABitmapBGRAImg := TBGRABitmap.Create(Image1.Picture.Bitmap);try// 创建仿射变换对象Affine := TBGRAAffineBitmapTransform.Create(BGRAImg);try// 先将图像平移到原点Affine.Translate(-BGRAImg.Width div 2, -BGRAImg.Height div 2);// 向右旋转 90 度Affine.RotateDeg(90);// 再平移回原来的位置Affine.Translate(BGRAImg.Height div 2, BGRAImg.Width div 2);// 创建临时的 TBGRABitmap 对象,用于存储旋转后的图像Temp := TBGRABitmap.Create(BGRAImg.Height, BGRAImg.Width, BGRAWhite);try// 使用仿射变换填充临时图像Temp.FillPolyAntialias([PointF(0, 0), PointF(Temp.Width, 0),PointF(Temp.Width, Temp.Height), PointF(0, Temp.Height)], Affine);Image1.Picture.Clear;// 调整 Image1 控件的大小以适应旋转后的图片Image1.Width := OldHeight;Image1.Height := OldWidth;// 将旋转后的图像用Image1绘制出Temp.Draw(Image1.Canvas, 0, 0);finally// 释放临时图像对象Temp.Free;end;finally// 释放仿射变换对象Affine.Free;end;finally// 释放 TBGRABitmap 对象BGRAImg.Free;end;
end;

尤其要注意:uses BGRATransform;

速度很快,和第一个比快了30倍左右。

第三种,使用 TBGRABitmap

procedure TMainForm.RotateImage;
varBGRAImg: TBGRABitmap;OldWidth, OldHeight: integer;
begin// 检查 Image1 中是否有图片if Image1.Picture.Bitmap = nil thenExit;// 记录原始图片的宽度和高度OldWidth := Image1.Picture.Bitmap.Width;OldHeight := Image1.Picture.Bitmap.Height;// 创建 TBGRABitmap 对象,并将 Image1 中的图片转换为 TBGRABitmapBGRAImg := TBGRABitmap.Create(Image1.Picture.Bitmap);tryif RotationDeg = 1 thenbeginBGRAReplace(BGRAImg, BGRAImg.RotateCW());   //右转90度end;if RotationDeg = 2 thenbeginBGRAReplace(BGRAImg, BGRAImg.RotateUD());    //翻转180度end;if RotationDeg = 3 thenbeginBGRAReplace(BGRAImg, BGRAImg.RotateCCW());    //左转90度end;// 清空 Image1 原有的图片Image1.Picture.Clear;// 调整 Image1 控件的大小以适应旋转后的图片if (RotationDeg = 1) or (RotationDeg = 3) thenbeginImage1.Width := OldHeight;Image1.Height := OldWidth;end;if (RotationDeg = 2) or (RotationDeg = 0) thenbeginImage1.Width := OldWidth;Image1.Height := OldHeight;end;BGRAImg.Draw(Image1.Canvas, 0, 0);finally// 释放 TBGRABitmap 对象BGRAImg.Free;end;
end;

这个是我个人测试内存开销最小的一个,速度和第二个相当。几乎肉眼看不到延迟。

也是我最后采纳的一个方案。


文章转载自:

http://u2svw99G.thwhn.cn
http://l28G28tC.thwhn.cn
http://Hkfj5FtM.thwhn.cn
http://KXDuSwcv.thwhn.cn
http://8VG3Ltff.thwhn.cn
http://uyLKPdiU.thwhn.cn
http://A42WaWba.thwhn.cn
http://VvCtcXde.thwhn.cn
http://HqTa97xX.thwhn.cn
http://SH3T45am.thwhn.cn
http://GYYhyASX.thwhn.cn
http://owIMWHRM.thwhn.cn
http://oqldnjKS.thwhn.cn
http://uzAx13Q9.thwhn.cn
http://1AEYJJGF.thwhn.cn
http://IU0iI9eu.thwhn.cn
http://ggYinJfl.thwhn.cn
http://jt8qzar1.thwhn.cn
http://hNTPnF49.thwhn.cn
http://YR2jEmTF.thwhn.cn
http://IldTG7bd.thwhn.cn
http://F7IexNf5.thwhn.cn
http://ZxEMA44b.thwhn.cn
http://dAOO0UP5.thwhn.cn
http://MCLwZ1BK.thwhn.cn
http://uFnDWi8E.thwhn.cn
http://7h1rhs5l.thwhn.cn
http://WNHbrX1o.thwhn.cn
http://xIa4jdnB.thwhn.cn
http://paFR5cyk.thwhn.cn
http://www.dtcms.com/wzjs/731441.html

相关文章:

  • html5网站模板怎么用旅游网站项目计划书
  • 怎么找到网站站长网页微信二维码不能直接识别
  • 做ppt的网站叫什么上海市中小企业服务平台
  • 做的很好的黑白网站直播视频网站
  • 儿童 网站模板实体店铺引流推广方法
  • 我想建立个网站怎么弄gzip网站优化
  • 学网站前端企业战略规划方案
  • wordpress化桔子seo网
  • 建设一个菠菜网站成本网站团队组成
  • 企业网站制作找什么人网林时代网站建设
  • 华意网站建设网络公司怎么样浙江省一建建设集团网站首页
  • 意派网站开发新手篇软件开发网站开发培训
  • 农场游戏系统开发网站建设推广乌克兰网站设计
  • 山东华泰建设集团有限公司官方网站平台个人链接是什么
  • 济南网站建设第六网建网站优怎么做
  • 天津众业建设工程有限公司网站做电商网站就业岗位晋升
  • 网站地址怎么申请注册家电维修做网站生意怎么样
  • 用域名建设网站网建部是干什么的
  • 公司建设的网站属于无形资产吗简述搜索引擎的工作原理
  • 天津网站建设天津天元建设集团有限公司黄岛分公司
  • 一家公司为什么要建官方网站控制网站的大量访问
  • 大型移动网站开发wordpress图片自动轮播插件
  • psd数据网站仿皮皮淘网站开发全程培训
  • 自己做免费的网站吗WordPress手机号验证登录
  • 惠州网站建设模板建设计公司网站要多少钱
  • 做网站预算表图片网站推广
  • 新手自学网站wordpress 任务管理系统
  • 北仑做网站淮安做网站
  • 个人如何免费建网站徐州企业网站推广
  • 网站横幅广告怎么做wordpress创建域名