SHOW:
|
|
- or go back to the newest paste.
| 1 | # Bazz here with a patch for Texture.c in the StarRuby package | |
| 2 | # this patch will update StarRuby to be fully compatible with libPng 1.5 | |
| 3 | --- texture.c.old.txt 2012-12-23 18:47:39.000000000 -0500 | |
| 4 | +++ texture.c 2012-12-23 18:51:29.000000000 -0500 | |
| 5 | @@ -323,22 +323,30 @@ | |
| 6 | png_set_packing(pngPtr); | |
| 7 | } | |
| 8 | if (colorType == PNG_COLOR_TYPE_GRAY && bitDepth < 8) {
| |
| 9 | - png_set_gray_1_2_4_to_8(pngPtr); | |
| 10 | + png_set_expand_gray_1_2_4_to_8(pngPtr); | |
| 11 | } | |
| 12 | + | |
| 13 | + png_colorp png_palette = NULL; | |
| 14 | + int num_palette = 0; | |
| 15 | + png_get_PLTE(pngPtr, infoPtr, &png_palette, &num_palette); | |
| 16 | + | |
| 17 | png_read_update_info(pngPtr, infoPtr); | |
| 18 | - if (0 < infoPtr->num_palette && hasPalette) {
| |
| 19 | + if (0 < num_palette && hasPalette) {
| |
| 20 | texture->indexes = ALLOC_N(uint8_t, width * height); | |
| 21 | - const png_colorp palette = infoPtr->palette; | |
| 22 | - const int numTrans = infoPtr->num_trans; | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + int numTrans = 0; | |
| 27 | + png_bytep trans = NULL; | |
| 28 | #if PNG_LIBPNG_VER_SONUM <= 12 | |
| 29 | - const png_bytep trans = infoPtr->trans; | |
| 30 | + png_get_tRNS(pngPtr,infoPtr, &trans, &numTrans, NULL); | |
| 31 | #else | |
| 32 | - const png_bytep trans = infoPtr->trans_alpha; | |
| 33 | + png_get_tRNS(pngPtr,infoPtr, &trans, &numTrans, NULL); | |
| 34 | #endif | |
| 35 | - texture->paletteSize = infoPtr->num_palette; | |
| 36 | + texture->paletteSize = num_palette; | |
| 37 | Color* p = texture->palette = ALLOC_N(Color, texture->paletteSize); | |
| 38 | for (int i = 0; i < texture->paletteSize; i++, p++) {
| |
| 39 | - const png_colorp pngColorP = &(palette[i]); | |
| 40 | + const png_colorp pngColorP = &(png_palette[i]); | |
| 41 | p->red = pngColorP->red; | |
| 42 | p->green = pngColorP->green; | |
| 43 | p->blue = pngColorP->blue; |