Converting base64 image string to Bitmap in C#
This string prefix is not part of image base64 data, therefore before you try to convert it to Bitmap instance in C# code, you need to get rid of it. This can be easily done with simple regular expression:
How to get and actual instance of System.Drawing.Imaging.ImageFormat from a string you can find in article listed in the references sections at the bottom of this page
And now for the final thing and that is getting the Bitmap instance from the cleaned up base64 string data we just need to convert our base64 to byte array and pump it into the Stream from which we initialize the Bitmap instance
Purpose of the code contained in snippets or available for download in this article is solely for learning and demo purposes. Author will not be held responsible for any failure or damages caused due to any other usage.
Comments for this article