Sunday, January 30, 2005

Convert Image to Byte Digg del.icio.us Reddit Yahoo

[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:

[Wrong Way] return (Byte[])imgLogoBuffer;
[Correct Way] Byte[] btImageLogo = new Byte[1];
[Correct Way] return btImageLogo = (Byte[])(new ImageConverter()).ConvertTo(imgLogoBuffer, btImageLogo.GetType());

بابا جان هر چی رو که نمی شه با cast کردن تبدیل کرد. راه حل بالا بد نیست. گرچه به عدد آدم های روی زمین (نه روی هوا) راه است برای رسیدن به بایت های تصویر یک Image (;

1 comments:

Anonymous said...

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