Show
Ignore:
Timestamp:
02/15/10 11:56:43 (2 years ago)
Author:
Carsten
Message:

Merged latest libpng upgrade in vendor/libpng to cafu/trunk/ExtLibs/libpng.

Note that this implements the "Vendor Branches" strategy described in the Subversion book at
 http://svnbook.red-bean.com/nightly/en/svn.branchmerge.basicmerging.html
 http://svnbook.red-bean.com/nightly/en/svn.advanced.vendorbr.html

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/ExtLibs/libpng/pngread.c

    r11 r44  
    22/* pngread.c - read a PNG file 
    33 * 
    4  * Last changed in libpng 1.2.37 [June 4, 2009] 
     4 * Last changed in libpng 1.2.41 [December 3, 2009] 
    55 * Copyright (c) 1998-2009 Glenn Randers-Pehrson 
    66 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 
     
    1616 
    1717#define PNG_INTERNAL 
     18#define PNG_NO_PEDANTIC_WARNINGS 
    1819#include "png.h" 
    19 #if defined(PNG_READ_SUPPORTED) 
     20#ifdef PNG_READ_SUPPORTED 
     21 
    2022 
    2123/* Create a PNG structure for reading, and allocate any memory needed. */ 
     
    5254 
    5355   png_debug(1, "in png_create_read_struct"); 
     56 
    5457#ifdef PNG_USER_MEM_SUPPORTED 
    5558   png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, 
     
    6366   /* Added at libpng-1.2.6 */ 
    6467#ifdef PNG_SET_USER_LIMITS_SUPPORTED 
    65    png_ptr->user_width_max=PNG_USER_WIDTH_MAX; 
    66    png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; 
     68   png_ptr->user_width_max = PNG_USER_WIDTH_MAX; 
     69   png_ptr->user_height_max = PNG_USER_HEIGHT_MAX; 
    6770#endif 
    6871 
     
    8790   png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); 
    8891#endif 
    89 #endif 
     92#endif /* PNG_SETJMP_SUPPORTED */ 
    9093 
    9194#ifdef PNG_USER_MEM_SUPPORTED 
     
    97100   if (user_png_ver) 
    98101   { 
    99      i = 0; 
    100      do 
    101      { 
    102        if (user_png_ver[i] != png_libpng_ver[i]) 
    103           png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 
    104      } while (png_libpng_ver[i++]); 
    105    } 
    106    else 
    107         png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 
    108  
    109  
    110    if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) 
    111    { 
    112      /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so 
    113       * we must recompile any applications that use any older library version. 
    114       * For versions after libpng 1.0, we will be compatible, so we need 
    115       * only check the first digit. 
    116       */ 
    117      if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || 
    118          (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || 
    119          (user_png_ver[0] == '0' && user_png_ver[2] < '9')) 
    120      { 
    121 #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) 
    122         char msg[80]; 
    123         if (user_png_ver) 
    124         { 
    125           png_snprintf(msg, 80, 
    126              "Application was compiled with png.h from libpng-%.20s", 
    127              user_png_ver); 
    128           png_warning(png_ptr, msg); 
    129         } 
    130         png_snprintf(msg, 80, 
     102      i = 0; 
     103      do 
     104      { 
     105         if (user_png_ver[i] != png_libpng_ver[i]) 
     106            png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 
     107      } while (png_libpng_ver[i++]); 
     108    } 
     109    else 
     110         png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 
     111 
     112 
     113    if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) 
     114    { 
     115       /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so 
     116       * we must recompile any applications that use any older library version. 
     117       * For versions after libpng 1.0, we will be compatible, so we need 
     118       * only check the first digit. 
     119       */ 
     120      if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || 
     121          (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || 
     122          (user_png_ver[0] == '0' && user_png_ver[2] < '9')) 
     123      { 
     124#if defined(PNG_STDIO_SUPPORTED) && !defined(_WIN32_WCE) 
     125         char msg[80]; 
     126         if (user_png_ver) 
     127         { 
     128           png_snprintf(msg, 80, 
     129              "Application was compiled with png.h from libpng-%.20s", 
     130              user_png_ver); 
     131           png_warning(png_ptr, msg); 
     132         } 
     133         png_snprintf(msg, 80, 
    131134             "Application  is  running with png.c from libpng-%.20s", 
    132            png_libpng_ver); 
    133         png_warning(png_ptr, msg); 
     135             png_libpng_ver); 
     136         png_warning(png_ptr, msg); 
    134137#endif 
    135138#ifdef PNG_ERROR_NUMBERS_SUPPORTED 
    136         png_ptr->flags = 0; 
    137 #endif 
    138         png_error(png_ptr, 
    139            "Incompatible libpng version in application and library"); 
    140      } 
     139         png_ptr->flags = 0; 
     140#endif 
     141         png_error(png_ptr, 
     142            "Incompatible libpng version in application and library"); 
     143      } 
    141144   } 
    142145 
     
    149152   png_ptr->zstream.opaque = (voidpf)png_ptr; 
    150153 
    151    switch (inflateInit(&png_ptr->zstream)) 
    152    { 
    153      case Z_OK: /* Do nothing */ break; 
    154      case Z_MEM_ERROR: 
    155      case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; 
    156      case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; 
    157      default: png_error(png_ptr, "Unknown zlib error"); 
    158    } 
     154      switch (inflateInit(&png_ptr->zstream)) 
     155      { 
     156         case Z_OK: /* Do nothing */ break; 
     157         case Z_MEM_ERROR: 
     158         case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); 
     159            break; 
     160         case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); 
     161            break; 
     162         default: png_error(png_ptr, "Unknown zlib error"); 
     163      } 
     164 
    159165 
    160166   png_ptr->zstream.next_out = png_ptr->zbuf; 
     
    164170 
    165171#ifdef PNG_SETJMP_SUPPORTED 
    166 /* Applications that neglect to set up their own setjmp() and then encounter 
    167    a png_error() will longjmp here.  Since the jmpbuf is then meaningless we 
    168    abort instead of returning. */ 
     172/* Applications that neglect to set up their own setjmp() and then 
     173   encounter a png_error() will longjmp here.  Since the jmpbuf is 
     174   then meaningless we abort instead of returning. */ 
    169175#ifdef USE_FAR_KEYWORD 
    170176   if (setjmp(jmpbuf)) 
    171       PNG_ABORT(); 
     177       PNG_ABORT(); 
    172178   png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); 
    173179#else 
    174180   if (setjmp(png_ptr->jmpbuf)) 
    175       PNG_ABORT(); 
    176 #endif 
    177 #endif 
     181       PNG_ABORT(); 
     182#endif 
     183#endif /* PNG_SETJMP_SUPPORTED */ 
     184 
    178185   return (png_ptr); 
    179186} 
     
    181188#if defined(PNG_1_0_X) || defined(PNG_1_2_X) 
    182189/* Initialize PNG structure for reading, and allocate any memory needed. 
    183    This interface is deprecated in favour of the png_create_read_struct(), 
    184    and it will disappear as of libpng-1.3.0. */ 
     190 * This interface is deprecated in favour of the png_create_read_struct(), 
     191 * and it will disappear as of libpng-1.3.0. 
     192 */ 
    185193#undef png_read_init 
    186194void PNGAPI 
     
    198206   if (png_ptr == NULL) 
    199207      return; 
    200 #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) 
     208#if defined(PNG_STDIO_SUPPORTED) && !defined(_WIN32_WCE) 
    201209   if (png_sizeof(png_struct) > png_struct_size || 
    202210      png_sizeof(png_info) > png_info_size) 
     
    218226#endif 
    219227   if (png_sizeof(png_struct) > png_struct_size) 
    220      { 
    221        png_ptr->error_fn = NULL; 
     228   { 
     229      png_ptr->error_fn = NULL; 
    222230#ifdef PNG_ERROR_NUMBERS_SUPPORTED 
    223        png_ptr->flags = 0; 
    224 #endif 
    225        png_error(png_ptr, 
    226        "The png struct allocated by the application for reading is too small."); 
    227      } 
     231      png_ptr->flags = 0; 
     232#endif 
     233      png_error(png_ptr, 
     234      "The png struct allocated by the application for reading is too small."); 
     235   } 
    228236   if (png_sizeof(png_info) > png_info_size) 
    229      { 
    230        png_ptr->error_fn = NULL; 
     237   { 
     238      png_ptr->error_fn = NULL; 
    231239#ifdef PNG_ERROR_NUMBERS_SUPPORTED 
    232        png_ptr->flags = 0; 
    233 #endif 
    234        png_error(png_ptr, 
    235          "The info struct allocated by application for reading is too small."); 
    236      } 
     240      png_ptr->flags = 0; 
     241#endif 
     242      png_error(png_ptr, 
     243        "The info struct allocated by application for reading is too small."); 
     244   } 
    237245   png_read_init_3(&png_ptr, user_png_ver, png_struct_size); 
    238246} 
     
    256264   do 
    257265   { 
    258      if (user_png_ver[i] != png_libpng_ver[i]) 
    259      { 
     266      if (user_png_ver[i] != png_libpng_ver[i]) 
     267      { 
    260268#ifdef PNG_LEGACY_SUPPORTED 
    261        png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 
     269        png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 
    262270#else 
    263        png_ptr->warning_fn = NULL; 
    264        png_warning(png_ptr, 
    265         "Application uses deprecated png_read_init() and should be recompiled."); 
    266        break; 
    267 #endif 
    268      } 
     271        png_ptr->warning_fn = NULL; 
     272        png_warning(png_ptr, 
     273         "Application uses deprecated png_read_init() and should be recompiled."); 
     274        break; 
     275#endif 
     276      } 
    269277   } while (png_libpng_ver[i++]); 
    270278 
     
    293301   /* Added at libpng-1.2.6 */ 
    294302#ifdef PNG_SET_USER_LIMITS_SUPPORTED 
    295    png_ptr->user_width_max=PNG_USER_WIDTH_MAX; 
    296    png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; 
     303   png_ptr->user_width_max = PNG_USER_WIDTH_MAX; 
     304   png_ptr->user_height_max = PNG_USER_HEIGHT_MAX; 
    297305#endif 
    298306 
    299307   /* Initialize zbuf - compression buffer */ 
    300308   png_ptr->zbuf_size = PNG_ZBUF_SIZE; 
     309   png_ptr->zstream.zalloc = png_zalloc; 
    301310   png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, 
    302311     (png_uint_32)png_ptr->zbuf_size); 
     
    307316   switch (inflateInit(&png_ptr->zstream)) 
    308317   { 
    309      case Z_OK: /* Do nothing */ break; 
    310      case Z_MEM_ERROR: 
    311      case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; 
    312      case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; 
    313      default: png_error(png_ptr, "Unknown zlib error"); 
     318      case Z_OK: /* Do nothing */ break; 
     319      case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; 
     320      case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; 
     321      default: png_error(png_ptr, "Unknown zlib error"); 
    314322   } 
    315323 
     
    320328} 
    321329 
    322 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 
     330#ifdef PNG_SEQUENTIAL_READ_SUPPORTED 
    323331/* Read the information before the actual image data.  This has been 
    324332 * changed in v0.90 to allow reading a file that already has the magic 
     
    332340png_read_info(png_structp png_ptr, png_infop info_ptr) 
    333341{ 
     342   png_debug(1, "in png_read_info"); 
     343  
    334344   if (png_ptr == NULL || info_ptr == NULL) 
    335345      return; 
    336    png_debug(1, "in png_read_info"); 
     346  
    337347   /* If we haven't checked all of the PNG signature bytes, do so now. */ 
    338348   if (png_ptr->sig_bytes < 8) 
     
    363373      PNG_CONST PNG_IEND; 
    364374      PNG_CONST PNG_PLTE; 
    365 #if defined(PNG_READ_bKGD_SUPPORTED) 
     375#ifdef PNG_READ_bKGD_SUPPORTED 
    366376      PNG_CONST PNG_bKGD; 
    367377#endif 
    368 #if defined(PNG_READ_cHRM_SUPPORTED) 
     378#ifdef PNG_READ_cHRM_SUPPORTED 
    369379      PNG_CONST PNG_cHRM; 
    370380#endif 
    371 #if defined(PNG_READ_gAMA_SUPPORTED) 
     381#ifdef PNG_READ_gAMA_SUPPORTED 
    372382      PNG_CONST PNG_gAMA; 
    373383#endif 
    374 #if defined(PNG_READ_hIST_SUPPORTED) 
     384#ifdef PNG_READ_hIST_SUPPORTED 
    375385      PNG_CONST PNG_hIST; 
    376386#endif 
    377 #if defined(PNG_READ_iCCP_SUPPORTED) 
     387#ifdef PNG_READ_iCCP_SUPPORTED 
    378388      PNG_CONST PNG_iCCP; 
    379389#endif 
    380 #if defined(PNG_READ_iTXt_SUPPORTED) 
     390#ifdef PNG_READ_iTXt_SUPPORTED 
    381391      PNG_CONST PNG_iTXt; 
    382392#endif 
    383 #if defined(PNG_READ_oFFs_SUPPORTED) 
     393#ifdef PNG_READ_oFFs_SUPPORTED 
    384394      PNG_CONST PNG_oFFs; 
    385395#endif 
    386 #if defined(PNG_READ_pCAL_SUPPORTED) 
     396#ifdef PNG_READ_pCAL_SUPPORTED 
    387397      PNG_CONST PNG_pCAL; 
    388398#endif 
    389 #if defined(PNG_READ_pHYs_SUPPORTED) 
     399#ifdef PNG_READ_pHYs_SUPPORTED 
    390400      PNG_CONST PNG_pHYs; 
    391401#endif 
    392 #if defined(PNG_READ_sBIT_SUPPORTED) 
     402#ifdef PNG_READ_sBIT_SUPPORTED 
    393403      PNG_CONST PNG_sBIT; 
    394404#endif 
    395 #if defined(PNG_READ_sCAL_SUPPORTED) 
     405#ifdef PNG_READ_sCAL_SUPPORTED 
    396406      PNG_CONST PNG_sCAL; 
    397407#endif 
    398 #if defined(PNG_READ_sPLT_SUPPORTED) 
     408#ifdef PNG_READ_sPLT_SUPPORTED 
    399409      PNG_CONST PNG_sPLT; 
    400410#endif 
    401 #if defined(PNG_READ_sRGB_SUPPORTED) 
     411#ifdef PNG_READ_sRGB_SUPPORTED 
    402412      PNG_CONST PNG_sRGB; 
    403413#endif 
    404 #if defined(PNG_READ_tEXt_SUPPORTED) 
     414#ifdef PNG_READ_tEXt_SUPPORTED 
    405415      PNG_CONST PNG_tEXt; 
    406416#endif 
    407 #if defined(PNG_READ_tIME_SUPPORTED) 
     417#ifdef PNG_READ_tIME_SUPPORTED 
    408418      PNG_CONST PNG_tIME; 
    409419#endif 
    410 #if defined(PNG_READ_tRNS_SUPPORTED) 
     420#ifdef PNG_READ_tRNS_SUPPORTED 
    411421      PNG_CONST PNG_tRNS; 
    412422#endif 
    413 #if defined(PNG_READ_zTXt_SUPPORTED) 
     423#ifdef PNG_READ_zTXt_SUPPORTED 
    414424      PNG_CONST PNG_zTXt; 
    415425#endif 
     
    462472         break; 
    463473      } 
    464 #if defined(PNG_READ_bKGD_SUPPORTED) 
     474#ifdef PNG_READ_bKGD_SUPPORTED 
    465475      else if (!png_memcmp(chunk_name, png_bKGD, 4)) 
    466476         png_handle_bKGD(png_ptr, info_ptr, length); 
    467477#endif 
    468 #if defined(PNG_READ_cHRM_SUPPORTED) 
     478#ifdef PNG_READ_cHRM_SUPPORTED 
    469479      else if (!png_memcmp(chunk_name, png_cHRM, 4)) 
    470480         png_handle_cHRM(png_ptr, info_ptr, length); 
    471481#endif 
    472 #if defined(PNG_READ_gAMA_SUPPORTED) 
     482#ifdef PNG_READ_gAMA_SUPPORTED 
    473483      else if (!png_memcmp(chunk_name, png_gAMA, 4)) 
    474484         png_handle_gAMA(png_ptr, info_ptr, length); 
    475485#endif 
    476 #if defined(PNG_READ_hIST_SUPPORTED) 
     486#ifdef PNG_READ_hIST_SUPPORTED 
    477487      else if (!png_memcmp(chunk_name, png_hIST, 4)) 
    478488         png_handle_hIST(png_ptr, info_ptr, length); 
    479489#endif 
    480 #if defined(PNG_READ_oFFs_SUPPORTED) 
     490#ifdef PNG_READ_oFFs_SUPPORTED 
    481491      else if (!png_memcmp(chunk_name, png_oFFs, 4)) 
    482492         png_handle_oFFs(png_ptr, info_ptr, length); 
    483493#endif 
    484 #if defined(PNG_READ_pCAL_SUPPORTED) 
     494#ifdef PNG_READ_pCAL_SUPPORTED 
    485495      else if (!png_memcmp(chunk_name, png_pCAL, 4)) 
    486496         png_handle_pCAL(png_ptr, info_ptr, length); 
    487497#endif 
    488 #if defined(PNG_READ_sCAL_SUPPORTED) 
     498#ifdef PNG_READ_sCAL_SUPPORTED 
    489499      else if (!png_memcmp(chunk_name, png_sCAL, 4)) 
    490500         png_handle_sCAL(png_ptr, info_ptr, length); 
    491501#endif 
    492 #if defined(PNG_READ_pHYs_SUPPORTED) 
     502#ifdef PNG_READ_pHYs_SUPPORTED 
    493503      else if (!png_memcmp(chunk_name, png_pHYs, 4)) 
    494504         png_handle_pHYs(png_ptr, info_ptr, length); 
    495505#endif 
    496 #if defined(PNG_READ_sBIT_SUPPORTED) 
     506#ifdef PNG_READ_sBIT_SUPPORTED 
    497507      else if (!png_memcmp(chunk_name, png_sBIT, 4)) 
    498508         png_handle_sBIT(png_ptr, info_ptr, length); 
    499509#endif 
    500 #if defined(PNG_READ_sRGB_SUPPORTED) 
     510#ifdef PNG_READ_sRGB_SUPPORTED 
    501511      else if (!png_memcmp(chunk_name, png_sRGB, 4)) 
    502512         png_handle_sRGB(png_ptr, info_ptr, length); 
    503513#endif 
    504 #if defined(PNG_READ_iCCP_SUPPORTED) 
     514#ifdef PNG_READ_iCCP_SUPPORTED 
    505515      else if (!png_memcmp(chunk_name, png_iCCP, 4)) 
    506516         png_handle_iCCP(png_ptr, info_ptr, length); 
    507517#endif 
    508 #if defined(PNG_READ_sPLT_SUPPORTED) 
     518#ifdef PNG_READ_sPLT_SUPPORTED 
    509519      else if (!png_memcmp(chunk_name, png_sPLT, 4)) 
    510520         png_handle_sPLT(png_ptr, info_ptr, length); 
    511521#endif 
    512 #if defined(PNG_READ_tEXt_SUPPORTED) 
     522#ifdef PNG_READ_tEXt_SUPPORTED 
    513523      else if (!png_memcmp(chunk_name, png_tEXt, 4)) 
    514524         png_handle_tEXt(png_ptr, info_ptr, length); 
    515525#endif 
    516 #if defined(PNG_READ_tIME_SUPPORTED) 
     526#ifdef PNG_READ_tIME_SUPPORTED 
    517527      else if (!png_memcmp(chunk_name, png_tIME, 4)) 
    518528         png_handle_tIME(png_ptr, info_ptr, length); 
    519529#endif 
    520 #if defined(PNG_READ_tRNS_SUPPORTED) 
     530#ifdef PNG_READ_tRNS_SUPPORTED 
    521531      else if (!png_memcmp(chunk_name, png_tRNS, 4)) 
    522532         png_handle_tRNS(png_ptr, info_ptr, length); 
    523533#endif 
    524 #if defined(PNG_READ_zTXt_SUPPORTED) 
     534#ifdef PNG_READ_zTXt_SUPPORTED 
    525535      else if (!png_memcmp(chunk_name, png_zTXt, 4)) 
    526536         png_handle_zTXt(png_ptr, info_ptr, length); 
    527537#endif 
    528 #if defined(PNG_READ_iTXt_SUPPORTED) 
     538#ifdef PNG_READ_iTXt_SUPPORTED 
    529539      else if (!png_memcmp(chunk_name, png_iTXt, 4)) 
    530540         png_handle_iTXt(png_ptr, info_ptr, length); 
     
    534544   } 
    535545} 
    536 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 
     546#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ 
    537547 
    538548/* Optional call to update the users info_ptr structure */ 
     
    541551{ 
    542552   png_debug(1, "in png_read_update_info"); 
     553  
    543554   if (png_ptr == NULL) 
    544555      return; 
     
    548559      png_warning(png_ptr, 
    549560      "Ignoring extra png_read_update_info() call; row buffer not reallocated"); 
     561 
    550562   png_read_transform_info(png_ptr, info_ptr); 
    551563} 
    552564 
    553 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 
     565#ifdef PNG_SEQUENTIAL_READ_SUPPORTED 
    554566/* Initialize palette, background, etc, after transformations 
    555567 * are set, but before any reading takes place.  This allows 
     
    561573{ 
    562574   png_debug(1, "in png_start_read_image"); 
     575  
    563576   if (png_ptr == NULL) 
    564577      return; 
     
    566579      png_read_start_row(png_ptr); 
    567580} 
    568 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 
    569  
    570 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 
     581#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ 
     582 
     583#ifdef PNG_SEQUENTIAL_READ_SUPPORTED 
    571584void PNGAPI 
    572585png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) 
    573586{ 
    574 #ifdef PNG_USE_LOCAL_ARRAYS 
    575587   PNG_CONST PNG_IDAT; 
    576588   PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 
    577589      0xff}; 
    578590   PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; 
    579 #endif 
    580591   int ret; 
     592  
    581593   if (png_ptr == NULL) 
    582594      return; 
     595  
    583596   png_debug2(1, "in png_read_row (row %lu, pass %d)", 
    584597      png_ptr->row_number, png_ptr->pass); 
     598 
    585599   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) 
    586600      png_read_start_row(png_ptr); 
     
    618632   } 
    619633 
    620 #if defined(PNG_READ_INTERLACING_SUPPORTED) 
     634#ifdef PNG_READ_INTERLACING_SUPPORTED 
    621635   /* If interlaced and we do not need a new row, combine row and return */ 
    622636   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) 
     
    752766      png_ptr->rowbytes + 1); 
    753767 
    754 #if defined(PNG_MNG_FEATURES_SUPPORTED) 
     768#ifdef PNG_MNG_FEATURES_SUPPORTED 
    755769   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && 
    756770      (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) 
     
    765779      png_do_read_transformations(png_ptr); 
    766780 
    767 #if defined(PNG_READ_INTERLACING_SUPPORTED) 
     781#ifdef PNG_READ_INTERLACING_SUPPORTED 
    768782   /* Blow up interlaced rows to full size */ 
    769783   if (png_ptr->interlaced && 
     
    797811      (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); 
    798812} 
    799 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 
    800  
    801 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 
     813#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ 
     814 
     815#ifdef PNG_SEQUENTIAL_READ_SUPPORTED 
    802816/* Read one or more rows of image data.  If the image is interlaced, 
    803817 * and png_set_interlace_handling() has been called, the rows need to 
     
    833847 
    834848   png_debug(1, "in png_read_rows"); 
     849  
    835850   if (png_ptr == NULL) 
    836851      return; 
     
    860875      } 
    861876} 
    862 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 
    863  
    864 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 
     877#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ 
     878 
     879#ifdef PNG_SEQUENTIAL_READ_SUPPORTED 
    865880/* Read the entire image.  If the image has an alpha channel or a tRNS 
    866881 * chunk, and you have called png_handle_alpha()[*], you will need to 
     
    883898 
    884899   png_debug(1, "in png_read_image"); 
     900  
    885901   if (png_ptr == NULL) 
    886902      return; 
     
    909925   } 
    910926} 
    911 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 
    912  
    913 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 
     927#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ 
     928 
     929#ifdef PNG_SEQUENTIAL_READ_SUPPORTED 
    914930/* Read the end of the PNG file.  Will not read past the end of the 
    915931 * file, will verify the end is accurate, and will read any comments 
     
    920936{ 
    921937   png_debug(1, "in png_read_end"); 
     938  
    922939   if (png_ptr == NULL) 
    923940      return; 
     
    931948      PNG_CONST PNG_IEND; 
    932949      PNG_CONST PNG_PLTE; 
    933 #if defined(PNG_READ_bKGD_SUPPORTED) 
     950#ifdef PNG_READ_bKGD_SUPPORTED 
    934951      PNG_CONST PNG_bKGD; 
    935952#endif 
    936 #if defined(PNG_READ_cHRM_SUPPORTED) 
     953#ifdef PNG_READ_cHRM_SUPPORTED 
    937954      PNG_CONST PNG_cHRM; 
    938955#endif 
    939 #if defined(PNG_READ_gAMA_SUPPORTED) 
     956#ifdef PNG_READ_gAMA_SUPPORTED 
    940957      PNG_CONST PNG_gAMA; 
    941958#endif 
    942 #if defined(PNG_READ_hIST_SUPPORTED) 
     959#ifdef PNG_READ_hIST_SUPPORTED 
    943960      PNG_CONST PNG_hIST; 
    944961#endif 
    945 #if defined(PNG_READ_iCCP_SUPPORTED) 
     962#ifdef PNG_READ_iCCP_SUPPORTED 
    946963      PNG_CONST PNG_iCCP; 
    947964#endif 
    948 #if defined(PNG_READ_iTXt_SUPPORTED) 
     965#ifdef PNG_READ_iTXt_SUPPORTED 
    949966      PNG_CONST PNG_iTXt; 
    950967#endif 
    951 #if defined(PNG_READ_oFFs_SUPPORTED) 
     968#ifdef PNG_READ_oFFs_SUPPORTED 
    952969      PNG_CONST PNG_oFFs; 
    953970#endif 
    954 #if defined(PNG_READ_pCAL_SUPPORTED) 
     971#ifdef PNG_READ_pCAL_SUPPORTED 
    955972      PNG_CONST PNG_pCAL; 
    956973#endif 
    957 #if defined(PNG_READ_pHYs_SUPPORTED) 
     974#ifdef PNG_READ_pHYs_SUPPORTED 
    958975      PNG_CONST PNG_pHYs; 
    959976#endif 
    960 #if defined(PNG_READ_sBIT_SUPPORTED) 
     977#ifdef PNG_READ_sBIT_SUPPORTED 
    961978      PNG_CONST PNG_sBIT; 
    962979#endif 
    963 #if defined(PNG_READ_sCAL_SUPPORTED) 
     980#ifdef PNG_READ_sCAL_SUPPORTED 
    964981      PNG_CONST PNG_sCAL; 
    965982#endif 
    966 #if defined(PNG_READ_sPLT_SUPPORTED) 
     983#ifdef PNG_READ_sPLT_SUPPORTED 
    967984      PNG_CONST PNG_sPLT; 
    968985#endif 
    969 #if defined(PNG_READ_sRGB_SUPPORTED) 
     986#ifdef PNG_READ_sRGB_SUPPORTED 
    970987      PNG_CONST PNG_sRGB; 
    971988#endif 
    972 #if defined(PNG_READ_tEXt_SUPPORTED) 
     989#ifdef PNG_READ_tEXt_SUPPORTED 
    973990      PNG_CONST PNG_tEXt; 
    974991#endif 
    975 #if defined(PNG_READ_tIME_SUPPORTED) 
     992#ifdef PNG_READ_tIME_SUPPORTED 
    976993      PNG_CONST PNG_tIME; 
    977994#endif 
    978 #if defined(PNG_READ_tRNS_SUPPORTED) 
     995#ifdef PNG_READ_tRNS_SUPPORTED 
    979996      PNG_CONST PNG_tRNS; 
    980997#endif 
    981 #if defined(PNG_READ_zTXt_SUPPORTED) 
     998#ifdef PNG_READ_zTXt_SUPPORTED 
    982999      PNG_CONST PNG_zTXt; 
    9831000#endif 
     
    10141031      else if (!png_memcmp(chunk_name, png_PLTE, 4)) 
    10151032         png_handle_PLTE(png_ptr, info_ptr, length); 
    1016 #if defined(PNG_READ_bKGD_SUPPORTED) 
     1033#ifdef PNG_READ_bKGD_SUPPORTED 
    10171034      else if (!png_memcmp(chunk_name, png_bKGD, 4)) 
    10181035         png_handle_bKGD(png_ptr, info_ptr, length); 
    10191036#endif 
    1020 #if defined(PNG_READ_cHRM_SUPPORTED) 
     1037#ifdef PNG_READ_cHRM_SUPPORTED 
    10211038      else if (!png_memcmp(chunk_name, png_cHRM, 4)) 
    10221039         png_handle_cHRM(png_ptr, info_ptr, length); 
    10231040#endif 
    1024 #if defined(PNG_READ_gAMA_SUPPORTED) 
     1041#ifdef PNG_READ_gAMA_SUPPORTED 
    10251042      else if (!png_memcmp(chunk_name, png_gAMA, 4)) 
    10261043         png_handle_gAMA(png_ptr, info_ptr, length); 
    10271044#endif 
    1028 #if defined(PNG_READ_hIST_SUPPORTED) 
     1045#ifdef PNG_READ_hIST_SUPPORTED 
    10291046      else if (!png_memcmp(chunk_name, png_hIST, 4)) 
    10301047         png_handle_hIST(png_ptr, info_ptr, length); 
    10311048#endif 
    1032 #if defined(PNG_READ_oFFs_SUPPORTED) 
     1049#ifdef PNG_READ_oFFs_SUPPORTED 
    10331050      else if (!png_memcmp(chunk_name, png_oFFs, 4)) 
    10341051         png_handle_oFFs(png_ptr, info_ptr, length); 
    10351052#endif 
    1036 #if defined(PNG_READ_pCAL_SUPPORTED) 
     1053#ifdef PNG_READ_pCAL_SUPPORTED 
    10371054      else if (!png_memcmp(chunk_name, png_pCAL, 4)) 
    10381055         png_handle_pCAL(png_ptr, info_ptr, length); 
    10391056#endif 
    1040 #if defined(PNG_READ_sCAL_SUPPORTED) 
     1057#ifdef PNG_READ_sCAL_SUPPORTED 
    10411058      else if (!png_memcmp(chunk_name, png_sCAL, 4)) 
    10421059         png_handle_sCAL(png_ptr, info_ptr, length); 
    10431060#endif 
    1044 #if defined(PNG_READ_pHYs_SUPPORTED) 
     1061#ifdef PNG_READ_pHYs_SUPPORTED 
    10451062      else if (!png_memcmp(chunk_name, png_pHYs, 4)) 
    10461063         png_handle_pHYs(png_ptr, info_ptr, length); 
    10471064#endif 
    1048 #if defined(PNG_READ_sBIT_SUPPORTED) 
     1065#ifdef PNG_READ_sBIT_SUPPORTED 
    10491066      else if (!png_memcmp(chunk_name, png_sBIT, 4)) 
    10501067         png_handle_sBIT(png_ptr, info_ptr, length); 
    10511068#endif 
    1052 #if defined(PNG_READ_sRGB_SUPPORTED) 
     1069#ifdef PNG_READ_sRGB_SUPPORTED 
    10531070      else if (!png_memcmp(chunk_name, png_sRGB, 4)) 
    10541071         png_handle_sRGB(png_ptr, info_ptr, length); 
    10551072#endif 
    1056 #if defined(PNG_READ_iCCP_SUPPORTED) 
     1073#ifdef PNG_READ_iCCP_SUPPORTED 
    10571074      else if (!png_memcmp(chunk_name, png_iCCP, 4)) 
    10581075         png_handle_iCCP(png_ptr, info_ptr, length); 
    10591076#endif 
    1060 #if defined(PNG_READ_sPLT_SUPPORTED) 
     1077#ifdef PNG_READ_sPLT_SUPPORTED 
    10611078      else if (!png_memcmp(chunk_name, png_sPLT, 4)) 
    10621079         png_handle_sPLT(png_ptr, info_ptr, length); 
    10631080#endif 
    1064 #if defined(PNG_READ_tEXt_SUPPORTED) 
     1081#ifdef PNG_READ_tEXt_SUPPORTED 
    10651082      else if (!png_memcmp(chunk_name, png_tEXt, 4)) 
    10661083         png_handle_tEXt(png_ptr, info_ptr, length); 
    10671084#endif 
    1068 #if defined(PNG_READ_tIME_SUPPORTED) 
     1085#ifdef PNG_READ_tIME_SUPPORTED 
    10691086      else if (!png_memcmp(chunk_name, png_tIME, 4)) 
    10701087         png_handle_tIME(png_ptr, info_ptr, length); 
    10711088#endif 
    1072 #if defined(PNG_READ_tRNS_SUPPORTED) 
     1089#ifdef PNG_READ_tRNS_SUPPORTED 
    10731090      else if (!png_memcmp(chunk_name, png_tRNS, 4)) 
    10741091         png_handle_tRNS(png_ptr, info_ptr, length); 
    10751092#endif 
    1076 #if defined(PNG_READ_zTXt_SUPPORTED) 
     1093#ifdef PNG_READ_zTXt_SUPPORTED 
    10771094      else if (!png_memcmp(chunk_name, png_zTXt, 4)) 
    10781095         png_handle_zTXt(png_ptr, info_ptr, length); 
    10791096#endif 
    1080 #if defined(PNG_READ_iTXt_SUPPORTED) 
     1097#ifdef PNG_READ_iTXt_SUPPORTED 
    10811098      else if (!png_memcmp(chunk_name, png_iTXt, 4)) 
    10821099         png_handle_iTXt(png_ptr, info_ptr, length); 
     
    10861103   } while (!(png_ptr->mode & PNG_HAVE_IEND)); 
    10871104} 
    1088 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 
     1105#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ 
    10891106 
    10901107/* Free all memory used by the read */ 
     
    11011118 
    11021119   png_debug(1, "in png_destroy_read_struct"); 
     1120  
    11031121   if (png_ptr_ptr != NULL) 
    11041122      png_ptr = *png_ptr_ptr; 
     
    11211139   if (info_ptr != NULL) 
    11221140   { 
    1123 #if defined(PNG_TEXT_SUPPORTED) 
     1141#ifdef PNG_TEXT_SUPPORTED 
    11241142      png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); 
    11251143#endif 
     
    11361154   if (end_info_ptr != NULL) 
    11371155   { 
    1138 #if defined(PNG_READ_TEXT_SUPPORTED) 
     1156#ifdef PNG_READ_TEXT_SUPPORTED 
    11391157      png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); 
    11401158#endif 
     
    11751193 
    11761194   png_debug(1, "in png_read_destroy"); 
     1195  
    11771196   if (info_ptr != NULL) 
    11781197      png_info_destroy(png_ptr, info_ptr); 
     
    11851204   png_free(png_ptr, png_ptr->prev_row); 
    11861205   png_free(png_ptr, png_ptr->chunkdata); 
    1187 #if defined(PNG_READ_DITHER_SUPPORTED) 
     1206#ifdef PNG_READ_DITHER_SUPPORTED 
    11881207   png_free(png_ptr, png_ptr->palette_lookup); 
    11891208   png_free(png_ptr, png_ptr->dither_index); 
    11901209#endif 
    1191 #if defined(PNG_READ_GAMMA_SUPPORTED) 
     1210#ifdef PNG_READ_GAMMA_SUPPORTED 
    11921211   png_free(png_ptr, png_ptr->gamma_table); 
    11931212#endif 
    1194 #if defined(PNG_READ_BACKGROUND_SUPPORTED) 
     1213#ifdef PNG_READ_BACKGROUND_SUPPORTED 
    11951214   png_free(png_ptr, png_ptr->gamma_from_1); 
    11961215   png_free(png_ptr, png_ptr->gamma_to_1); 
     
    12171236#endif 
    12181237#endif 
    1219 #if defined(PNG_READ_hIST_SUPPORTED) 
     1238#ifdef PNG_READ_hIST_SUPPORTED 
    12201239#ifdef PNG_FREE_ME_SUPPORTED 
    12211240   if (png_ptr->free_me & PNG_FREE_HIST) 
     
    12281247#endif 
    12291248#endif 
    1230 #if defined(PNG_READ_GAMMA_SUPPORTED) 
     1249#ifdef PNG_READ_GAMMA_SUPPORTED 
    12311250   if (png_ptr->gamma_16_table != NULL) 
    12321251   { 
     
    12391258   png_free(png_ptr, png_ptr->gamma_16_table); 
    12401259   } 
    1241 #if defined(PNG_READ_BACKGROUND_SUPPORTED) 
     1260#ifdef PNG_READ_BACKGROUND_SUPPORTED 
    12421261   if (png_ptr->gamma_16_from_1 != NULL) 
    12431262   { 
     
    12621281#endif 
    12631282#endif 
    1264 #if defined(PNG_TIME_RFC1123_SUPPORTED) 
     1283#ifdef PNG_TIME_RFC1123_SUPPORTED 
    12651284   png_free(png_ptr, png_ptr->time_buffer); 
    12661285#endif 
     
    13151334 
    13161335 
    1317 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 
    1318 #if defined(PNG_INFO_IMAGE_SUPPORTED) 
     1336#ifdef PNG_SEQUENTIAL_READ_SUPPORTED 
     1337#ifdef PNG_INFO_IMAGE_SUPPORTED 
    13191338void PNGAPI 
    13201339png_read_png(png_structp png_ptr, png_infop info_ptr, 
     
    13261345   if (png_ptr == NULL) 
    13271346      return; 
    1328 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) 
     1347#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED 
    13291348   /* Invert the alpha channel from opacity to transparency 
    13301349    */ 
     
    13421361   /* -------------- image transformations start here ------------------- */ 
    13431362 
    1344 #if defined(PNG_READ_16_TO_8_SUPPORTED) 
     1363#ifdef PNG_READ_16_TO_8_SUPPORTED 
    13451364   /* Tell libpng to strip 16 bit/color files down to 8 bits per color. 
    13461365    */ 
     
    13491368#endif 
    13501369 
    1351 #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) 
     1370#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED 
    13521371   /* Strip alpha bytes from the input data without combining with 
    13531372    * the background (not recommended). 
     
    13651384#endif 
    13661385 
    1367 #if defined(PNG_READ_PACKSWAP_SUPPORTED) 
     1386#ifdef PNG_READ_PACKSWAP_SUPPORTED 
    13681387   /* Change the order of packed pixels to least significant bit first 
    13691388    * (not useful if you are using png_set_packing). 
     
    13731392#endif 
    13741393 
    1375 #if defined(PNG_READ_EXPAND_SUPPORTED) 
     1394#ifdef PNG_READ_EXPAND_SUPPORTED 
    13761395   /* Expand paletted colors into true RGB triplets 
    13771396    * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel 
     
    13891408    */ 
    13901409 
    1391 #if defined(PNG_READ_INVERT_SUPPORTED) 
     1410#ifdef PNG_READ_INVERT_SUPPORTED 
    13921411   /* Invert monochrome files to have 0 as white and 1 as black 
    13931412    */ 
     
    13961415#endif 
    13971416 
    1398 #if defined(PNG_READ_SHIFT_SUPPORTED) 
     1417#ifdef PNG_READ_SHIFT_SUPPORTED 
    13991418   /* If you want to shift the pixel values from the range [0,255] or 
    14001419    * [0,65535] to the original [0,7] or [0,31], or whatever range the 
     
    14111430#endif 
    14121431 
    1413 #if defined(PNG_READ_BGR_SUPPORTED) 
     1432#ifdef PNG_READ_BGR_SUPPORTED 
    14141433   /* Flip the RGB pixels to BGR (or RGBA to BGRA) 
    14151434    */ 
     
    14181437#endif 
    14191438 
    1420 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) 
     1439#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED 
    14211440   /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) 
    14221441    */ 
     
    14251444#endif 
    14261445 
    1427 #if defined(PNG_READ_SWAP_SUPPORTED) 
     1446#ifdef PNG_READ_SWAP_SUPPORTED 
    14281447   /* Swap bytes of 16 bit files to least significant byte first 
    14291448    */ 
    14301449   if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) 
    14311450      png_set_swap(png_ptr); 
     1451#endif 
     1452 
     1453/* Added at libpng-1.2.41 */ 
     1454#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED 
     1455   /* Invert the alpha channel from opacity to transparency 
     1456    */ 
     1457   if (transforms & PNG_TRANSFORM_INVERT_ALPHA) 
     1458       png_set_invert_alpha(png_ptr); 
     1459#endif 
     1460 
     1461/* Added at libpng-1.2.41 */ 
     1462#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 
     1463   /* Expand grayscale image to RGB 
     1464    */ 
     1465   if (transforms & PNG_TRANSFORM_GRAY_TO_RGB) 
     1466       png_set_gray_to_rgb(png_ptr); 
    14321467#endif 
    14331468 
     
    14511486      png_memset(info_ptr->row_pointers, 0, info_ptr->height 
    14521487         * png_sizeof(png_bytep)); 
     1488 
    14531489#ifdef PNG_FREE_ME_SUPPORTED 
    14541490      info_ptr->free_me |= PNG_FREE_ROWS; 
    14551491#endif 
     1492 
    14561493      for (row = 0; row < (int)info_ptr->height; row++) 
    14571494         info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, 
     
    14701507} 
    14711508#endif /* PNG_INFO_IMAGE_SUPPORTED */ 
    1472 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 
     1509#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ 
    14731510#endif /* PNG_READ_SUPPORTED */