Results 1 to 14 of 14

Thread: Blitting compatable dc to compatable dc does not work.

  1. #1

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Blitting compatable dc to compatable dc does not work.

    //creation of the 2 dc's. hdc is screen.
    HDC memDC= ::CreateCompatibleDC(hdc);
    HDC imageDC= ::CreateCompatibleDC(hdc);

    //created drawing surface fo the memDC
    HBITMAP hMemBmp= ::CreateCompatibleBitmap(hdc, wndRect.right-wndRect.left,
    wndRect.bottom-wndRect.top);

    //Selecting bmp's into dc's
    HBITMAP hOldBmp= (HBITMAP)::SelectObject(imageDC, hBmp->HBmp);
    HBITMAP hOldMemBmp= (HBITMAP)::SelectObject(memDC, hMemBmp);

    //drawing background on memDC
    ::StretchBlt(memDC, 0, 0, wndRect.right-wndRect.left,
    wndRect.bottom-wndRect.top, imageDC, 0, 0, BmpW, BmpH, SRCCOPY);

    //Attempt to copy the memDC to another dc yeilds a black box
    //and not the image!
    ::BitBlt(imageDC, drawLocation->left, drawLocation->top, BmpW, BmpH, memDC, drawLocation->left, drawLocation->top, SRCCOPY);

  2. #2

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    My mistake. I could not see it! It's exactly the same as the background! Bad mistake!

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    the old bitmaps seems a bit redundant there, you've just created them dcs
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I have no idea what you are talking about but do you know how to create another object in memory just like a chosen object? Like a Bitmap?
    Do I use
    ::CreateCompatibleBitmap for a Bitmap?
    What about anything else?
    Last edited by aewarnick; Dec 13th, 2003 at 03:45 PM.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    yes, you can read more on msdn for creating other GDI objects http://msdn.microsoft.com/library/en...asp?frame=true
    I just pointed out that these:
    HBITMAP hOldBmp=
    HBITMAP hOldMemBmp=
    were redundant, as there are no bitmaps for the new dcs
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    But don't I have to Select them out of the dc's and then delete the HBitmap's when I'm done?

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    of course you have to.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Thanks. Are you trying to confuse me?

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    no, i certainly didn't intend to and i hope i didn't.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Are you saying that these
    HBITMAP hOldBmp=
    HBITMAP hOldMemBmp=
    are NULL?

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well now i'm not sure in fact, most of the time i see people even on msdn not deleting the objects.. so now that you mentioned it (and i used to take it for granted) it does return a 1x1 bitmap - and doing it again returns the same bitmap.. sorry if it seems confusing, but it seems to me as you should not delete it after all. Yet you should delete all bitmaps you create on your own.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Thank you very much. My code is now improved and probably a little faster.

  13. #13

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I read this article: CLICK
    and as you see, it mentions that there is a default Bitmap in the DC's that MS was not Selecting the Old hbitmaps back into the dc's and there was a leak.

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    thanks.. seems like microsoft can't keep track on anything but thats nothing new then..
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

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



Click Here to Expand Forum to Full Width