I work on bitmap i read header of bmp 24 bit per pixel ,width 320 height 240,offset start of image data in location 54,use c#
in location 54 in bmp array i access to data ,i store data in new array :
struct pix //structure for pixel in bmp image
{
public byte r;//Red
public byte g;//Green
public byte b;//Blue
};
Bitmap img = new Bitmap(opendialog1.FileName);
string filename = opendialog1.FileName;
byte[] bmp = File.ReadAllBytes(filename);
int i=54;
pix[ , ] bmpdata = new pix[img.Height, img.Width]; //create array of structure
for (int row = 0; row < img.Height; row++)
{
for (int col = 0; col < img.Width; col++)
{
bmpdata[row, col].r = bmp[i];
bmpdata[row, col].g = bmp[i + 1];
bmpdata[row, col].b = bmp[i + 2];
i += 3;
}
is this correct method for copy data from bmp array into new array for data only ,i use c# window form ?
No this is not how you get the pixel data (color information).
Compare it yourself with the color defined at each pixel by calling
GetPixel(x,y)
Also you could compare with this method:
If you just want the byte data, use
img.Save()
to save to a newMemoryStream
for example...