c# - Image from manually created byte[] -
i want create image byte[]
create manually, jit error
system.argumentexception: parameter not valid. @ system.drawing.image.fromstream(stream stream, boolean useembeddedcolormanagement, boolean validateimagedata) @ createbitmapfromstream.form1.form1_load(object sender, eventargs e) in c:\data\c#-workspace\createbitmapfromstream\createbitmapfromstream\form1.cs:line 35 @ system.windows.forms.form.onload(eventargs e) ...
here code:
private void form1_load(object sender, eventargs e) { var data = new byte[20*10]; (int = 0; < data.length; i++) { if (i < 100) data[i] = 0x15; else data[i] = 0x99; } using (var ms = new memorystream(data)) { var img = image.fromstream(ms, true, true); panel1.backgroundimage = img; } }
what doing wrong?
an image constructed according format.
it's not sequence of pixels. if want draw pixels, use bitmap
class provided system.drawing
bitmap b = new bitmap(1, 1); b.setpixel(0, 0, color.gray);
Comments
Post a Comment