![](/img/trans.png)
[英]Is it possible to use Portable Bitmap Image in TBitmap Component in Delphi?
[英]Is it possible to smooth a scaled TBitmap in Delphi?
我在具有256x256位图的TImage上使用Stretched = True。 这会按比例缩小1,2,4或8.正如预期的那样,位图上的文字越是可怕,越离“1”。 我注意到,虽然Windows 7资源管理器呈现缩小版本的位图“更柔和”,更令人愉悦。 是否有可能以这种方式“模糊”TBitmap?
通过使用HALFTONE 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;
我想你的意思是在TImage上的Stretched = True,而不是在TBitmap上。
不幸的是,在调整图像大小时,TImage没有内置的重新采样器。 我的建议是使用Graphics32,因为它支持各种重采样器(有些更适合增加其他尺寸以减小尺寸)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.