
The implementation handles the SYSCOLORCHANGE message as described by BOOL SetBitmap(UINT nIDResource) // Loads bitmap from resource IDīOOL SetBitmap(LPCTSTR lpszResourceName) // Loads bitmap from resource nameīOOL SetBitmap(HBITMAP hBitmap) // Not recommended, as reloads can't be done Then in your OnInitDialogįunction, call CBitmapPicture::SetBitmap() to set the bitmap to be used. Variable of type CBitmapPicture to the object. Your project then create a CStatic object to yuour dialog, and attach a member

The easist way to use this class is to add the CBitmapPicture class to This allows images to be displayed smaller When theįont size changes, the CStatic window size changes, and the bitmap willīe StretchBlt’d to the new size. To overcome this problem I wrote a CStatic derived class that displaysĪ bitmap according to the size of the underlying CStatic window.
#STRETCHBLT COPYIMAGE DRIVERS#
If the system font size is changed (The matrox millenium drivers allow you If you change the size of the dialog box font, then the sizeĪnd position of each control will also change, but the size of the displayedīitmap will not, resulting in a mis-aligned picture. A problem occurs if you want toĭisplay a bitmap which must be aligned with other controls (eg. The picture at the original picture’s size. Great for quickly displaying a picture in a dialog, but it only displays When you load the icon or cursor, the application asks for the size that the GetSystemMetrics() suggests the system then picks the closest image and scales if necessary.The Picture control available from the dialog editor component bar is cur formats are capable of storing multiple images in a single file. (GDI+ offers additional stretching options see the GDI+ section.) Use SetStretchBltMode() to change between stretching modes:Īn alternative to scaling is using multiple images, each designed for a different DPI. HALFTONE stretching is slower, but provides much higher quality. The default stretching mode, COLORONCOLOR, is fast but loses a lot of details. This is most noticeable when scaling from a small DPI to a large one, but scaling down also has problems the details the scaling algorithm chooses to keep are not necessarily the details you would choose. Scaling does degrade the quality of the image. HdcBitmap, 0, 0, info.bmWidth, info.bmHeight, SRCCOPY) DeleteDC(hdcBitmap) SCALEX(info.bmWidth), SCALEY(info.bmHeight), HDC hdcBitmap = CreateCompatibleDC(target) GetObject(bitmap, sizeof(info), (PTSTR) &info) This example takes a bitmap designed for 96 DPI, and draws it scaled:

StretchBlt can be used to do this, as well. It’s often easier for the application to scale the image when it is loaded, rather than scaling when the image is drawn.

You can scale a bitmap by calling StretchBlt() instead of BitBlt(). If the display’s DPI is not the same as the DPI for which the image was designed, the image needs to be scaled in order to appear the correct physical size. Images are more difficult to deal with than fonts, since images consist of discrete pixels.

“Images” covers all raster-based image files (such as BMP, JPEG, and GIF), icons, and cursors.
