Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. StretchDIBits / mem DC

StretchDIBits / mem DC

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphicsperformancequestion
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pba_
    wrote on last edited by
    #1

    I want to scale a DIB into a window DC, and to do that I am using StretchDIBits - everything works fine. Because StretchDBits directly in the window DC is a very slow operation , I am trying to speed up the operation by stretching first into a mem DC and then draw the bitmap into the window DC using BitBlt. My problem is that StretchDIBits into the mem DC seems to have no result - nothing appears into the window DC. If I stretch directly everything works fine. // HBITMAP hBmp = ::CreateBitmap( /* ... */); BITMAPINFO bmpInfo // build bmp info //original code ::StrectchDibits( hDC, /* ... */); //everything is OK //updated code HDC hMemDC = ::CreateCompatibleDC( hDC); ::StretchDBIits( hMemDc, /* ... */); ::BitBlt( hDC, /* ... */, hMemDC, /* ... /-*/); //!? any help will be welcome ! Thanks .

    P 1 Reply Last reply
    0
    • P pba_

      I want to scale a DIB into a window DC, and to do that I am using StretchDIBits - everything works fine. Because StretchDBits directly in the window DC is a very slow operation , I am trying to speed up the operation by stretching first into a mem DC and then draw the bitmap into the window DC using BitBlt. My problem is that StretchDIBits into the mem DC seems to have no result - nothing appears into the window DC. If I stretch directly everything works fine. // HBITMAP hBmp = ::CreateBitmap( /* ... */); BITMAPINFO bmpInfo // build bmp info //original code ::StrectchDibits( hDC, /* ... */); //everything is OK //updated code HDC hMemDC = ::CreateCompatibleDC( hDC); ::StretchDBIits( hMemDc, /* ... */); ::BitBlt( hDC, /* ... */, hMemDC, /* ... /-*/); //!? any help will be welcome ! Thanks .

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      solon wrote: //updated code HDC hMemDC = ::CreateCompatibleDC( hDC); After you create the MemDC, you will have a monchromatic bitmap with 1 pixel selected into that memdc. What you need to do now is to create a bitmap that has the proper height, width and color depth to match the Window DC that you want to paint to. In order to do this you should use some code similar to this: // Get the dimensions of the client window. RECT rClient; ::GetClientRect(hWnd, &rClient); // Create the compatible bitmap to the window DC with the proper dimensions. HBITMAP hBmp = ::CreateCompatibleBitmap(hDC, rClient.right, rClient.bottom); // Select this new bitmap into the MemDC. (HBITMAP)::SelectObject(hMemDC, hBmp); Now you can continue with the code that you have previously written. solon wrote: ::StretchDBIits( hMemDc, /* ... */); ::BitBlt( hDC, /* ... */, hMemDC, /* ... /-*/); //!? Finally in order to cleanup, you must do things in this order. ::DeleteDC(hMemDC); ::DeleteObject(hBmp);

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups