修改一下DELPHI ,cxImage控件显示图片异常时候的情况
2019独角兽企业重金招聘Python工程师标准>>>
客户提出客户端预览图片的时候经常报错,影响操作。经检查是图片异常导致cxImage控件不停的显示异常导致的。
我个人为了省事,直接修改 DevExpress\Library\ExpressEditors5\cxImage.pas 文件
定位到1462行这个函数:procedure TcxImageViewInfo.InternalPaint(ACanvas: TcxCanvas);
增加try except end,省事。。。
trywith ACanvas dobeginif not Assigned(Picture) or IsPictureEmpty(Picture) thenbegininherited InternalPaint(ACanvas);Brush.Color := BackgroundColor;if Caption <> '' thenbeginBrush.Style := bsClear;Canvas.Font.Assign(Self.Font);Canvas.Font.Color := Self.TextColor;ACanvas.DrawText(Caption, CR, cxAlignCenter + cxSingleLine);Brush.Style := bsSolid;end;if ShowFocusRect then FocusRect(Canvas, CR);Exit;end;with CR dobeginif Stretch thenbeginCalcStretchRect(CR, Picture.Width, Picture.Height, R);if Center thenbeginOffsetRect(R, (Right - Left - (R.Right - R.Left)) div 2, 0);OffsetRect(R, 0, (Bottom - Top - (R.Bottom - R.Top)) div 2);end;endelsebeginR := Rect(Left, Top, Left + Picture.Width, Top + Picture.Height);if Center thenbeginOffsetRect(R, (Right - Left - Picture.Width) div 2, 0);OffsetRect(R, 0, (Bottom - Top - Picture.Height) div 2);endelseOffsetRect(R, -Self.TopLeft.X, -Self.TopLeft.Y);end;end;SaveRgn := GetClipRegion; // for native modeExcludeClipRect(CR);DrawCustomEdit(ACanvas, Self, False, bpsSolid);SetClipRegion(SaveRgn, roSet);if ShowFocusRect thenbeginFocusRect(Canvas, CR);InflateRect(CR, -1, -1);end;SaveRgn := GetClipRegion;IntersectClipRect(CR);if ShowFocusRect then InflateRect(CR, 1, 1);if not Self.Transparent and Picture.Graphic.Transparent thenbeginif FTempBitmap = nil thenbeginFTempBitmap := TBitmap.Create;FTempBitmap.PixelFormat := pfDevice;end;tryFTempBitmap.Width := R.Right - R.Left;FTempBitmap.Height := R.Bottom - R.Top;FTempBitmap.Canvas.Brush.Color := BackgroundColor;FTempBitmap.Canvas.FillRect(Rect(0, 0, FTempBitmap.Width, FTempBitmap.Height));FTempBitmap.Canvas.StretchDraw(Rect(0, 0, FTempBitmap.Width, FTempBitmap.Height), Picture.Graphic);Canvas.Draw(R.Left, R.Top, FTempBitmap);excepton EOutOfResources dobeginCanvas.Brush.Color := BackgroundColor;Canvas.FillRect(ClientRect);Canvas.StretchDraw(R, Picture.Graphic);end;end;endelseCanvas.StretchDraw(R, Picture.Graphic);NeedDrawBkg := not (IntersectRect(Temp, R, CR) and EqualRect(Temp, CR)) and not Self.Transparent;if NeedDrawBkg thenbeginExcludeClipRect(R);Brush.Color := BackgroundColor;FillRect(CR);end;SetClipRegion(SaveRgn, roSet);end;exceptACanvas.Brush.Color := clWhite;ACanvas.Canvas.FillRect(ClientRect);ACanvas.DrawTexT('无法查看此图片,因为此文件可能已损坏、损毁或者过大', ClientRect, DT_VCENTER or DT_CENTER);end;
try
....................
except
ACanvas.Brush.Color := clWhite;
ACanvas.Canvas.FillRect(ClientRect);
ACanvas.DrawTexT('无法查看此图片,因为此文件可能已损坏、损毁或者过大', ClientRect, DT_VCENTER or DT_CENTER);
end;
此处是我新增部分,其余是原有的,你们还有什么好的处理方式吗?
转载于:https://my.oschina.net/huanghongqiao/blog/727699
修改一下DELPHI ,cxImage控件显示图片异常时候的情况相关推荐
- MFC 对话框中的picture control 控件显示图片
MFC读取图片一般使用自定义的DIB文件.DIB文件集中了处理图片的API函数,这样可以方便我们的图像操作. DIB文件下载路径:DIB文件下载 MFC显示图片有几种方法: 1.在运行界面上选择 文件 ...
- C#利用Picturebox控件显示图片
源文章:https://blog.csdn.net/liyuqian199695/article/details/54098938 C#利用Picturebox控件显示图片 1.Picturebox控 ...
- 实现picturecontrol控件显示图片_陕西曝光机触摸屏实时数据控件
随着市场需求的快速发展,PCB行业对产能的要求与日俱增.为了在保证品质的前提下快速提高产能,PCB曝光领域掀起了一场新的革命,那就是对传统曝光机进行UVLED改造,用UVLED光源代替传统汞灯.目前市 ...
- image控件显示图片_Unity之Image amp; Raw Image
推荐阅读: 我的CSDN 我的博客园 QQ群:704621321 我的个人博客 前言 在Unity中,图片组件主要有Image和Raw Image,今天,偶然发现了项目中别人有用到Raw Image, ...
- PyCharm pyqt5用label控件显示图片 QPixmap 串口通信指示灯
import sys from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtGui import QPixmap imp ...
- 使用CvvImage类在MFC的static控件显示图片
使用OpenCV的库,可以非常便捷地实现对图像的各种操作.在CTestDlg对话框中放置一个picture static控件,ID为IDC_STATIC,如下函数即可实现显示图片的功能.根据此方法,可 ...
- QT 通过label控件显示图片,图片能自适应label的大小
将通过URL下载的图片显示出来: 效果如下: //显示图片QPixmap pix;QImage image(fileName);//filename,图片的路径名字ui->pix->set ...
- Qt——P26 Label控件显示图片
先把图片资源添加到Qt ui界面创建label //利用lable 显示图片ui->label_image->setPixmap(QPixmap(":/picture/abc.p ...
- 演练GridView控件显示目录图片
本博文,将带你学习使用GridView控件显示站点目录的图片.如果你已经学会怎样做图片缩略图:怎样应用接口来实现统一的属性,方法或函数:怎样动态加载用户控件,等等.就不必往下看了.因为此篇博文就是演练 ...
最新文章
- 自定义全局按键修饰符
- python 静态变量 静态方法 简介
- java bean join_spring data jpa 关联join查询出自定义实体java bean的坑
- rsync同步(2010年写作)
- 北大poj1018题解题报告
- C#-datagriview的表头高度的设置
- Matlab高光谱样本相关性分析
- Constructor vs Object
- 二叉树的概念和基本术语
- 关于单细胞批次矫正那些事(一)
- java常见面试微服务_微服务面试一般问什么?java微服务面试题以及答案整理
- raw socket的例子
- 二维码自动生成器批量将表格整行数据制作二维码
- .net framework 官方下载地址
- c++ opencv 彩色图rgb 转换hsv 再通道分离
- 2026年物联网将为运营商带来高收入
- 基于Halcon学习的一维码识别【十三】ean13.hdev
- 图书管理系统之带验证码登录界面
- 罗升阳对安卓2.3系统的总结
- UON:《Detecting Unexpected Obstacles for Self-Driving Cars...》论文阅读与总结
热门文章
- enote笔记法之附录1——“语法词”(即“关联词”)(ver0.23)
- R编程Error处理手册
- 视频编解码 — 卡顿与花屏
- 常用Linux命令的基本使用(五)
- Nessus8.0.1使用教程
- java中什么是接口
- python海龟库如何导入_Python 中的海龟绘图turtle函数库的详细使用方法
- Nebulogy携手福耀集团,助力制造业智能化转型
- php 0x80070003,HOWTO: 解决 Windows DISM error ID3 0x80070003 故障
- MySQL SQL 优化参数 引发的悲剧