mirror of
https://github.com/nothings/stb
synced 2024-12-15 12:22:55 +03:00
Merge branch 'master' of https://github.com/guillaumechereau/stb into working
This commit is contained in:
commit
23b21a7c1f
@ -89,10 +89,16 @@ distribute, and modify this file as you see fit.
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);
|
#ifdef STB_IMAGE_WRITE_STATIC
|
||||||
extern int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);
|
#define STBIWDEF static
|
||||||
extern int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);
|
#else
|
||||||
extern int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
|
#define STBIWDEF extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);
|
||||||
|
STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);
|
||||||
|
STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);
|
||||||
|
STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
@ -224,7 +230,7 @@ static int outfile(char const *filename, int rgb_dir, int vdir, int x, int y, in
|
|||||||
return f != NULL;
|
return f != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)
|
STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)
|
||||||
{
|
{
|
||||||
int pad = (-x*3) & 3;
|
int pad = (-x*3) & 3;
|
||||||
return outfile(filename,-1,-1,x,y,comp,1,(void *) data,0,pad,
|
return outfile(filename,-1,-1,x,y,comp,1,(void *) data,0,pad,
|
||||||
@ -233,7 +239,7 @@ int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *dat
|
|||||||
40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header
|
40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header
|
||||||
}
|
}
|
||||||
|
|
||||||
int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)
|
STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)
|
||||||
{
|
{
|
||||||
int has_alpha = (comp == 2 || comp == 4);
|
int has_alpha = (comp == 2 || comp == 4);
|
||||||
int colorbytes = has_alpha ? comp-1 : comp;
|
int colorbytes = has_alpha ? comp-1 : comp;
|
||||||
@ -299,8 +305,8 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra
|
|||||||
linear[1] = scanline[x*comp + 1];
|
linear[1] = scanline[x*comp + 1];
|
||||||
linear[0] = scanline[x*comp + 0];
|
linear[0] = scanline[x*comp + 0];
|
||||||
break;
|
break;
|
||||||
case 2: /* fallthrough */
|
default:
|
||||||
case 1: linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
|
linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stbiw__linear_to_rgbe(rgbe, linear);
|
stbiw__linear_to_rgbe(rgbe, linear);
|
||||||
@ -316,8 +322,8 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra
|
|||||||
linear[1] = scanline[x*comp + 1];
|
linear[1] = scanline[x*comp + 1];
|
||||||
linear[0] = scanline[x*comp + 0];
|
linear[0] = scanline[x*comp + 0];
|
||||||
break;
|
break;
|
||||||
case 2: /* fallthrough */
|
default:
|
||||||
case 1: linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
|
linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stbiw__linear_to_rgbe(rgbe, linear);
|
stbiw__linear_to_rgbe(rgbe, linear);
|
||||||
@ -369,7 +375,7 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)
|
STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
@ -698,7 +704,7 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)
|
STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int len;
|
int len;
|
||||||
|
Loading…
Reference in New Issue
Block a user