Ok, earlier I mentioned how to avoid memory leaks with FromHBitmap and GetHbitmap. In the example I had a bitmap supplied by reference. A key thing to realize (which I didn't at the time) is that the approach I presented can lead to broken pointers. Example is below:
'Just say you have the following Picture box (FImage)
'If you do the following, abmp will point to the Image of FImage (you don't make a copy)
Dim abmp as Bitmap = FImage.Image
'If you then supply abmp to the function I mentioned in the earlier post.
'Then all of a sudden FImage.Image does not have any data and you get an error when you try to use it.
So be careful when using the code below.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.