views:

223

answers:

2

I am using Stretched=True on a TImage with a 256x256 bitmap. This gets scaled down by 1,2,4 or 8. As expected, text on the bitmap gets more horrible the more I depart from '1'. I notice though that Windows 7 explorer renders a scaled down version of the bitmap 'softer' and more pleasing. Is it possible to 'blur' a TBitmap in this way?

+6  A: 

I suppose you mean Stretched = True on a TImage, not on A TBitmap.

Unfortunately TImage has no resamplers built in, when it comes to resizing images in it. My recommendation would be to use Graphics32 as it supports a variety of resamplers (some are better for increasing size others for reducing size)

iamjoosy
Thanks, corrected the text. Good suggestion re Graphics32.
Brian Frost
Graphics32 is available here: http://graphics32.org/
stukelly
+1  A: 

By using the HALFTONE StretchBltMode, you will get smoother results than the normal stretchdraw. This will only work in windows 2000 and later

var 
pt:TPoint;
// 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(imgMainPicture.Canvas.Handle, pt);
SetStretchBltMode(imgMainPicture.Canvas.Handle, HALFTONE);
SetBrushOrgEx(imgMainPicture.Canvas.Handle, pt.x, pt.y, @pt);
StretchBlt(imgMainPicture.Canvas.Handle,0, 0, imgMainPicture.Width - 1,
  imgMainPicture.Height - 1,curPicture.AnnotatedBitmap.Canvas.Handle,
  0,0,curPicture.Width,curPicture.Height,SRCCOPY);
Jan Oosting
Great suggestion, thanks.
Brian Frost