日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

修改一下DELPHI ,cxImage控件显示图片异常时候的情况

發布時間:2024/1/18 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 修改一下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控件显示图片异常时候的情况的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。