CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: [RESOLVED] Not clear about such a result from StretchBlt

  1. #1
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    [RESOLVED] Not clear about such a result from StretchBlt

    I'm not really clear why calling the following line on a 32-bit bitmap produces such a weird result? It's almost like a bitmap is converted to an 8-bit GIF or something.

    Code:
    //Image is being shrunk
    StretchBlt(hDC, 0, 0, nOutputW, nOutputH, hMemDC, 0, 0, nRenderW, nRenderH, SRCCOPY);
    See attached examples:
    "sm_bad.png" = (left) what I get from the line above
    "sm_good.png" = (right) how it should look
    Attached Images Attached Images   

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Not clear about such a result from StretchBlt

    Call SetStretchBltMode before StretchBlit. Use HALFTONE for high quality, or another options for fast blitting.

  3. #3
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: Not clear about such a result from StretchBlt

    Perfect, thanks.

    Do you think all those *Blt APIs take advantage of hardware acceleration?

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: [RESOLVED] Not clear about such a result from StretchBlt

    Depends on the version of windows you're using. And whether you're using desktop composition or not.

    Oddly enough, hardware accelleration from the application POV has taken a turn for the worst in recent versions of windows, and there is a drift AWAY from accelleration in GDI.

    However this is being offset (by a lot) by windows requiring the application to repaint itself far fewer (since windows is basically double buffering). Applications that force frequent invalidates can get punished for that however and should rework their ui's.

  5. #5
    Join Date
    Jul 2002
    Posts
    2,543

    Re: [RESOLVED] Not clear about such a result from StretchBlt

    Starting from Vista and later, all GDI stuff is implemented using software emulation level. Native graphic library that has hardware acceleration is now DirectX.

  6. #6
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: [RESOLVED] Not clear about such a result from StretchBlt

    Thanks for the info.

    I'm using that API to render a screen saver frames. So coupled with GDI+ drawing of a single full screen size PNG into my own "double-buffering" the whole picture becomes quite slow, even on my Windows 7 with the 8 core CPU and 1GB video RAM.

  7. #7
    Join Date
    Jul 2002
    Posts
    2,543

    Re: [RESOLVED] Not clear about such a result from StretchBlt

    Take a look at Direct2D.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)