forked from espressif/esp-who
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitmap.c
26 lines (24 loc) · 1.03 KB
/
bitmap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//https://stackoverflow.com/a/23303847
#include "bitmap.h"
#include <string.h>
#include <stdlib.h>
bitmap_header_t *bmp_create_header(int w, int h)
{
bitmap_header_t *pbitmap = (bitmap_header_t*)calloc(1, sizeof(bitmap_header_t));
int _pixelbytesize = w * h * _bitsperpixel/8;
int _filesize = _pixelbytesize+sizeof(bitmap_header_t);
strcpy((char*)pbitmap->fileheader.signature, "BM");
pbitmap->fileheader.filesize = _filesize;
pbitmap->fileheader.fileoffset_to_pixelarray = sizeof(bitmap_header_t);
pbitmap->bitmapinfoheader.dibheadersize = sizeof(bitmapinfoheader);
pbitmap->bitmapinfoheader.width = w;
pbitmap->bitmapinfoheader.height = h;
pbitmap->bitmapinfoheader.planes = _planes;
pbitmap->bitmapinfoheader.bitsperpixel = _bitsperpixel;
pbitmap->bitmapinfoheader.compression = _compression;
pbitmap->bitmapinfoheader.imagesize = _pixelbytesize;
pbitmap->bitmapinfoheader.ypixelpermeter = _ypixelpermeter ;
pbitmap->bitmapinfoheader.xpixelpermeter = _xpixelpermeter ;
pbitmap->bitmapinfoheader.numcolorspallette = 0;
return pbitmap;
}