P
Pavlo Pelekh
I wroted this piece of code :
#include <stdio.h>
#include <malloc.h>
FILE * f;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef long LONG;
LONG width;
LONG height;
struct BITMAPFILEHEADER {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} h1;
struct BITMAPINFOHEADER {
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
};
struct BITMAPINFO{
BITMAPINFOHEADER bmiHEADER;
//DWORD test;
} h2;
int main() {
// open file to read
f = fopen("1.bmp", "rb");
// read BITMAPFILEHEADER
fread( &h1 , sizeof(h1), 1, f);
char * string = & h1.bfType;
printf ("%s\n", string);
width = h1.bfSize;
printf("%ul \n", width);
}
it should print to stdout h1.bfType it's type of file: output is BM6;
and size of file. I see 91 or something like this, but should be 38386. If
anybody could help?
Thanks
#include <stdio.h>
#include <malloc.h>
FILE * f;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef long LONG;
LONG width;
LONG height;
struct BITMAPFILEHEADER {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} h1;
struct BITMAPINFOHEADER {
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
};
struct BITMAPINFO{
BITMAPINFOHEADER bmiHEADER;
//DWORD test;
} h2;
int main() {
// open file to read
f = fopen("1.bmp", "rb");
// read BITMAPFILEHEADER
fread( &h1 , sizeof(h1), 1, f);
char * string = & h1.bfType;
printf ("%s\n", string);
width = h1.bfSize;
printf("%ul \n", width);
}
it should print to stdout h1.bfType it's type of file: output is BM6;
and size of file. I see 91 or something like this, but should be 38386. If
anybody could help?
Thanks