Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/libpng/pngget.c

    r2 r561  
    22/* pngget.c - retrieval of values from info struct
    33 *
    4  * Last changed in libpng 1.2.15 January 5, 2007
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2007 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
     12 *
    913 */
    1014
    1115#define PNG_INTERNAL
    1216#include "png.h"
    13 
    1417#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
    1518
     
    1922   if (png_ptr != NULL && info_ptr != NULL)
    2023      return(info_ptr->valid & flag);
     24
    2125   else
    2226      return(0);
     
    2832   if (png_ptr != NULL && info_ptr != NULL)
    2933      return(info_ptr->rowbytes);
     34
    3035   else
    3136      return(0);
     
    3843   if (png_ptr != NULL && info_ptr != NULL)
    3944      return(info_ptr->row_pointers);
     45
    4046   else
    4147      return(0);
     
    4450
    4551#ifdef PNG_EASY_ACCESS_SUPPORTED
    46 /* easy access to info, added in libpng-0.99 */
     52/* Easy access to info, added in libpng-0.99 */
    4753png_uint_32 PNGAPI
    4854png_get_image_width(png_structp png_ptr, png_infop info_ptr)
    4955{
    5056   if (png_ptr != NULL && info_ptr != NULL)
    51    {
    5257      return info_ptr->width;
    53    }
     58
    5459   return (0);
    5560}
     
    5964{
    6065   if (png_ptr != NULL && info_ptr != NULL)
    61    {
    6266      return info_ptr->height;
    63    }
     67
    6468   return (0);
    6569}
     
    6973{
    7074   if (png_ptr != NULL && info_ptr != NULL)
    71    {
    7275      return info_ptr->bit_depth;
    73    }
     76
    7477   return (0);
    7578}
     
    7982{
    8083   if (png_ptr != NULL && info_ptr != NULL)
    81    {
    8284      return info_ptr->color_type;
    83    }
     85
    8486   return (0);
    8587}
     
    8991{
    9092   if (png_ptr != NULL && info_ptr != NULL)
    91    {
    9293      return info_ptr->filter_type;
    93    }
     94
    9495   return (0);
    9596}
     
    99100{
    100101   if (png_ptr != NULL && info_ptr != NULL)
    101    {
    102102      return info_ptr->interlace_type;
    103    }
     103
    104104   return (0);
    105105}
     
    109109{
    110110   if (png_ptr != NULL && info_ptr != NULL)
    111    {
    112111      return info_ptr->compression_type;
    113    }
     112
    114113   return (0);
    115114}
     
    122121   if (info_ptr->valid & PNG_INFO_pHYs)
    123122   {
    124       png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
    125       if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
     123      png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
     124
     125      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
    126126          return (0);
    127       else return (info_ptr->x_pixels_per_unit);
     127
     128      else
     129          return (info_ptr->x_pixels_per_unit);
    128130   }
    129131#else
     
    140142   if (info_ptr->valid & PNG_INFO_pHYs)
    141143   {
    142       png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
    143       if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
     144      png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
     145
     146      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
    144147          return (0);
    145       else return (info_ptr->y_pixels_per_unit);
     148
     149      else
     150          return (info_ptr->y_pixels_per_unit);
    146151   }
    147152#else
     
    158163   if (info_ptr->valid & PNG_INFO_pHYs)
    159164   {
    160       png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
    161       if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
     165      png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
     166
     167      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
    162168         info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
    163169          return (0);
    164       else return (info_ptr->x_pixels_per_unit);
     170
     171      else
     172          return (info_ptr->x_pixels_per_unit);
    165173   }
    166174#else
     
    176184   if (png_ptr != NULL && info_ptr != NULL)
    177185#if defined(PNG_pHYs_SUPPORTED)
     186
    178187   if (info_ptr->valid & PNG_INFO_pHYs)
    179188   {
    180       png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
     189      png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
    181190      if (info_ptr->x_pixels_per_unit == 0)
    182191         return ((float)0.0);
     
    186195   }
    187196#else
    188    return (0.0);
     197      return (0.0);
    189198#endif
    190199   return ((float)0.0);
     
    197206   if (png_ptr != NULL && info_ptr != NULL)
    198207#if defined(PNG_oFFs_SUPPORTED)
     208
    199209   if (info_ptr->valid & PNG_INFO_oFFs)
    200210   {
    201       png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
    202       if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
     211      png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
     212
     213      if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
    203214          return (0);
    204       else return (info_ptr->x_offset);
     215
     216      else
     217          return (info_ptr->x_offset);
    205218   }
    206219#else
    207    return (0);
     220      return (0);
    208221#endif
    209222   return (0);
     
    214227{
    215228   if (png_ptr != NULL && info_ptr != NULL)
     229
    216230#if defined(PNG_oFFs_SUPPORTED)
    217231   if (info_ptr->valid & PNG_INFO_oFFs)
    218232   {
    219       png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
    220       if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
     233      png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
     234
     235      if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
    221236          return (0);
    222       else return (info_ptr->y_offset);
     237
     238      else
     239          return (info_ptr->y_offset);
    223240   }
    224241#else
     
    232249{
    233250   if (png_ptr != NULL && info_ptr != NULL)
     251
    234252#if defined(PNG_oFFs_SUPPORTED)
    235253   if (info_ptr->valid & PNG_INFO_oFFs)
    236254   {
    237       png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
    238       if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
     255      png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
     256
     257      if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
    239258          return (0);
    240       else return (info_ptr->x_offset);
     259
     260      else
     261          return (info_ptr->x_offset);
    241262   }
    242263#else
     
    250271{
    251272   if (png_ptr != NULL && info_ptr != NULL)
     273
    252274#if defined(PNG_oFFs_SUPPORTED)
    253275   if (info_ptr->valid & PNG_INFO_oFFs)
    254276   {
    255       png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
    256       if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
     277      png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
     278
     279      if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
    257280          return (0);
    258       else return (info_ptr->y_offset);
     281
     282      else
     283          return (info_ptr->y_offset);
    259284   }
    260285#else
     
    309334   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
    310335   {
    311       png_debug1(1, "in %s retrieval function\n", "pHYs");
     336      png_debug1(1, "in %s retrieval function", "pHYs");
    312337      if (res_x != NULL)
    313338      {
     
    324349         *unit_type = (int)info_ptr->phys_unit_type;
    325350         retval |= PNG_INFO_pHYs;
    326          if(*unit_type == 1)
     351         if (*unit_type == 1)
    327352         {
    328353            if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
     
    366391      && background != NULL)
    367392   {
    368       png_debug1(1, "in %s retrieval function\n", "bKGD");
     393      png_debug1(1, "in %s retrieval function", "bKGD");
    369394      *background = &(info_ptr->background);
    370395      return (PNG_INFO_bKGD);
     
    383408   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
    384409   {
    385       png_debug1(1, "in %s retrieval function\n", "cHRM");
     410      png_debug1(1, "in %s retrieval function", "cHRM");
    386411      if (white_x != NULL)
    387412         *white_x = (double)info_ptr->x_white;
     
    414439   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
    415440   {
    416       png_debug1(1, "in %s retrieval function\n", "cHRM");
     441      png_debug1(1, "in %s retrieval function", "cHRM");
    417442      if (white_x != NULL)
    418443         *white_x = info_ptr->int_x_white;
     
    446471      && file_gamma != NULL)
    447472   {
    448       png_debug1(1, "in %s retrieval function\n", "gAMA");
     473      png_debug1(1, "in %s retrieval function", "gAMA");
    449474      *file_gamma = (double)info_ptr->gamma;
    450475      return (PNG_INFO_gAMA);
     
    461486      && int_file_gamma != NULL)
    462487   {
    463       png_debug1(1, "in %s retrieval function\n", "gAMA");
     488      png_debug1(1, "in %s retrieval function", "gAMA");
    464489      *int_file_gamma = info_ptr->int_gamma;
    465490      return (PNG_INFO_gAMA);
     
    477502      && file_srgb_intent != NULL)
    478503   {
    479       png_debug1(1, "in %s retrieval function\n", "sRGB");
     504      png_debug1(1, "in %s retrieval function", "sRGB");
    480505      *file_srgb_intent = (int)info_ptr->srgb_intent;
    481506      return (PNG_INFO_sRGB);
     
    494519      && name != NULL && profile != NULL && proflen != NULL)
    495520   {
    496       png_debug1(1, "in %s retrieval function\n", "iCCP");
     521      png_debug1(1, "in %s retrieval function", "iCCP");
    497522      *name = info_ptr->iccp_name;
    498523      *profile = info_ptr->iccp_profile;
    499       /* compression_type is a dummy so the API won't have to change
    500          if we introduce multiple compression types later. */
     524      /* Compression_type is a dummy so the API won't have to change
     525       * if we introduce multiple compression types later.
     526       */
    501527      *proflen = (int)info_ptr->iccp_proflen;
    502528      *compression_type = (int)info_ptr->iccp_compression;
     
    528554      && hist != NULL)
    529555   {
    530       png_debug1(1, "in %s retrieval function\n", "hIST");
     556      png_debug1(1, "in %s retrieval function", "hIST");
    531557      *hist = info_ptr->hist;
    532558      return (PNG_INFO_hIST);
     
    546572      bit_depth != NULL && color_type != NULL)
    547573   {
    548       png_debug1(1, "in %s retrieval function\n", "IHDR");
     574      png_debug1(1, "in %s retrieval function", "IHDR");
    549575      *width = info_ptr->width;
    550576      *height = info_ptr->height;
    551577      *bit_depth = info_ptr->bit_depth;
    552578      if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
    553         png_error(png_ptr, "Invalid bit depth");
     579         png_error(png_ptr, "Invalid bit depth");
     580
    554581      *color_type = info_ptr->color_type;
     582
    555583      if (info_ptr->color_type > 6)
    556         png_error(png_ptr, "Invalid color type");
     584         png_error(png_ptr, "Invalid color type");
     585
    557586      if (compression_type != NULL)
    558587         *compression_type = info_ptr->compression_type;
     588
    559589      if (filter_type != NULL)
    560590         *filter_type = info_ptr->filter_type;
     591
    561592      if (interlace_type != NULL)
    562593         *interlace_type = info_ptr->interlace_type;
    563594
    564       /* check for potential overflow of rowbytes */
     595      /* Check for potential overflow of rowbytes */
    565596      if (*width == 0 || *width > PNG_UINT_31_MAX)
    566597        png_error(png_ptr, "Invalid image width");
     598
    567599      if (*height == 0 || *height > PNG_UINT_31_MAX)
    568600        png_error(png_ptr, "Invalid image height");
     601
    569602      if (info_ptr->width > (PNG_UINT_32_MAX
    570603                 >> 3)      /* 8-byte RGBA pixels */
     
    577610            "Width too large for libpng to process image data.");
    578611      }
     612
    579613      return (1);
    580614   }
     
    590624      && offset_x != NULL && offset_y != NULL && unit_type != NULL)
    591625   {
    592       png_debug1(1, "in %s retrieval function\n", "oFFs");
     626      png_debug1(1, "in %s retrieval function", "oFFs");
    593627      *offset_x = info_ptr->x_offset;
    594628      *offset_y = info_ptr->y_offset;
     
    607641{
    608642   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
    609       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
    610       nparams != NULL && units != NULL && params != NULL)
    611    {
    612       png_debug1(1, "in %s retrieval function\n", "pCAL");
     643       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
     644       nparams != NULL && units != NULL && params != NULL)
     645   {
     646      png_debug1(1, "in %s retrieval function", "pCAL");
    613647      *purpose = info_ptr->pcal_purpose;
    614648      *X0 = info_ptr->pcal_X0;
     
    631665{
    632666    if (png_ptr != NULL && info_ptr != NULL &&
    633        (info_ptr->valid & PNG_INFO_sCAL))
     667        (info_ptr->valid & PNG_INFO_sCAL))
    634668    {
    635669        *unit = info_ptr->scal_unit;
     
    647681{
    648682    if (png_ptr != NULL && info_ptr != NULL &&
    649        (info_ptr->valid & PNG_INFO_sCAL))
     683        (info_ptr->valid & PNG_INFO_sCAL))
    650684    {
    651685        *unit = info_ptr->scal_unit;
     
    670704      (info_ptr->valid & PNG_INFO_pHYs))
    671705   {
    672       png_debug1(1, "in %s retrieval function\n", "pHYs");
     706      png_debug1(1, "in %s retrieval function", "pHYs");
     707
    673708      if (res_x != NULL)
    674709      {
     
    676711         retval |= PNG_INFO_pHYs;
    677712      }
     713
    678714      if (res_y != NULL)
    679715      {
     
    681717         retval |= PNG_INFO_pHYs;
    682718      }
     719
    683720      if (unit_type != NULL)
    684721      {
     
    698735       && palette != NULL)
    699736   {
    700       png_debug1(1, "in %s retrieval function\n", "PLTE");
     737      png_debug1(1, "in %s retrieval function", "PLTE");
    701738      *palette = info_ptr->palette;
    702739      *num_palette = info_ptr->num_palette;
    703       png_debug1(3, "num_palette = %d\n", *num_palette);
     740      png_debug1(3, "num_palette = %d", *num_palette);
    704741      return (PNG_INFO_PLTE);
    705742   }
     
    714751      && sig_bit != NULL)
    715752   {
    716       png_debug1(1, "in %s retrieval function\n", "sBIT");
     753      png_debug1(1, "in %s retrieval function", "sBIT");
    717754      *sig_bit = &(info_ptr->sig_bit);
    718755      return (PNG_INFO_sBIT);
     
    729766   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
    730767   {
    731       png_debug1(1, "in %s retrieval function\n",
     768      png_debug1(1, "in %s retrieval function",
    732769         (png_ptr->chunk_name[0] == '\0' ? "text"
    733770             : (png_const_charp)png_ptr->chunk_name));
     771
    734772      if (text_ptr != NULL)
    735773         *text_ptr = info_ptr->text;
     774
    736775      if (num_text != NULL)
    737776         *num_text = info_ptr->num_text;
     777
    738778      return ((png_uint_32)info_ptr->num_text);
    739779   }
     
    751791       && mod_time != NULL)
    752792   {
    753       png_debug1(1, "in %s retrieval function\n", "tIME");
     793      png_debug1(1, "in %s retrieval function", "tIME");
    754794      *mod_time = &(info_ptr->mod_time);
    755795      return (PNG_INFO_tIME);
     
    767807   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
    768808   {
    769       png_debug1(1, "in %s retrieval function\n", "tRNS");
     809      png_debug1(1, "in %s retrieval function", "tRNS");
    770810      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
    771811      {
     
    775815             retval |= PNG_INFO_tRNS;
    776816          }
     817
    777818          if (trans_values != NULL)
    778819             *trans_values = &(info_ptr->trans_values);
     
    785826             retval |= PNG_INFO_tRNS;
    786827          }
    787           if(trans != NULL)
     828
     829          if (trans != NULL)
    788830             *trans = NULL;
    789831      }
    790       if(num_trans != NULL)
     832      if (num_trans != NULL)
    791833      {
    792834         *num_trans = info_ptr->num_trans;
     
    838880#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
    839881#ifndef PNG_1_0_X
    840 /* this function was added to libpng 1.2.0 and should exist by default */
     882/* This function was added to libpng 1.2.0 and should exist by default */
    841883png_uint_32 PNGAPI
    842884png_get_asm_flags (png_structp png_ptr)
    843885{
    844     /* obsolete, to be removed from libpng-1.4.0 */
     886    /* Obsolete, to be removed from libpng-1.4.0 */
    845887    return (png_ptr? 0L: 0L);
    846888}
    847889
    848 /* this function was added to libpng 1.2.0 and should exist by default */
     890/* This function was added to libpng 1.2.0 and should exist by default */
    849891png_uint_32 PNGAPI
    850892png_get_asm_flagmask (int flag_select)
    851893{
    852     /* obsolete, to be removed from libpng-1.4.0 */
     894    /* Obsolete, to be removed from libpng-1.4.0 */
    853895    flag_select=flag_select;
    854896    return 0L;
     
    856898
    857899    /* GRR:  could add this:   && defined(PNG_MMX_CODE_SUPPORTED) */
    858 /* this function was added to libpng 1.2.0 */
     900/* This function was added to libpng 1.2.0 */
    859901png_uint_32 PNGAPI
    860902png_get_mmx_flagmask (int flag_select, int *compilerID)
    861903{
    862     /* obsolete, to be removed from libpng-1.4.0 */
     904    /* Obsolete, to be removed from libpng-1.4.0 */
    863905    flag_select=flag_select;
    864906    *compilerID = -1;   /* unknown (i.e., no asm/MMX code compiled) */
     
    866908}
    867909
    868 /* this function was added to libpng 1.2.0 */
     910/* This function was added to libpng 1.2.0 */
    869911png_byte PNGAPI
    870912png_get_mmx_bitdepth_threshold (png_structp png_ptr)
    871913{
    872     /* obsolete, to be removed from libpng-1.4.0 */
     914    /* Obsolete, to be removed from libpng-1.4.0 */
    873915    return (png_ptr? 0: 0);
    874916}
    875917
    876 /* this function was added to libpng 1.2.0 */
     918/* This function was added to libpng 1.2.0 */
    877919png_uint_32 PNGAPI
    878920png_get_mmx_rowbytes_threshold (png_structp png_ptr)
    879921{
    880     /* obsolete, to be removed from libpng-1.4.0 */
     922    /* Obsolete, to be removed from libpng-1.4.0 */
    881923    return (png_ptr? 0L: 0L);
    882924}
     
    885927
    886928#ifdef PNG_SET_USER_LIMITS_SUPPORTED
    887 /* these functions were added to libpng 1.2.6 */
     929/* These functions were added to libpng 1.2.6 */
    888930png_uint_32 PNGAPI
    889931png_get_user_width_max (png_structp png_ptr)
     
    897939}
    898940#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
    899  
     941
    900942
    901943#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
Note: See TracChangeset for help on using the changeset viewer.