bazz

StarRuby Patch for LibPNG 1.5 Compatibility

Dec 23rd, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- texture.c.old.txt   2012-12-23 18:47:39.000000000 -0500
  2. +++ texture.c   2012-12-23 18:51:29.000000000 -0500
  3. @@ -323,22 +323,30 @@
  4.      png_set_packing(pngPtr);
  5.    }
  6.    if (colorType == PNG_COLOR_TYPE_GRAY && bitDepth < 8) {
  7. -    png_set_gray_1_2_4_to_8(pngPtr);
  8. +    png_set_expand_gray_1_2_4_to_8(pngPtr);
  9.    }
  10. +
  11. +   png_colorp png_palette = NULL;
  12. +   int num_palette = 0;
  13. +   png_get_PLTE(pngPtr, infoPtr, &png_palette, &num_palette);
  14. +
  15.    png_read_update_info(pngPtr, infoPtr);
  16. -  if (0 < infoPtr->num_palette && hasPalette) {
  17. +  if (0 < num_palette && hasPalette) {
  18.      texture->indexes = ALLOC_N(uint8_t, width * height);
  19. -    const png_colorp palette = infoPtr->palette;
  20. -    const int numTrans = infoPtr->num_trans;
  21. +
  22. +  
  23. +  
  24. +   int numTrans = 0;
  25. +   png_bytep trans = NULL;
  26.  #if PNG_LIBPNG_VER_SONUM <= 12
  27. -    const png_bytep trans = infoPtr->trans;
  28. +   png_get_tRNS(pngPtr,infoPtr, &trans, &numTrans, NULL);
  29.  #else
  30. -    const png_bytep trans = infoPtr->trans_alpha;
  31. +   png_get_tRNS(pngPtr,infoPtr, &trans, &numTrans, NULL);
  32.  #endif
  33. -    texture->paletteSize = infoPtr->num_palette;
  34. +    texture->paletteSize = num_palette;
  35.      Color* p = texture->palette = ALLOC_N(Color, texture->paletteSize);
  36.      for (int i = 0; i < texture->paletteSize; i++, p++) {
  37. -      const png_colorp pngColorP = &(palette[i]);
  38. +      const png_colorp pngColorP = &(png_palette[i]);
  39.        p->red   = pngColorP->red;
  40.        p->green = pngColorP->green;
  41.        p->blue  = pngColorP->blue;
Advertisement
Add Comment
Please, Sign In to add comment