Skip to content
Myr

rle tweaks, credits

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent 40ace6b · Browse files · 1 file+14 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+14 added−3 removed

  • other:+14 added−3 removed

1 file+14 added−3 removed

modified:stb_image_write.h+14 added-3 removed
60 unmodified lines
61 HDR expects linear float data. Since the format is always 32-bit rgb(e)62 data, alpha (if provided) is discarded, and for monochrome data it is63 replicated across all three channels.6465 TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed66 data, set the global variable 'stbi_write_tga_with_rle' to 0.6768CREDITS:6970 PNG/BMP/TGA71 Sean Barrett
2 unmodified lines
74 TGA monochrome:75 Jean-Sebastien Guay76 misc enhancements:77 Tim Kelsey78 TGA RLE79 Alan Hickman80 bugfixes:81 github:Chribba82 Guillaume Chereau83 github:jry2
15 unmodified lines
99#ifdef STB_IMAGE_WRITE_STATIC100#define STBIWDEF static101#else102#define STBIWDEF extern103extern int stbi_write_tga_with_rle;104#endif105106STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);107STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);
44 unmodified lines
152153typedef unsigned int stbiw_uint32;154typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];155150static int stbi__write_tga_with_rle = 1;156157#ifdef STB_IMAGE_WRITE_STATIC158static int stbi_write_tga_with_rle = 1;159#else160int stbi_write_tga_with_rle = 1;161#endif162163static void writefv(FILE *f, const char *fmt, va_list v)164{165 while (*fmt) {166 switch (*fmt++) {
113 unmodified lines
280 int colorbytes = has_alpha ? comp-1 : comp;281 int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3282 FILE *f;283273 if (!stbi__write_tga_with_rle) {284 if (!stbi_write_tga_with_rle) {285 return outfile(filename, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,286 "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);287 }288
531 unmodified lines
820#endif // STB_IMAGE_WRITE_IMPLEMENTATION821822/* Revision history823 0.99 (2015-09-13)813 warning fixes824 warning fixes; TGA rle support825 0.98 (2015-04-08)826 added STBIW_MALLOC, STBIW_ASSERT etc827 0.97 (2015-01-18)828 fixed HDR asserts, rewrote HDR rle logic
15 unmodified lines