Browse Source

Merge branch 'fastjpeg' of https://github.com/nothings/stb into fastjpeg

Conflicts:
	stb_image.h
Fabian Giesen 10 years ago
parent
commit
7d32f74d8a
4 changed files with 566 additions and 178 deletions
  1. 549 171
      stb_image.h
  2. 7 7
      tests/image_test.c
  3. 8 0
      tests/test_cpp_compilation.cpp
  4. 2 0
      tests/test_truetype.c

File diff suppressed because it is too large
+ 549 - 171
stb_image.h


+ 7 - 7
tests/image_test.c

@@ -9,7 +9,7 @@
 
 #define PNGSUITE_PRIMARY
 
-#if 1
+#if 0
 void test_ycbcr(void)
 {
    STBI_SIMD_ALIGN(unsigned char, y[256]);
@@ -28,15 +28,15 @@ void test_ycbcr(void)
             cb[k] = j;
             cr[k] = i;
          }
-         stbi__YCbCr_to_RGB_sse2(out1[0], y, cb, cr, 256, 4);
-         stbi__YCbCr_to_RGB_backport(out2[0], y, cb, cr, 256, 4);
+         stbi__YCbCr_to_RGB_row(out1[0], y, cb, cr, 256, 4);
+         stbi__YCbCr_to_RGB_sse2(out2[0], y, cb, cr, 256, 4);
          for (k=0; k < 256; ++k) {
             if (out1[k][0] != out2[k][0] || out1[k][1] != out2[k][1] || out1[k][2] != out2[k][2]) {
                int dist1 = abs(out1[k][0] - out2[k][0]);
                int dist2 = abs(out1[k][1] - out2[k][1]);
                int dist3 = abs(out1[k][2] - out2[k][2]);
                ++count;
-               if (dist2)
+               if (out1[k][1] > out2[k][1])
                   ++bigcount;
             }
          }
@@ -50,12 +50,12 @@ void test_ycbcr(void)
 int main(int argc, char **argv)
 {
    int w,h;
-   test_ycbcr();
+   //test_ycbcr();
    if (argc > 1) {
-      int i;
+      int i, n;
+
       for (i=1; i < argc; ++i) {
          unsigned char *data;
-         int n;
          printf("%s\n", argv[i]);
          data = stbi_load(argv[i], &w, &h, &n, 4); if (data) free(data); else printf("Failed &n\n");
          data = stbi_load(argv[i], &w, &h,  0, 1); if (data) free(data); else printf("Failed 1\n");

+ 8 - 0
tests/test_cpp_compilation.cpp

@@ -8,6 +8,14 @@
 #define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION
 #define STB_RECT_PACK_IMPLEMENTATION
 
+#define STBI_MALLOC     my_malloc
+#define STBI_FREE       my_free
+#define STBI_REALLOC    my_realloc
+
+void *my_malloc(size_t) { return 0; }
+void *my_realloc(void *, size_t) { return 0; }
+void my_free(void *) { }
+
 #include "stb_image.h"
 #include "stb_rect_pack.h"
 #include "stb_truetype.h"

+ 2 - 0
tests/test_truetype.c

@@ -35,6 +35,7 @@ int main(int argc, char **argv)
    // @TODO: why is minglui.ttc failing? 
    fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/mingliu.ttc", "rb"));
 
+#if 0
    stbtt_BakeFontBitmap(ttf_buffer,stbtt_GetFontOffsetForIndex(ttf_buffer,0), 40.0, temp_bitmap[0],BITMAP_W,BITMAP_H, 32,96, cdata); // no guarantee this fits!
    stbi_write_png("fonttest1.png", BITMAP_W, BITMAP_H, 1, temp_bitmap, 0);
 
@@ -67,6 +68,7 @@ int main(int argc, char **argv)
       stbi_write_png("fonttest3.png", BITMAP_W, BITMAP_H, 1, temp_bitmap, 0);
    }
    return 0;
+#endif
 
    stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
    bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, (float)s), c, &w, &h, 0,0);

Some files were not shown because too many files changed in this diff