zozo ahmed

zozo ahmed

  • NA
  • 18
  • 15.4k

copy data from bitmap array into new array store data of bmp

Dec 30 2013 6:19 PM

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 ?


Answers (1)