Created
September 13, 2010 20:39
-
-
Save GiorgioRegni/577996 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 write_bmp(unsigned char *img, int width, int height) { | |
| bmpfile_t *bmp; | |
| int i, j; | |
| rgb_pixel_t palette[PALETE_NUM_COLORS] = {0}; | |
| if ((bmp = bmp_create(width, height, 32)) == NULL) { | |
| printf("Could not create bitmap"); | |
| exit(-1); | |
| } | |
| /* Palette initialization code removed ... */ | |
| for (j = 0; j < height; ++j) { | |
| for (i = 0; i < width; ++i) { | |
| int index = j*width+i; | |
| int c = img[index]; | |
| bmp_set_pixel(bmp, i, j, palette[c % PALETE_NUM_COLORS]); | |
| } | |
| } | |
| bmp_save(bmp, "image.bmp"); | |
| bmp_destroy(bmp); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment