Hello all!
I'm trying to use this library to create base64 string from Bitmap image using code like this:
Bitmap bitmap = new Bitmap(1,1); FillBitmap(); byte[] bytes = (byte[])TypeDescriptor.GetConverter(bitmap) .ConvertTo(bitmap, typeof(byte[])); string result = Convert.ToBase64String(bytes);
I'm get an exception on third line:
An exception of type 'System.NotSupportedException' occurred in System.ComponentModel.TypeConverter.dll but was not handled in user code: ''TypeConverter' is unable to convert 'System.Drawing.Bitmap' to 'System.Byte[]'.' at System.ComponentModel.TypeConverter.GetConvertToException(Object value, Type destinationType) at System.ComponentModel.TypeConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType) at System.ComponentModel.TypeConverter.ConvertTo(Object value, Type destinationType)
Why it's wrong? How can I convert Bitmap to bytes array?
Thank you.