Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Bazz here with a patch for Texture.c in the StarRuby package
- # this patch will update StarRuby to be fully compatible with libPng 1.5
- --- texture.c.old.txt 2012-12-23 18:47:39.000000000 -0500
- +++ texture.c 2012-12-23 18:51:29.000000000 -0500
- @@ -323,22 +323,30 @@
- png_set_packing(pngPtr);
- }
- if (colorType == PNG_COLOR_TYPE_GRAY && bitDepth < 8) {
- - png_set_gray_1_2_4_to_8(pngPtr);
- + png_set_expand_gray_1_2_4_to_8(pngPtr);
- }
- +
- + png_colorp png_palette = NULL;
- + int num_palette = 0;
- + png_get_PLTE(pngPtr, infoPtr, &png_palette, &num_palette);
- +
- png_read_update_info(pngPtr, infoPtr);
- - if (0 < infoPtr->num_palette && hasPalette) {
- + if (0 < num_palette && hasPalette) {
- texture->indexes = ALLOC_N(uint8_t, width * height);
- - const png_colorp palette = infoPtr->palette;
- - const int numTrans = infoPtr->num_trans;
- +
- +
- +
- + int numTrans = 0;
- + png_bytep trans = NULL;
- #if PNG_LIBPNG_VER_SONUM <= 12
- - const png_bytep trans = infoPtr->trans;
- + png_get_tRNS(pngPtr,infoPtr, &trans, &numTrans, NULL);
- #else
- - const png_bytep trans = infoPtr->trans_alpha;
- + png_get_tRNS(pngPtr,infoPtr, &trans, &numTrans, NULL);
- #endif
- - texture->paletteSize = infoPtr->num_palette;
- + texture->paletteSize = num_palette;
- Color* p = texture->palette = ALLOC_N(Color, texture->paletteSize);
- for (int i = 0; i < texture->paletteSize; i++, p++) {
- - const png_colorp pngColorP = &(palette[i]);
- + const png_colorp pngColorP = &(png_palette[i]);
- p->red = pngColorP->red;
- p->green = pngColorP->green;
- p->blue = pngColorP->blue;
Advertisement
Add Comment
Please, Sign In to add comment