Created
March 5, 2019 06:59
-
-
Save hewumars/bd8096d7d40476b1c57386439093505e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void savebmp(char *name,HI_U8 *buffer,int w,int h) { | |
FILE *f=fopen(name,"wb"); | |
if(!f) { | |
printf("Error writing image to disk.\n"); | |
return; | |
} | |
unsigned int size=w*h*3+54; | |
HI_U8 header[54]={'B','M',size&255,(size>>8)&255,(size>>16)&255,size>>24,0, | |
0,0,0,54,0,0,0,40,0,0,0,w&255,w>>8,0,0,h&255,h>>8,0,0,1,0,24,0,0,0,0,0,0, | |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | |
fwrite(header,1,54,f); | |
fwrite(buffer,1,w*h*3,f); | |
fclose(f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment