Results 1 to 2 of 2

Thread: [2005] Problem with BitBlt from Bitmap to Bitmap

  1. #1

    Thread Starter
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    [2005] Problem with BitBlt from Bitmap to Bitmap

    Hi.

    Can someone tell me why this doesn't work?
    I would expect the end result to be all red, but nothing happens.
    If I remove the source bitmap and graphics object and just use "hdcSrc=GetDC(0)" then I get a screenshot, so I know the BitBlt function works.
    It appears that the BitBlt function can't copy from one memory image to another.

    So, can anyone answer this:
    Are there any problems BitBlt'ing two memory images? Or does it have to be real physical devicecontexts?

    VB Code:
    1. Dim bmpDst, bmpSrc As Bitmap
    2.         Dim grpDst, grpSrc As Graphics
    3.         Dim hdcDst, hdcSrc As IntPtr
    4.  
    5.         bmpDst = New Bitmap(Panel1.ClientRectangle.Width, Panel1.ClientRectangle.Height)
    6.         bmpSrc = New Bitmap(Panel1.ClientRectangle.Width, Panel1.ClientRectangle.Height)
    7.  
    8.         grpDst = Graphics.FromImage(bmpDst)
    9.         grpSrc = Graphics.FromImage(bmpSrc)
    10.  
    11.         grpDst.Clear(Color.Black)
    12.         grpSrc.Clear(Color.Red)
    13.         grpSrc.Flush()
    14.  
    15.         hdcDst = grpDst.GetHdc
    16.         hdcSrc = grpSrc.GetHdc
    17.  
    18.         Win32.Declarations.BitBlt(hdcDst, 0, 0, bmpDst.Width, bmpDst.Height, hdcSrc, 0, 0, Win32.Constants.BitBltConstants.SRCCOPY)
    19.  
    20.         grpSrc.ReleaseHdc(hdcSrc)
    21.         grpDst.ReleaseHdc(hdcDst)
    22.  
    23.         grpSrc.Dispose()
    24.         grpDst.Dispose()
    25.  
    26.         e.Graphics.DrawImage(bmpDst, 0, 0)
    27.  
    28.         bmpDst.Dispose()
    29.         bmpSrc.Dispose()

    Thanks
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  2. #2

    Thread Starter
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Re: [2005] Problem with BitBlt from Bitmap to Bitmap

    *** Bumpety-Bump ***

    Where are you Wossy?
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

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