| 490 | } |
| 491 | |
| 492 | static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) |
| 493 | { |
| 494 | if (comp != 4) { |
| 495 | // write RGB bitmap |
| 496 | int pad = (-x*3) & 3; |
| 497 | return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, |
| 498 | "11 4 22 4" "4 44 22 444444", |
| 499 | 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header |
| 500 | 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header |
| 501 | } else { |
| 502 | // RGBA bitmaps need a v4 header |
| 503 | // use BI_BITFIELDS mode with 32bpp and alpha mask |
| 504 | // (straight BI_RGB with alpha mask doesn't work in most readers) |
| 505 | return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *)data,1,0, |
| 506 | "11 4 22 4" "4 44 22 444444 4444 4 444 444 444 444", |
| 507 | 'B', 'M', 14+108+x*y*4, 0, 0, 14+108, // file header |
| 508 | 108, x,y, 1,32, 3,0,0,0,0,0, 0xff0000,0xff00,0xff,0xff000000u, 0, 0,0,0, 0,0,0, 0,0,0, 0,0,0); // bitmap V4 header |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) |
| 513 | { |
no test coverage detected