(.NET/GDI/BitBlt) Bitmap does not appear correctly using BitBlt
I have the following code which works fine and puts a transparent image onto
an image in a Picturebox. The Mask and Src Images are both In PictureBoxes
Private bmpConv As Bitmap = Nothing
Private bmpBtl As Bitmap = Nothing
Private bmpBtlMask As Bitmap = Nothing
bmpConv = Image.FromFile("..\Images\Conveyor.bmp")
pbConv.BackgroundImage = bmpConv
bmpBtl = Image.FromFile("..\Images\Mist50White.bmp")
pbBtl.BackgroundImage = bmpBtl
bmpBtlMask = Image.FromFile("..\Images\Mist50Mask.bmp")
pbBtlMask.BackgroundImage = bmpBtlMask
MyBitBlt(pbConv, pbBtl, pbBtlMask, 0, 0)
Public Sub MyBitBlt(ByVal Dst As PictureBox, ByVal Src As PictureBox,
ByVal Mask As PictureBox, ByVal X As Long, ByRef Y As Long)
' Get device context of source and destination picture boxes
Dim srcHDC As IntPtr = Src.CreateGraphics.GetHdc
Dim dstHDC As IntPtr = Dst.CreateGraphics.GetHdc
Dim maskHDC As IntPtr = Mask.CreateGraphics.GetHdc
BitBlt(dstHDC.ToInt32, X, Y, 50, 50, maskHDC.ToInt32, 0, 0,
TernaryRasterOperations.SRCPAINT)
'put the picture onto the main screen
BitBlt(dstHDC.ToInt32, X, Y, 50, 50, srcHDC.ToInt32, 0, 0,
TernaryRasterOperations.SRCAND)
End Sub
--
IT/Software Dev Manager
date: Thu, 15 May 2008 14:58:01 -0700
author: Tony (Goody Goody Liquor,Dallas)