Hi,
Use Bitmap instead of image. Bit map can be directly created from image file name or from image itself
Dim bmp as Bitmap=new Bitmap(image);
then you may write it to a memory stream and get the bytes. Refer
http://www.vbforums.com/showthread.php?t=358917[
^]
But this will give you all the image bytes, I mean all the bytes the file has including headers etc.,
If you only want the pixel values then loop through it
int xBound = bmp.Width;
int yBound = bmp.Height;
The c# code here. Convert to VB.net
Byte[,] pixels=new Byte[xBound,yBound];
Color clr;
for (int i = 0; i < xBound - 1; i++)
{
for (int j = 0; j < xBound - 1; j++)
{
clr = bitmap.GetPixel(i, j);
pixels[i, j] = clr.R;
}
}
Note: for a grey scale clr.R,clr.G, clr.B all are results in same values.
After the 2D array manipulations you may use setPixels to the bitmap.
The bitmap can be set to a picturebox
picturebox1.Image=bitmap;
If you want ...
So I create a random series of Bytes, but can find no way (without writing to the file system) to make it show up on my form's PictureBox component.
then
Bitmap bitmap2 = new Bitmap(xBound, yBound);
for (int i = 0; i < xBound - 1; i++)
{
for (int j = 0; j < xBound - 1; j++)
{
bitmap2.SetPixel(i,j,Color.FromArgb(Random value,random value,random value));
}
}
pictureBox1.Image = bitmap2;
or generate bitmap from a stream. There are 12 overloaded methods to create the bitmap. Your choice