Pages

Wednesday, December 2, 2015

How to Convert a Bitmap to an Image

I have seen a lot of crap about how to do this, and there is some very bad advice out there.
This:
Image img = (Image)myBitmap; DOES NOT WORK!

I did find a way to do this in one line of code. Many of the solutions I saw were 50+ lines of code, and most assumed you were saving the bitmap to a file first, which I did not want to do.

Image img = Image.FromHbitmap(bmp.GetHbitmap()); ...

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

No comments:

Share This!

Contact Us

Name

Email *

Message *