EDN Admin
Well-known member
I used code below to retrive Bitmap Image height, but the value is always negative value -858993460. Is there anything wrong with the code below?
<pre class="prettyprint typedef struct tagBITMAPINFOHEADER
{
uint32_t biSize; //specifies the number of bytes required by the struct/header
uint32_t biWidth; //specifies width in pixels
uint32_t biHeight; //species height in pixels
uint16_t biPlanes; //specifies the number of color planes, must be 1
uint16_t biBitCount; //specifies the number of bit per pixel
uint32_t biCompression;//specifies the type of compression
uint32_t biSizeImage; //size of image in bytes
int32_t biXPelsPerMeter; //number of pixels per meter in x axis
int32_t biYPelsPerMeter; //number of pixels per meter in y axis
uint32_t biClrUsed; //number of colors used by th ebitmap
uint32_t biClrImportant; //number of colors that are important
}BITMAPINFOHEADER;
uint8_t *LoadBitmapFile(char *filename, BITMAPINFOHEADER *bitmapInfoHeader)
{
FILE *filePtr; //our file pointer
BITMAPFILEHEADER bitmapFileHeader; //our bitmap file header
uint8_t *bitmapImage; //store image data
int imageIdx=0; //image index counter
unsigned char tempRGB; //our swap variable
//open filename in read binary mode
filePtr = fopen(filename,"rb");
if (filePtr == NULL)
{
cout<<"couldnt open the file";
return NULL;
}
int main()
{
int a;
BITMAPINFOHEADER bitmapInfoHeader;
uint8_t *bitmapData;
fflush(stdin);
bitmapData = LoadBitmapFile("D:\SampleBitMap.bmp",&bitmapInfoHeader);
}[/code]
<br/>
<
Jason
View the full article
<pre class="prettyprint typedef struct tagBITMAPINFOHEADER
{
uint32_t biSize; //specifies the number of bytes required by the struct/header
uint32_t biWidth; //specifies width in pixels
uint32_t biHeight; //species height in pixels
uint16_t biPlanes; //specifies the number of color planes, must be 1
uint16_t biBitCount; //specifies the number of bit per pixel
uint32_t biCompression;//specifies the type of compression
uint32_t biSizeImage; //size of image in bytes
int32_t biXPelsPerMeter; //number of pixels per meter in x axis
int32_t biYPelsPerMeter; //number of pixels per meter in y axis
uint32_t biClrUsed; //number of colors used by th ebitmap
uint32_t biClrImportant; //number of colors that are important
}BITMAPINFOHEADER;
uint8_t *LoadBitmapFile(char *filename, BITMAPINFOHEADER *bitmapInfoHeader)
{
FILE *filePtr; //our file pointer
BITMAPFILEHEADER bitmapFileHeader; //our bitmap file header
uint8_t *bitmapImage; //store image data
int imageIdx=0; //image index counter
unsigned char tempRGB; //our swap variable
//open filename in read binary mode
filePtr = fopen(filename,"rb");
if (filePtr == NULL)
{
cout<<"couldnt open the file";
return NULL;
}
int main()
{
int a;
BITMAPINFOHEADER bitmapInfoHeader;
uint8_t *bitmapData;
fflush(stdin);
bitmapData = LoadBitmapFile("D:\SampleBitMap.bmp",&bitmapInfoHeader);
}[/code]
<br/>
<
Jason
View the full article