patch-interfaces_IDirectFBImageProvider_idirectfbimageprovider_png_c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. --- DirectFB-1.4.11.orig/interfaces/IDirectFBImageProvider/idirectfbimageprovider_png.c 2010-10-31 09:49:49.000000000 +0100
  2. +++ DirectFB-1.4.11/interfaces/IDirectFBImageProvider/idirectfbimageprovider_png.c 2011-03-29 10:57:18.433069010 +0200
  3. @@ -207,7 +207,7 @@ Construct( IDirectFBImageProvider *thiz,
  4. if (!data->png_ptr)
  5. goto error;
  6. - if (setjmp( data->png_ptr->jmpbuf )) {
  7. + if (png_jmpbuf( data->png_ptr )) {
  8. D_ERROR( "ImageProvider/PNG: Error reading header!\n" );
  9. goto error;
  10. }
  11. @@ -292,7 +292,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDi
  12. rect = dst_data->area.wanted;
  13. }
  14. - if (setjmp( data->png_ptr->jmpbuf )) {
  15. + if (png_jmpbuf( data->png_ptr )) {
  16. D_ERROR( "ImageProvider/PNG: Error during decoding!\n" );
  17. if (data->stage < STAGE_IMAGE)
  18. @@ -327,6 +327,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDi
  19. }
  20. else {
  21. CoreSurfaceBufferLock lock;
  22. + png_byte bit_depth = png_get_bit_depth( data->png_ptr, data->info_ptr );
  23. ret = dfb_surface_lock_buffer( dst_surface, CSBR_BACK, CSAID_CPU, CSAF_WRITE, &lock );
  24. if (ret)
  25. @@ -334,7 +335,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDi
  26. switch (data->color_type) {
  27. case PNG_COLOR_TYPE_PALETTE:
  28. - if (dst_surface->config.format == DSPF_LUT8 && data->info_ptr->bit_depth == 8) {
  29. + if (dst_surface->config.format == DSPF_LUT8 && bit_depth == 8) {
  30. /*
  31. * Special indexed PNG to LUT8 loading.
  32. */
  33. @@ -377,7 +378,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDi
  34. }
  35. else {
  36. if (data->color_type == PNG_COLOR_TYPE_GRAY) {
  37. - int num = 1 << data->info_ptr->bit_depth;
  38. + int num = 1 << bit_depth;
  39. for (x=0; x<num; x++) {
  40. int value = x * 255 / (num - 1);
  41. @@ -386,7 +387,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDi
  42. }
  43. }
  44. - switch (data->info_ptr->bit_depth) {
  45. + switch (bit_depth) {
  46. case 8:
  47. for (y=0; y<data->height; y++) {
  48. u8 *S = data->image + data->pitch * y;
  49. @@ -441,7 +442,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDi
  50. default:
  51. D_ERROR( "ImageProvider/PNG: Unsupported indexed bit depth %d!\n",
  52. - data->info_ptr->bit_depth );
  53. + bit_depth );
  54. }
  55. dfb_scale_linear_32( image_argb, data->width, data->height,
  56. @@ -594,16 +595,26 @@ png_info_callback( png_structp png_read_
  57. NULL, NULL, NULL );
  58. if (png_get_valid( data->png_ptr, data->info_ptr, PNG_INFO_tRNS )) {
  59. + png_bytep trans;
  60. + png_color_16p trans_color;
  61. + int num_trans;
  62. +
  63. + png_get_tRNS( data->png_ptr, data->info_ptr, &trans, &num_trans, &trans_color );
  64. +
  65. data->color_keyed = true;
  66. /* generate color key based on palette... */
  67. if (data->color_type == PNG_COLOR_TYPE_PALETTE) {
  68. u32 key;
  69. - png_colorp palette = data->info_ptr->palette;
  70. - png_bytep trans = data->info_ptr->trans_alpha;
  71. - int num_colors = MIN( MAXCOLORMAPSIZE,
  72. - data->info_ptr->num_palette );
  73. - u8 cmap[3][num_colors];
  74. + png_colorp palette;
  75. + int num_colors;
  76. + u8 *cmap[3];
  77. +
  78. + png_get_PLTE( data->png_ptr, data->info_ptr, &palette, &num_colors );
  79. + num_colors = MIN( MAXCOLORMAPSIZE, num_colors );
  80. + cmap[0] = alloca (num_colors);
  81. + cmap[1] = alloca (num_colors);
  82. + cmap[2] = alloca (num_colors);
  83. for (i=0; i<num_colors; i++) {
  84. cmap[0][i] = palette[i].red;
  85. @@ -613,7 +624,7 @@ png_info_callback( png_structp png_read_
  86. key = FindColorKey( num_colors, &cmap[0][0] );
  87. - for (i=0; i<data->info_ptr->num_trans; i++) {
  88. + for (i=0; i<num_trans; i++) {
  89. if (!trans[i]) {
  90. palette[i].red = (key & 0xff0000) >> 16;
  91. palette[i].green = (key & 0x00ff00) >> 8;
  92. @@ -625,20 +636,23 @@ png_info_callback( png_structp png_read_
  93. }
  94. else {
  95. /* ...or based on trans rgb value */
  96. - png_color_16p trans = &data->info_ptr->trans_color;
  97. -
  98. - data->color_key = (((trans->red & 0xff00) << 8) |
  99. - ((trans->green & 0xff00)) |
  100. - ((trans->blue & 0xff00) >> 8));
  101. + data->color_key = (((trans_color->red & 0xff00) << 8) |
  102. + ((trans_color->green & 0xff00)) |
  103. + ((trans_color->blue & 0xff00) >> 8));
  104. }
  105. }
  106. switch (data->color_type) {
  107. case PNG_COLOR_TYPE_PALETTE: {
  108. - png_colorp palette = data->info_ptr->palette;
  109. - png_bytep trans = data->info_ptr->trans_alpha;
  110. - int num_trans = data->info_ptr->num_trans;
  111. - int num_colors = MIN( MAXCOLORMAPSIZE, data->info_ptr->num_palette );
  112. + png_colorp palette;
  113. + png_bytep trans;
  114. + png_color_16p trans_color;
  115. + int num_trans;
  116. + int num_colors;
  117. +
  118. + png_get_PLTE( data->png_ptr, data->info_ptr, &palette, &num_colors );
  119. + num_colors = MIN( MAXCOLORMAPSIZE, num_colors );
  120. + png_get_tRNS( data->png_ptr, data->info_ptr, &trans, &num_trans, &trans_color );
  121. for (i=0; i<num_colors; i++) {
  122. data->colors[i].a = (i < num_trans) ? trans[i] : 0xff;