January 29, 2005

Convert Image to Byte

[Error Prompt] Cannot convert type 'System.Drawing.Image' to 'Byte[]'

If you have this problem or you can't make casting convert Image to Byte Array in dotNet Solution, you can follow bellow:
return (Byte[])imgLogoBuffer;
Byte[] btImageLogo = new Byte[1];
return btImageLogo = (Byte[])(new ImageConverter()).ConvertTo(imgLogoBuffer, btImageLogo.GetType());
بابا جان هر چی رو که نمی شه با cast کردن تبدیل کرد. راه حل بالا بد نیست. گرچه راه زیاد است برای رسیدن به بایت های یک تصویر


Anonymous said...

Imagine the power of tens of thousands of other web sites being able to easily

Amastaneh said...

Error: Cannot convert type 'byte[]' to 'System.Drawing.Image'

//byte[] btImageLogo;
Image img = Image.FromStream(new MemoryStream(btImageLogo));

Laleh said...

good job :P