Changeset 43 for vendor/libpng/pngget.c

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

Upgraded vendor/libpng from 1.2.40 to 1.2.42.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vendor/libpng/pngget.c

    r11 r43  
    22/* pngget.c - retrieval of values from info struct 
    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) 
     
    1414 
    1515#define PNG_INTERNAL 
     16#define PNG_NO_PEDANTIC_WARNINGS 
    1617#include "png.h" 
    1718#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 
     
    3738} 
    3839 
    39 #if defined(PNG_INFO_IMAGE_SUPPORTED) 
     40#ifdef PNG_INFO_IMAGE_SUPPORTED 
    4041png_bytepp PNGAPI 
    4142png_get_rows(png_structp png_ptr, png_infop info_ptr) 
     
    118119{ 
    119120   if (png_ptr != NULL && info_ptr != NULL) 
    120 #if defined(PNG_pHYs_SUPPORTED) 
     121#ifdef PNG_pHYs_SUPPORTED 
    121122   if (info_ptr->valid & PNG_INFO_pHYs) 
    122123   { 
     
    139140{ 
    140141   if (png_ptr != NULL && info_ptr != NULL) 
    141 #if defined(PNG_pHYs_SUPPORTED) 
     142#ifdef PNG_pHYs_SUPPORTED 
    142143   if (info_ptr->valid & PNG_INFO_pHYs) 
    143144   { 
     
    160161{ 
    161162   if (png_ptr != NULL && info_ptr != NULL) 
    162 #if defined(PNG_pHYs_SUPPORTED) 
     163#ifdef PNG_pHYs_SUPPORTED 
    163164   if (info_ptr->valid & PNG_INFO_pHYs) 
    164165   { 
     
    183184   { 
    184185   if (png_ptr != NULL && info_ptr != NULL) 
    185 #if defined(PNG_pHYs_SUPPORTED) 
     186#ifdef PNG_pHYs_SUPPORTED 
    186187 
    187188   if (info_ptr->valid & PNG_INFO_pHYs) 
    188189   { 
    189190      png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); 
     191 
    190192      if (info_ptr->x_pixels_per_unit == 0) 
    191193         return ((float)0.0); 
     194 
    192195      else 
    193196         return ((float)((float)info_ptr->y_pixels_per_unit 
     
    205208{ 
    206209   if (png_ptr != NULL && info_ptr != NULL) 
    207 #if defined(PNG_oFFs_SUPPORTED) 
     210#ifdef PNG_oFFs_SUPPORTED 
    208211 
    209212   if (info_ptr->valid & PNG_INFO_oFFs) 
     
    228231   if (png_ptr != NULL && info_ptr != NULL) 
    229232 
    230 #if defined(PNG_oFFs_SUPPORTED) 
     233#ifdef PNG_oFFs_SUPPORTED 
    231234   if (info_ptr->valid & PNG_INFO_oFFs) 
    232235   { 
     
    250253   if (png_ptr != NULL && info_ptr != NULL) 
    251254 
    252 #if defined(PNG_oFFs_SUPPORTED) 
     255#ifdef PNG_oFFs_SUPPORTED 
    253256   if (info_ptr->valid & PNG_INFO_oFFs) 
    254257   { 
     
    272275   if (png_ptr != NULL && info_ptr != NULL) 
    273276 
    274 #if defined(PNG_oFFs_SUPPORTED) 
     277#ifdef PNG_oFFs_SUPPORTED 
    275278   if (info_ptr->valid & PNG_INFO_oFFs) 
    276279   { 
     
    325328} 
    326329 
    327 #if defined(PNG_pHYs_SUPPORTED) 
     330#ifdef PNG_pHYs_SUPPORTED 
    328331png_uint_32 PNGAPI 
    329332png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, 
     
    335338   { 
    336339      png_debug1(1, "in %s retrieval function", "pHYs"); 
     340 
    337341      if (res_x != NULL) 
    338342      { 
     
    383387} 
    384388 
    385 #if defined(PNG_bKGD_SUPPORTED) 
     389#ifdef PNG_bKGD_SUPPORTED 
    386390png_uint_32 PNGAPI 
    387391png_get_bKGD(png_structp png_ptr, png_infop info_ptr, 
     
    392396   { 
    393397      png_debug1(1, "in %s retrieval function", "bKGD"); 
     398 
    394399      *background = &(info_ptr->background); 
    395400      return (PNG_INFO_bKGD); 
     
    399404#endif 
    400405 
    401 #if defined(PNG_cHRM_SUPPORTED) 
     406#ifdef PNG_cHRM_SUPPORTED 
    402407#ifdef PNG_FLOATING_POINT_SUPPORTED 
    403408png_uint_32 PNGAPI 
     
    409414   { 
    410415      png_debug1(1, "in %s retrieval function", "cHRM"); 
     416 
    411417      if (white_x != NULL) 
    412418         *white_x = (double)info_ptr->x_white; 
     
    437443   png_fixed_point *blue_x, png_fixed_point *blue_y) 
    438444{ 
     445   png_debug1(1, "in %s retrieval function", "cHRM"); 
     446 
    439447   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) 
    440448   { 
    441       png_debug1(1, "in %s retrieval function", "cHRM"); 
    442449      if (white_x != NULL) 
    443450         *white_x = info_ptr->int_x_white; 
     
    463470#endif 
    464471 
    465 #if defined(PNG_gAMA_SUPPORTED) 
     472#ifdef PNG_gAMA_SUPPORTED 
    466473#ifdef PNG_FLOATING_POINT_SUPPORTED 
    467474png_uint_32 PNGAPI 
    468475png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) 
    469476{ 
     477   png_debug1(1, "in %s retrieval function", "gAMA"); 
     478 
    470479   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) 
    471480      && file_gamma != NULL) 
    472481   { 
    473       png_debug1(1, "in %s retrieval function", "gAMA"); 
    474482      *file_gamma = (double)info_ptr->gamma; 
    475483      return (PNG_INFO_gAMA); 
     
    483491    png_fixed_point *int_file_gamma) 
    484492{ 
     493   png_debug1(1, "in %s retrieval function", "gAMA"); 
     494 
    485495   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) 
    486496      && int_file_gamma != NULL) 
    487497   { 
    488       png_debug1(1, "in %s retrieval function", "gAMA"); 
    489498      *int_file_gamma = info_ptr->int_gamma; 
    490499      return (PNG_INFO_gAMA); 
     
    495504#endif 
    496505 
    497 #if defined(PNG_sRGB_SUPPORTED) 
     506#ifdef PNG_sRGB_SUPPORTED 
    498507png_uint_32 PNGAPI 
    499508png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) 
    500509{ 
     510   png_debug1(1, "in %s retrieval function", "sRGB"); 
     511 
    501512   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) 
    502513      && file_srgb_intent != NULL) 
    503514   { 
    504       png_debug1(1, "in %s retrieval function", "sRGB"); 
    505515      *file_srgb_intent = (int)info_ptr->srgb_intent; 
    506516      return (PNG_INFO_sRGB); 
     
    510520#endif 
    511521 
    512 #if defined(PNG_iCCP_SUPPORTED) 
     522#ifdef PNG_iCCP_SUPPORTED 
    513523png_uint_32 PNGAPI 
    514524png_get_iCCP(png_structp png_ptr, png_infop info_ptr, 
     
    516526             png_charpp profile, png_uint_32 *proflen) 
    517527{ 
     528   png_debug1(1, "in %s retrieval function", "iCCP"); 
     529 
    518530   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) 
    519531      && name != NULL && profile != NULL && proflen != NULL) 
    520532   { 
    521       png_debug1(1, "in %s retrieval function", "iCCP"); 
    522533      *name = info_ptr->iccp_name; 
    523534      *profile = info_ptr->iccp_profile; 
     
    533544#endif 
    534545 
    535 #if defined(PNG_sPLT_SUPPORTED) 
     546#ifdef PNG_sPLT_SUPPORTED 
    536547png_uint_32 PNGAPI 
    537548png_get_sPLT(png_structp png_ptr, png_infop info_ptr, 
     
    547558#endif 
    548559 
    549 #if defined(PNG_hIST_SUPPORTED) 
     560#ifdef PNG_hIST_SUPPORTED 
    550561png_uint_32 PNGAPI 
    551562png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) 
    552563{ 
     564   png_debug1(1, "in %s retrieval function", "hIST"); 
     565 
    553566   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) 
    554567      && hist != NULL) 
    555568   { 
    556       png_debug1(1, "in %s retrieval function", "hIST"); 
    557569      *hist = info_ptr->hist; 
    558570      return (PNG_INFO_hIST); 
     
    569581 
    570582{ 
    571    if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && 
    572       bit_depth != NULL && color_type != NULL) 
    573    { 
    574       png_debug1(1, "in %s retrieval function", "IHDR"); 
    575       *width = info_ptr->width; 
    576       *height = info_ptr->height; 
    577       *bit_depth = info_ptr->bit_depth; 
    578       if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) 
    579          png_error(png_ptr, "Invalid bit depth"); 
    580  
    581       *color_type = info_ptr->color_type; 
    582  
    583       if (info_ptr->color_type > 6) 
    584          png_error(png_ptr, "Invalid color type"); 
    585  
    586       if (compression_type != NULL) 
    587          *compression_type = info_ptr->compression_type; 
    588  
    589       if (filter_type != NULL) 
    590          *filter_type = info_ptr->filter_type; 
    591  
    592       if (interlace_type != NULL) 
    593          *interlace_type = info_ptr->interlace_type; 
    594  
    595       /* Check for potential overflow of rowbytes */ 
    596       if (*width == 0 || *width > PNG_UINT_31_MAX) 
    597         png_error(png_ptr, "Invalid image width"); 
    598  
    599       if (*height == 0 || *height > PNG_UINT_31_MAX) 
    600         png_error(png_ptr, "Invalid image height"); 
    601  
    602       if (info_ptr->width > (PNG_UINT_32_MAX 
    603                  >> 3)      /* 8-byte RGBA pixels */ 
    604                  - 64       /* bigrowbuf hack */ 
    605                  - 1        /* filter byte */ 
    606                  - 7*8      /* rounding of width to multiple of 8 pixels */ 
    607                  - 8)       /* extra max_pixel_depth pad */ 
    608       { 
    609          png_warning(png_ptr, 
    610             "Width too large for libpng to process image data."); 
    611       } 
    612  
    613       return (1); 
    614    } 
    615    return (0); 
    616 } 
    617  
    618 #if defined(PNG_oFFs_SUPPORTED) 
     583   png_debug1(1, "in %s retrieval function", "IHDR"); 
     584 
     585   if (png_ptr == NULL || info_ptr == NULL || width == NULL || 
     586       height == NULL || bit_depth == NULL || color_type == NULL) 
     587      return (0); 
     588 
     589   *width = info_ptr->width; 
     590   *height = info_ptr->height; 
     591   *bit_depth = info_ptr->bit_depth; 
     592   *color_type = info_ptr->color_type; 
     593 
     594   if (compression_type != NULL) 
     595      *compression_type = info_ptr->compression_type; 
     596 
     597   if (filter_type != NULL) 
     598      *filter_type = info_ptr->filter_type; 
     599 
     600   if (interlace_type != NULL) 
     601      *interlace_type = info_ptr->interlace_type; 
     602 
     603   /* This is redundant if we can be sure that the info_ptr values were all 
     604    * assigned in png_set_IHDR().  We do the check anyhow in case an 
     605    * application has ignored our advice not to mess with the members 
     606    * of info_ptr directly. 
     607    */ 
     608   png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, 
     609       info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, 
     610       info_ptr->compression_type, info_ptr->filter_type); 
     611 
     612   return (1); 
     613} 
     614 
     615#ifdef PNG_oFFs_SUPPORTED 
    619616png_uint_32 PNGAPI 
    620617png_get_oFFs(png_structp png_ptr, png_infop info_ptr, 
    621618   png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) 
    622619{ 
     620   png_debug1(1, "in %s retrieval function", "oFFs"); 
     621 
    623622   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) 
    624623      && offset_x != NULL && offset_y != NULL && unit_type != NULL) 
    625624   { 
    626       png_debug1(1, "in %s retrieval function", "oFFs"); 
    627625      *offset_x = info_ptr->x_offset; 
    628626      *offset_y = info_ptr->y_offset; 
     
    634632#endif 
    635633 
    636 #if defined(PNG_pCAL_SUPPORTED) 
     634#ifdef PNG_pCAL_SUPPORTED 
    637635png_uint_32 PNGAPI 
    638636png_get_pCAL(png_structp png_ptr, png_infop info_ptr, 
     
    640638   png_charp *units, png_charpp *params) 
    641639{ 
     640   png_debug1(1, "in %s retrieval function", "pCAL"); 
     641 
    642642   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) 
    643643       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && 
    644644       nparams != NULL && units != NULL && params != NULL) 
    645645   { 
    646       png_debug1(1, "in %s retrieval function", "pCAL"); 
    647646      *purpose = info_ptr->pcal_purpose; 
    648647      *X0 = info_ptr->pcal_X0; 
     
    658657#endif 
    659658 
    660 #if defined(PNG_sCAL_SUPPORTED) 
     659#ifdef PNG_sCAL_SUPPORTED 
    661660#ifdef PNG_FLOATING_POINT_SUPPORTED 
    662661png_uint_32 PNGAPI 
     
    694693#endif 
    695694 
    696 #if defined(PNG_pHYs_SUPPORTED) 
     695#ifdef PNG_pHYs_SUPPORTED 
    697696png_uint_32 PNGAPI 
    698697png_get_pHYs(png_structp png_ptr, png_infop info_ptr, 
     
    701700   png_uint_32 retval = 0; 
    702701 
     702   png_debug1(1, "in %s retrieval function", "pHYs"); 
     703 
    703704   if (png_ptr != NULL && info_ptr != NULL && 
    704705      (info_ptr->valid & PNG_INFO_pHYs)) 
    705706   { 
    706       png_debug1(1, "in %s retrieval function", "pHYs"); 
    707  
    708707      if (res_x != NULL) 
    709708      { 
     
    732731   int *num_palette) 
    733732{ 
     733   png_debug1(1, "in %s retrieval function", "PLTE"); 
     734 
    734735   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) 
    735736       && palette != NULL) 
    736737   { 
    737       png_debug1(1, "in %s retrieval function", "PLTE"); 
    738738      *palette = info_ptr->palette; 
    739739      *num_palette = info_ptr->num_palette; 
     
    744744} 
    745745 
    746 #if defined(PNG_sBIT_SUPPORTED) 
     746#ifdef PNG_sBIT_SUPPORTED 
    747747png_uint_32 PNGAPI 
    748748png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) 
    749749{ 
     750   png_debug1(1, "in %s retrieval function", "sBIT"); 
     751 
    750752   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) 
    751753      && sig_bit != NULL) 
    752754   { 
    753       png_debug1(1, "in %s retrieval function", "sBIT"); 
    754755      *sig_bit = &(info_ptr->sig_bit); 
    755756      return (PNG_INFO_sBIT); 
     
    759760#endif 
    760761 
    761 #if defined(PNG_TEXT_SUPPORTED) 
     762#ifdef PNG_TEXT_SUPPORTED 
    762763png_uint_32 PNGAPI 
    763764png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, 
     
    784785#endif 
    785786 
    786 #if defined(PNG_tIME_SUPPORTED) 
     787#ifdef PNG_tIME_SUPPORTED 
    787788png_uint_32 PNGAPI 
    788789png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) 
    789790{ 
     791   png_debug1(1, "in %s retrieval function", "tIME"); 
     792 
    790793   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) 
    791794       && mod_time != NULL) 
    792795   { 
    793       png_debug1(1, "in %s retrieval function", "tIME"); 
    794796      *mod_time = &(info_ptr->mod_time); 
    795797      return (PNG_INFO_tIME); 
     
    799801#endif 
    800802 
    801 #if defined(PNG_tRNS_SUPPORTED) 
     803#ifdef PNG_tRNS_SUPPORTED 
    802804png_uint_32 PNGAPI 
    803805png_get_tRNS(png_structp png_ptr, png_infop info_ptr, 
     
    808810   { 
    809811      png_debug1(1, "in %s retrieval function", "tRNS"); 
     812 
    810813      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 
    811814      { 
     
    840843#endif 
    841844 
    842 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 
     845#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED 
    843846png_uint_32 PNGAPI 
    844847png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, 
     
    854857#endif 
    855858 
    856 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 
     859#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 
    857860png_byte PNGAPI 
    858861png_get_rgb_to_gray_status (png_structp png_ptr) 
     
    862865#endif 
    863866 
    864 #if defined(PNG_USER_CHUNKS_SUPPORTED) 
     867#ifdef PNG_USER_CHUNKS_SUPPORTED 
    865868png_voidp PNGAPI 
    866869png_get_user_chunk_ptr(png_structp png_ptr) 
     
    940943#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ 
    941944 
    942  
    943945#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */