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 处理缩放图像的更多相关文章

  1. Open CV缩放图像

    缩放图像是图像处理中需要经常使用的操作.太小的图像在图像识别中不能很好的处理,需要将其放大,太大的图像不方便储存,需要将其缩小,下面记录OpenCV图片缩放方法. 缩放函数 , , int inter ...

  2. 本图片处理类功能非常之强大可以实现几乎所有WEB开发中对图像的处理功能都集成了,包括有缩放图像、切割图像、图像类型转换、彩色转黑白、文字水印、图片水印等功能

    import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Graphic ...

  3. 解决Delphi窗体缩放の疑难杂症

    http://anony3721.blog.163.com/blog/static/511974201082235754423/ 解决Delphi窗体缩放の疑难杂症 2010-09-22 15:57: ...

  4. OpenCV2:图像的几何变换,平移、镜像、缩放、旋转(2)

    在OpenCV2:图像的几何变换,平移.镜像.缩放.旋转(1)主要介绍了图像变换中的向前映射.向后映射.处理变换过程中浮点坐标像素值的插值算法,并且基于OpenCV2实现了两个简单的几何变换:平移和镜 ...

  5. OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放

    这篇已经写得很好,真心给作者点个赞.题目都是直接转过来的,直接去看吧. Reference Link : http://blog.csdn.net/poem_qianmo/article/detail ...

  6. 【OpenCV新手教程之十三】OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放

    本系列文章由@浅墨_毛星云 出品,转载请注明出处. 文章链接:http://blog.csdn.net/poem_qianmo/article/details/26157633 作者:毛星云(浅墨) ...

  7. openCV(三)---图像缩放

    UIImage *img1 = [UIImage imageNamed:@"1448941176867"]; //将UIImage转换为IplImage格式 IplImage *p ...

  8. Delphi制作图像特殊显示效果

    Delphi制作实现图像的各种显示效果,比如百叶窗.渐变.淡入淡出.水平交错.雨滴效果等,用鼠标点击“打开图像”按钮,可以选择图像文件导入到窗体中:点击其它各个按钮,可以实现图像显示特效,例如:点击“ ...

  9. c#目录以及子目录下图片批量缩放,像素不变,图像大小改变

    采用多线程,整体效果 图像根目录黏贴或者手工选择,点击开始,进行目录底下图片筛查.采用多线程,点击开始按钮,开启线程,这样UI不会卡住 private void button2_Click(objec ...

随机推荐

  1. Xgboost理解

    一.xgboost模型函数形式 xgboost也是GBDT的一种,只不过GBDT在函数空间进行搜索最优F的时候,采用的是梯度下降法也就是一阶泰勒展开:而xgboost采用的是二阶泰勒展开也就是牛顿法, ...

  2. Interval Sum I && II

    Given an integer array (index from 0 to n-1, where n is the size of this array), and an query list. ...

  3. CentOS安装SVN客户端(rpm)

    http://mirrors.163.com/centos/6/os/x86_64/Packages/ 1.检查是已经安装了svn: rpm -qa subversion subversion-1.7 ...

  4. HTML播放FLASH(SWF)神器-SWFObject

    环境 必须有 swfobject.js和 expressInstall.swf js:  http://pan.baidu.com/share/link?shareid=2536087943& ...

  5. nginx 日志切割(也适用于docker)

    =============================================== 2019/4/6_第2次修改                       ccb_warlock 201 ...

  6. 无效GRANT语句导致主从同步断开

    最近遇到一个主从同步断开的案例,是由于在执行GRANT语句时,授权对象给错了,也就可以理解为无效的GRANT语句,我们收到slave库同步断开的报警信息,然后去找问题,发现binlog有报错,报错提示 ...

  7. java8中ConcurrentHashMap

    HashMap的线程不安全主要体现在resize时的死循环及使用迭代器时的fast-fail上. Fast-fail: fail-fast 机制是java集合(Collection)中的一种错误机制. ...

  8. 如何对手机使用adb

    因为要配合前端做测试,所以我需要在本机中安装adb驱动,以便可以连接手机进行各种操作. 好吧...装adb驱动这块当时我没有把流程给做记录...郁闷,下次再安装的时候再谷歌吧. 使用的简单脚本就是 有 ...

  9. Python 之 Module Not Found Error: No module named 'openpyxl'

    我在学习Python的过程中,计划将取到的数据保存到Excel文件中,使用 df.to_csv('D:/PythonWorkSpace/TestData/test.xlsx') 总是报错 Module ...

  10. Ubuntu系统无法获得锁/var/lib/dpkg/lock - open (11: 资源暂时不可用)的解决方案

    Ubuntu系统无法获得锁/var/lib/dpkg/lock - open (11: 资源暂时不可用)的解决方案     问题 使用Ubuntu打开终端时,输入带有sudo apt-get 命令行是 ...