Declare Auto Function BitBlt Lib "GDI32.DLL" (...)

Q

Qwert

Hello,

kind of a specific question, but here it goes:

The following code works:

Dim objGraphicsSource As Graphics = PictureBox1.CreateGraphics
Dim bmpSource As New Bitmap(PictureBox1.Width, PictureBox1.Height,
objGraphicsSource)
Dim objGraphicsBmp As Graphics = Graphics.FromImage(bmpSource)
Dim hdcSource As IntPtr = objGraphicsSource.GetHdc
Dim hdcDest As IntPtr = objGraphicsBmp.GetHdc
BitBlt(hdcDest, 0, 0, 50, pbxSource.Height, hdcSource, 0, 0, 13369376)
PictureBox2.Image = bmpSource.Clone()

but when I use as a source an Image object with a bmp loaded from file, it
doesn't work anymore.

WORKS:
Dim objGraphicsSource As Graphics = PictureBox1.CreateGraphics
WORKS NOT:
Dim objGraphicsSource As Graphics = Graphics.FromImage(BmpSource)

Why does this only work with Graphics object based on a PictureBox control
and not with a Graphics object based on a Image object with a bmp loaded
from file?

Thank you.



Declare Auto Function BitBlt Lib "GDI32.DLL" ( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Int32) As Boolean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top