我在帶有256x256位圖的TImage上使用Stretched = True。這會被縮小1,2,4或8倍。正如所料,離開'1'後,位圖上的文字變得更可怕。 我注意到,雖然Windows 7資源管理器呈現了一個縮小版本的位圖「更柔和」,更令人愉快。這樣可以「模糊」TBitmap嗎?是否可以在Delphi中平滑縮放的TBitmap?
回答
我想你的意思是在TImage上Stretched = True,而不是在TBitmap上。
不幸的是TImage沒有內置重新採樣器,當涉及到調整其中的圖像。 我的建議是使用Graphics32,因爲它支持多種重新採樣的(有些是增加大小他人減少尺寸更好)
通過使用半色調StretchBltMode,你會得到比正常stretchdraw平滑的結果。 這將只適用於Windows 2000及更高版本
procedure SmoothResize();
var pt:TPoint;
h: HDC;
begin
h := imgMainPicture.Canvas.Handle;
// Previous call to StretchDraw
// imgMainPicture.Canvas.StretchDraw(Rect(0, 0, imgMainPicture.Width - 1,
// imgMainPicture.Height - 1), curPicture.AnnotatedBitmap);
// Normal StretchDraw uses STRETCH_DELETESCANS as StretchBltMode , HALFTONE should give better results
GetBrushOrgEx(h, pt);
SetStretchBltMode(h, HALFTONE);
SetBrushOrgEx(h, pt.x, pt.y, @pt);
StretchBlt(h, 0, 0, imgMainPicture.Width - 1,
imgMainPicture.Height - 1, curPicture.AnnotatedBitmap.Canvas.Handle,
0, 0, curPicture.Width,curPicture.Height,SRCCOPY);
end;
很好的建議,謝謝。 – 2010-05-10 15:49:38
@BrianFrost HALFTONE或STRETCH_HALFTONE是你最好的選擇,恕我直言,這是一些代碼http://code.google.com/p/delphigeist-delphi-stuff/source/browse/trunk/SynMiniMap/src/SynMiniMap.pas – ComputerSaysNo 2012-09-17 17:24:55
- 1. delphi TBitmap是否支持alpha通道
- 2. 平滑縮放MovieClip
- 3. 縮放後的平滑線
- 4. 是否可以刪除android地圖視圖縮放縮放的平移?
- 5. 是否可以使字體可縮放?
- 6. 我可以禁用Safari的平滑圖像縮放嗎?
- 7. Android平滑捏縮放?
- 8. 圖像縮放和平滑
- 9. 是否可以使用php或js平移/縮放相機?
- 10. OL3中的分數縮放(平滑縮放)
- 11. Android:是否可以縮放xml drawable?
- 12. 是否可以縮放Google Apps腳本?
- 13. 如何在圖像庫中平滑過渡以縮放圖像?
- 14. D3:是否可以縮放+平移一個軸,只平移另一個軸?
- 15. 是否可以在Xcode6中模擬iphone6 +的縮放模式?
- 16. 是否可以在pyqt4中縮放QVBoxLayout的內容?
- 17. 是否可以禁用CSS中的字體平滑?
- 18. 是否可以在德爾福平滑按鈕的角落
- 19. 的Flash CS5,使圖像平滑縮放
- 20. Highcharts失去平滑的縮放效果
- 21. Delphi TBitmap代碼到Python PIL
- 22. 在Delphi的TBitmap組件中可以使用便攜式位圖圖像嗎?
- 23. SpriteKit。是否可以在不縮放childNode的情況下縮放parentNode?
- 24. Xcode故事板不可見;是否可以縮放/平移畫布?
- 25. 是否可以把按鈕放在WPF滑塊的拇指?
- 26. memcache可以水平縮放嗎?
- 27. UIScrollView可以縮放,但不能平移
- 28. SQL Server 2008可以水平縮放嗎?
- 29. Apache Jena可以水平縮放嗎?
- 30. 是否可以在iOS Safari中檢測放大/縮小事件?
謝謝,更正了文字。好的建議重新Graphics32。 – 2010-05-07 13:12:35