Watch out for memory leaks when debugging and working with .GetHBitmap
When you use this function, you need to delete the object manually.
MSDN example: http://msdn.microsoft.com/en-us/library/1dz311e4.aspx
<System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")> _ Private Shared Function DeleteObject (ByVal hObject As IntPtr) As Boolean End Function Private Sub DemonstrateGetHbitmap() Dim bm As New Bitmap("Picture.jpg") Dim hBitmap As IntPtr hBitmap = bm.GetHbitmap() ' Do something with hBitmap. DeleteObject(hBitmap) End Sub
and similar question: Error loading image using C #
Hello
source share