Click to See Complete Forum and Search --> : Stretch Bitmap
SteveMurphy
June 21st, 2004, 11:26 AM
I have a bitmap that I want to display in a class derived from CWnd. Instead of sizing the window to fit the bitmap (I can do this fine), is it possible to stretch a bitmap to fill a window larger than the bitmap? I noticed that when I simply change m_Width and m_Height bitmap attributes, the bitmap gets positioned in the upper left corner.
Thanks.
Marc G
June 21st, 2004, 11:39 AM
Use stretchblt (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cdc.3a3a.stretchblt.asp)
yiannakop
June 22nd, 2004, 09:45 AM
I don't know how stretchblt works, but you can implement this process by using 2-D interpollation to resize the image.
Doctor Luz
June 22nd, 2004, 10:43 AM
StretchBlt already does some kind of 2D interpolation, and probably good enough for the 99% of applications.
You can select the stretch mode by calling SetStretchBltMode() before StretchBlt().
yiannakop
June 23rd, 2004, 08:01 AM
Originally posted by Doctor Luz
StretchBlt already does some kind of 2D interpolation, and probably good enough for the 99% of applications.
You can select the stretch mode by calling SetStretchBltMode() before StretchBlt().
I did not see anything about interpolation in MSDN for SetStretchBltMode() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_6cth.asp).
Anyway, I found this this (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngdi/html/msdn_interp.asp) that describes how to interpolate a 2-D image.
Marc G
June 23rd, 2004, 09:48 AM
From MSDN SetStretchBltMode():
HALFTONE Maps pixels from the source rectangle into blocks of pixels in the destination rectangle. The average color over the destination block of pixels approximates the color of the source pixels.
That's a kind of 2D interpolation ;)
yiannakop
June 23rd, 2004, 10:10 AM
Ok, I did not notice that. You're right, that process looks similar to 2-D interpolation.
Regards,
Theodore
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.