Bladeren bron

rle tweaks, credits

Sean Barrett 10 jaren geleden
bovenliggende
commit
5bcce36638
1 gewijzigde bestanden met toevoegingen van 14 en 3 verwijderingen
  1. 14 3
      stb_image_write.h

+ 14 - 3
stb_image_write.h

@@ -62,6 +62,9 @@ USAGE:
    data, alpha (if provided) is discarded, and for monochrome data it is
    data, alpha (if provided) is discarded, and for monochrome data it is
    replicated across all three channels.
    replicated across all three channels.
 
 
+   TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed
+   data, set the global variable 'stbi_write_tga_with_rle' to 0.
+
 CREDITS:
 CREDITS:
 
 
    PNG/BMP/TGA
    PNG/BMP/TGA
@@ -72,6 +75,8 @@ CREDITS:
       Jean-Sebastien Guay
       Jean-Sebastien Guay
    misc enhancements:
    misc enhancements:
       Tim Kelsey
       Tim Kelsey
+   TGA RLE
+      Alan Hickman
    bugfixes:
    bugfixes:
       github:Chribba
       github:Chribba
       Guillaume Chereau
       Guillaume Chereau
@@ -95,6 +100,7 @@ extern "C" {
 #define STBIWDEF static
 #define STBIWDEF static
 #else
 #else
 #define STBIWDEF extern
 #define STBIWDEF extern
+extern int stbi_write_tga_with_rle;
 #endif
 #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_png(char const *filename, int w, int h, int comp, const void  *data, int stride_in_bytes);
@@ -147,7 +153,12 @@ STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const
 typedef unsigned int stbiw_uint32;
 typedef unsigned int stbiw_uint32;
 typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];
 typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];
 
 
-static int stbi__write_tga_with_rle = 1;
+
+#ifdef STB_IMAGE_WRITE_STATIC
+static int stbi_write_tga_with_rle = 1;
+#else
+int stbi_write_tga_with_rle = 1;
+#endif
 
 
 static void writefv(FILE *f, const char *fmt, va_list v)
 static void writefv(FILE *f, const char *fmt, va_list v)
 {
 {
@@ -270,7 +281,7 @@ STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const
    int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3
    int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3
    FILE *f;
    FILE *f;
 
 
-   if (!stbi__write_tga_with_rle) {
+   if (!stbi_write_tga_with_rle) {
       return outfile(filename, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,
       return outfile(filename, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,
          "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);
          "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);
    }
    }
@@ -810,7 +821,7 @@ STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const
 
 
 /* Revision history
 /* Revision history
       0.99 (2015-09-13)
       0.99 (2015-09-13)
-             warning fixes
+             warning fixes; TGA rle support
       0.98 (2015-04-08)
       0.98 (2015-04-08)
              added STBIW_MALLOC, STBIW_ASSERT etc
              added STBIW_MALLOC, STBIW_ASSERT etc
       0.97 (2015-01-18)
       0.97 (2015-01-18)