here is my code :
Image img;
int height = 0;
int weight = 0;
int size = 0;
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK) // Test result.
{
try
{
img = Image.FromFile(openFileDialog1.FileName);
ccdImageAnalyzer1.Image = img;
byte[] image = imageToByteArray(img);
height = img.Height;
weight = img.Width;
size = height * weight;
}
catch( Exception err)
{
MessageBox.Show(err.ToString());
}
}
MessageBox.Show(result.ToString());
the problem is I am getting :
256 for height and 256 for width
and size is 65536
however my byte array image is size {byte[262198]} long.
how is this ?
pixels are from 0 - 255 and 255 is 1111 1111 and that is one byte, so the array should be only 65536 long...
so what is going on ?
public byte[] imageToByteArray(Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
return ms.ToArray();
}
I am using a .Bmp picture
65536 * 4 = 262198
so it is 4 bytes for one pixels ?
Also, If that is true, then does pixel img(0,0) = image[0], image[1], image[2], image[3]?
if so,
should I convert it into a int ? so I can get the number 255 ?
I saved a white picture in paint as a ,bmp and I run my program and somehow I got non 0 values in my image array ?
how is that? I even saw some 255 but white is 0.
I just save a white pic.
the array should be fully of zero