parent
315e979f34
commit
b14a80784c
@ -491,11 +491,22 @@ static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x,
|
|||||||
|
|
||||||
static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data)
|
static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data)
|
||||||
{
|
{
|
||||||
int pad = (-x*3) & 3;
|
if (comp != 4) {
|
||||||
return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,
|
// write RGB bitmap
|
||||||
"11 4 22 4" "4 44 22 444444",
|
int pad = (-x*3) & 3;
|
||||||
'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header
|
return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,
|
||||||
40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header
|
"11 4 22 4" "4 44 22 444444",
|
||||||
|
'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header
|
||||||
|
40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header
|
||||||
|
} else {
|
||||||
|
// RGBA bitmaps need a v4 header
|
||||||
|
// use BI_BITFIELDS mode with 32bpp and alpha mask
|
||||||
|
// (straight BI_RGB with alpha mask doesn't work in most readers)
|
||||||
|
return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *)data,1,0,
|
||||||
|
"11 4 22 4" "4 44 22 444444 4444 4 444 444 444 444",
|
||||||
|
'B', 'M', 14+108+x*y*4, 0, 0, 14+108, // file header
|
||||||
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
|
STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
|
||||||
@ -1619,6 +1630,7 @@ STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const
|
|||||||
/* Revision history
|
/* Revision history
|
||||||
1.15 ( )
|
1.15 ( )
|
||||||
make Deflate code emit uncompressed blocks when it would otherwise expand
|
make Deflate code emit uncompressed blocks when it would otherwise expand
|
||||||
|
support writing BMPs with alpha channel
|
||||||
1.14 (2020-02-02) updated JPEG writer to downsample chroma channels
|
1.14 (2020-02-02) updated JPEG writer to downsample chroma channels
|
||||||
1.13
|
1.13
|
||||||
1.12
|
1.12
|
||||||
|
Loading…
Reference in New Issue
Block a user