delphi 处理缩放图像
procedure TTMEImageDeviceIdentifyFrom.DrawText(AImage : TImage; AFile: string);
var
I: Integer;
iWidth, iHeight: Integer;
oInfo: TTextInfoAry;
oRect, Rect: TRect;
bmp, dbmp: TBitmap;
iX, iY: Integer;
zoom: double;
NewW,NewH:Integer;
begin
bmp := TBitmap.Create;
dbmp := TBitmap.Create;
try
bmp.LoadFromFile(AFile);
if (bmp.Width > AImage.Width) or (bmp.Height > AImage.Height) then
begin
if bmp.Width > AImage.Width then
zoom := AImage.Width/bmp.Width
else
zoom := AImage.Height / bmp.Height;
NewH:=Round(bmp.Height * zoom);
NewW:=Round(bmp.Width * zoom);
with dbmp do
begin
Width:=NewW ;
Height:=NewH ;
dbmp.PixelFormat:=pfDevice;
SetStretchBltMode(dbmp.Canvas.Handle,COLORONCOLOR);//设置指位图拉伸模式
stretchblt(dbmp.Canvas.Handle,0,0,dbmp.Width,dbmp.Height,bmp.Canvas.Handle,0,0,bmp.Width,bmp.Height,srccopy); //从源矩形中复制一个位图到目标矩形并适当压缩
// Rect.TopLeft:=Point(0,0);
// Rect.BottomRight:=Point(NewW,NewH);
// Canvas.Rectangle(0,0,Width,Height);
// Canvas.StretchDraw(Rect,TGraphic(bmp));
end;
oRect.Left := Round((AImage.ClientRect.Width - dbmp.Width)/2);
oRect.Top := Round((AImage.ClientRect.Height - dbmp.Height)/2);
oRect.Width := dbmp.Width;
oRect.Height:= dbmp.Height;
AImage.Canvas.StretchDraw(oRect, dbmp);
end
else
begin
oRect.Left := Round((AImage.ClientRect.Width - bmp.Width)/2);
oRect.Top := Round((AImage.ClientRect.Height - bmp.Height)/2);
oRect.Width := bmp.Width;
oRect.Height:= bmp.Height;
AImage.Canvas.StretchDraw(oRect, bmp);
end;
iX := 6;
iY := 0;
AImage.Canvas.Font.Size := 14;
AImage.Canvas.Pen.Style := psClear;
AImage.Canvas.Brush.Style := bsClear;
ParseVectorDrawingText(FSelText, oInfo);
for I := Low(oInfo) to High(oInfo) do
begin
iWidth := AImage.Canvas.TextWidth(oInfo[I].Text);
iHeight := Round(AImage.Canvas.TextHeight(oInfo[I].Text));
oRect.Width := oRect.Width + iWidth;
oRect.Height := oRect.Height + iHeight;
if oRect.Left > iWidth then
oRect.Left := oRect.Left - iWidth;
iY := I * iHeight;
oInfo[I].InstPt.X := iX;
oInfo[I].InstPt.Y := iY ;
end;
for I := Low(oInfo) to High(oInfo) do
AImage.Canvas.TextOut(Round(oInfo[I].InstPt.X), Round(oInfo[I].InstPt.Y), oInfo[I].Text);
finally
bmp.Free;
dbmp.Free;
end;
end;
delphi 处理缩放图像的更多相关文章
- Open CV缩放图像
缩放图像是图像处理中需要经常使用的操作.太小的图像在图像识别中不能很好的处理,需要将其放大,太大的图像不方便储存,需要将其缩小,下面记录OpenCV图片缩放方法. 缩放函数 , , int inter ...
- 本图片处理类功能非常之强大可以实现几乎所有WEB开发中对图像的处理功能都集成了,包括有缩放图像、切割图像、图像类型转换、彩色转黑白、文字水印、图片水印等功能
import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Graphic ...
- 解决Delphi窗体缩放の疑难杂症
http://anony3721.blog.163.com/blog/static/511974201082235754423/ 解决Delphi窗体缩放の疑难杂症 2010-09-22 15:57: ...
- OpenCV2:图像的几何变换,平移、镜像、缩放、旋转(2)
在OpenCV2:图像的几何变换,平移.镜像.缩放.旋转(1)主要介绍了图像变换中的向前映射.向后映射.处理变换过程中浮点坐标像素值的插值算法,并且基于OpenCV2实现了两个简单的几何变换:平移和镜 ...
- OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放
这篇已经写得很好,真心给作者点个赞.题目都是直接转过来的,直接去看吧. Reference Link : http://blog.csdn.net/poem_qianmo/article/detail ...
- 【OpenCV新手教程之十三】OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放
本系列文章由@浅墨_毛星云 出品,转载请注明出处. 文章链接:http://blog.csdn.net/poem_qianmo/article/details/26157633 作者:毛星云(浅墨) ...
- openCV(三)---图像缩放
UIImage *img1 = [UIImage imageNamed:@"1448941176867"]; //将UIImage转换为IplImage格式 IplImage *p ...
- Delphi制作图像特殊显示效果
Delphi制作实现图像的各种显示效果,比如百叶窗.渐变.淡入淡出.水平交错.雨滴效果等,用鼠标点击“打开图像”按钮,可以选择图像文件导入到窗体中:点击其它各个按钮,可以实现图像显示特效,例如:点击“ ...
- c#目录以及子目录下图片批量缩放,像素不变,图像大小改变
采用多线程,整体效果 图像根目录黏贴或者手工选择,点击开始,进行目录底下图片筛查.采用多线程,点击开始按钮,开启线程,这样UI不会卡住 private void button2_Click(objec ...
随机推荐
- Hacking Using Beef-Xss
1.环境 hacker:192.168.133.128 os:Kali victims:192.168.133.1 os:win8 2.前期配置 首先进入beef-xss主目录,编辑配置文件,将 ...
- HDU 6395 Sequence 杜教板子题
题目意思非常明确,就是叫你求第n项,据我们学校一个大佬说他推出了矩阵,但是我是菜鸡,那么肯定是用简单的方法水过啦!我们先p^(1/2)的复杂度处理出i=[i,p]范围内的所有种类的(int)(p/i) ...
- Workflow规则收藏
豆瓣电影 查看电影评分等详细信息 查看图片EXIF 图铃机器人 快递查询 翻译 手机号码归属地 音乐视频下载 获取附近的免费WIFI
- casperjs批量执行多个url
var fs=require("fs"); ////-------sample.js-------// //casperオブジェクトを生成var casper = require( ...
- Windows安装pycrypto失败记录
Windows 10家庭中文版,Python 3.6.4, 180824测试前端加密文本在后台揭秘,查询后发现,可以使用pycrypto模块实现,那么,安装它(pip),结果安装失败了. 本文暂时记录 ...
- javascript设计模式----桥接模式、组合模式、装饰者模式、享元模式
http://blog.csdn.net/painsonline/article/details/7215087 桥接模式:http://www.cnblogs.com/TomXu/archiv ...
- Reactor模型-单线程版
Reactor模型是典型的事件驱动模型.在网络编程中,所谓的事件当然就是read.write.bind.connect.close等这些动作了.Reactor模型的实现有很多种,下面介绍最基本的三种: ...
- java 重新抛出异常
一.有时希望把刚捕获的异常重新抛出,尤其时在使用Exception捕获所以异常的时候,既然已经得到了对当前异常对象的引用,可以重新把它抛出: catch(Exception e){ System.ou ...
- [转] Web移动端Fixed布局的解决方案
移动端业务开发,iOS 下经常会有 fixed 元素和输入框(input 元素)同时存在的情况. 但是 fixed 元素在有软键盘唤起的情况下,会出现许多莫名其妙的问题. 这篇文章里就提供一个简单的有 ...
- 【PAT】1091 Acute Stroke(30 分)
1091 Acute Stroke(30 分) One important factor to identify acute stroke (急性脑卒中) is the volume of the s ...