You are currently offline, waiting for your internet to reconnect

StretchBlt()/StretchDIBits() Fails When Bitmap Sizes Differ Greatly

This article was previously published under Q269585
This article has been archived. It is offered "as is" and will no longer be updated.
StretchBlt() and StretchDIBits() may return FALSE (0, a BOOLEAN value, indicating failure), and this may occur even if system memory is not low, both device contexts are compatible, and both rectangles are within proper boundaries. This issue can occur if the source bitmap is much smaller than the destination bitmap.

This issue is known to affect the display of certain bitmaps as desktop wallpaper with Active Desktop Web content enabled.
This issue occurs because Graphics Device Interface (GDI) allocates an internal buffer for bitmap scaling operations. A scan line (or band) from the source bitmap is stretched (or scaled) into this buffer, and then copied to the destination bitmap. The size of the buffer is determined by the following initial conditions:
  • The width of the destination bitmap in PELS one source scan line.
  • The vertical scaling factor (destination height / source height).
  • The number of bytes per PEL (color depth).
The maximum size of this buffer is constrained to 64 kilobytes (for StretchBlt()), and 192 kilobytes (for StretchDIBits()). If the scaling factors or multipliers are large, it may not be possible for StretchBlt() to allocate a buffer that is both smaller than 64 kilobytes (K), and large enough to handle a single band. Similarly, StretchDIBits() may not be able to allocate a buffer that is smaller than 192 K that can accommodate a single band.

Given 1024 x 768 x 256 color display metrics, and a 16x16 source bitmap, StretchBlt() fails due to boundary conditions in the hunt method that is used to seek the optimum buffer size, but would succeed if the source bitmap were 18x18, or larger.
More information
For additional information about why StretchBlt() may fail, click the article number below to view the article in the Microsoft Knowledge Base:
92529 INFO: Reasons for Failure of Bitmap Functions
For additional information about how this problem affects Active Desktop Web Content, click the article number below to view the article in the Microsoft Knowledge Base:
269595 PRB: Active Desktop Wallpaper Scrambled
For additional information about this issue and Microsoft Windows 3.x, click the article number below to view the article in the Microsoft Knowledge Base:
111865 BUG: StretchBlt()/StretchDIBits() Fail with Very Large Stretch

Article ID: 269585 - Last Review: 10/26/2013 00:20:00 - Revision: 2.0

Microsoft Windows 95

  • kbnosurvey kbarchive kbdisplay kbprb KB269585