L
Larry Serflaten
Can anyone see something wrong with the code below?
Friend Sub MapUpdate(ByRef Artwork As Bitmap, ByRef Player As MapObject)
If grxForm Is Nothing Then grxForm = Me.CreateGraphics
Dim hdcDst As IntPtr = grxForm.GetHdc
Dim art As Graphics = Graphics.FromImage(Artwork)
Dim hdcSrc As IntPtr = art.GetHdc
Dim rtn As Integer
rtn = BitBlt(hdcDst.ToInt32, 0, 46, 352, 349, hdcSrc.ToInt32, Player.Location.X - 160, Player.Location.Y - 160,
&HCC0020)
'rtn = BitBlt(hdcDst.ToInt32, 0, 0, 150, 150, hdcDst.ToInt32, 50, 50, &HCC0020)
grxForm.ReleaseHdc(hdcDst)
art.ReleaseHdc(hdcSrc)
art.Dispose()
'myArtRect.X = Player.Location.X - 160
'myArtRect.Y = Player.Location.Y - 160
'grxForm.DrawImage(Artwork, myMapRect, myArtRect, GraphicsUnit.Pixel)
The problem is that the image copied is all black. If I use the
second BitBlt line, that works to copy part of the form back on
to itself. Both calls return 1.
If I comment it all out (except the top line) and use the last 3
lines that are shown commented, that works to copy the image, but
it is just too slow. The Artwork is a much larger bitmap and I am
trying to copy only a portion of it to the form.
Can anyone see why I am getting an all black copy?
Thanks
LFS
Friend Sub MapUpdate(ByRef Artwork As Bitmap, ByRef Player As MapObject)
If grxForm Is Nothing Then grxForm = Me.CreateGraphics
Dim hdcDst As IntPtr = grxForm.GetHdc
Dim art As Graphics = Graphics.FromImage(Artwork)
Dim hdcSrc As IntPtr = art.GetHdc
Dim rtn As Integer
rtn = BitBlt(hdcDst.ToInt32, 0, 46, 352, 349, hdcSrc.ToInt32, Player.Location.X - 160, Player.Location.Y - 160,
&HCC0020)
'rtn = BitBlt(hdcDst.ToInt32, 0, 0, 150, 150, hdcDst.ToInt32, 50, 50, &HCC0020)
grxForm.ReleaseHdc(hdcDst)
art.ReleaseHdc(hdcSrc)
art.Dispose()
'myArtRect.X = Player.Location.X - 160
'myArtRect.Y = Player.Location.Y - 160
'grxForm.DrawImage(Artwork, myMapRect, myArtRect, GraphicsUnit.Pixel)
The problem is that the image copied is all black. If I use the
second BitBlt line, that works to copy part of the form back on
to itself. Both calls return 1.
If I comment it all out (except the top line) and use the last 3
lines that are shown commented, that works to copy the image, but
it is just too slow. The Artwork is a much larger bitmap and I am
trying to copy only a portion of it to the form.
Can anyone see why I am getting an all black copy?
Thanks
LFS