burningsheep
New member
- Joined
- Feb 8, 2006
- Messages
- 1
- Programming Experience
- Beginner
Hi, i started vb6 a year ago. I then learnt how to use the bitblt and other api's to blit a picture from the hard drive to a form or picturebox with transparency. Now my problem is, how do i do this in vb.net 2005? All i need to do is blit the image from the file to the form and then i can figure out the rest. So here's the code i tried but theres a memory leak with the lines that i've put a "*".
Private bmp AsNew Bitmap("Load001.bmp")
Dim srcGraphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmp)
Dim dstGraphics As System.Drawing.Graphics = Form1.CreateGraphics()
Dim sDC As IntPtr = srcGraphics.GetHdc
Dim dDC As IntPtr = dstGraphics.GetHdc
* Dim hOld As IntPtr = SelectObject(sDC, bmp.GetHbitmap)
BitBlt(dDC, 0, 0, 1000, 1000, sDC, 0, 0, SRCCOPY) '1000 = h,w
* SelectObject(sDC, hOld)
srcGraphics.ReleaseHdc(sDC)
srcGraphics.Dispose()
dstGraphics.ReleaseHdc(dDC)
dstGraphics.Dispose()
Also, is there a better way to display graphics than bitblt (not going in directX) as of speed? (I've heard that GDI+ is slower than bitblt).
Thanks in advance.
vinny - 15
p.s. I accidentally posted twice and should this go in another category?
Private bmp AsNew Bitmap("Load001.bmp")
Dim srcGraphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmp)
Dim dstGraphics As System.Drawing.Graphics = Form1.CreateGraphics()
Dim sDC As IntPtr = srcGraphics.GetHdc
Dim dDC As IntPtr = dstGraphics.GetHdc
* Dim hOld As IntPtr = SelectObject(sDC, bmp.GetHbitmap)
BitBlt(dDC, 0, 0, 1000, 1000, sDC, 0, 0, SRCCOPY) '1000 = h,w
* SelectObject(sDC, hOld)
srcGraphics.ReleaseHdc(sDC)
srcGraphics.Dispose()
dstGraphics.ReleaseHdc(dDC)
dstGraphics.Dispose()
Also, is there a better way to display graphics than bitblt (not going in directX) as of speed? (I've heard that GDI+ is slower than bitblt).
Thanks in advance.
vinny - 15
p.s. I accidentally posted twice and should this go in another category?
Last edited: