~ubuntu-branches/ubuntu/lucid/perl-tk/lucid

« back to all changes in this revision

Viewing changes to PNG/libpng/pngget.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Tuckley
  • Date: 2008-02-15 13:56:59 UTC
  • mfrom: (1.1.3 upstream) (4.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080215135659-ru2oqlykuju20fav
Tags: 1:804.028-1
* New Upstream Release (Closes: #463080).
* Update to Debhelper v5.
* Build with XFT=1 (Closes: #411129).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/* pngget.c - retrieval of values from info struct
3
3
 *
4
 
 * libpng 1.2.5 - October 3, 2002
 
4
 * Last changed in libpng 1.2.9 April 14, 2006
5
5
 * For conditions of distribution and use, see copyright notice in png.h
6
 
 * Copyright (c) 1998-2002 Glenn Randers-Pehrson
 
6
 * Copyright (c) 1998-2006 Glenn Randers-Pehrson
7
7
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8
8
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9
9
 */
11
11
#define PNG_INTERNAL
12
12
#include "png.h"
13
13
 
 
14
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
 
15
 
14
16
png_uint_32 PNGAPI
15
17
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
16
18
{
540
542
   if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
541
543
      bit_depth != NULL && color_type != NULL)
542
544
   {
543
 
      int pixel_depth, channels;
544
 
      png_uint_32 rowbytes_per_pixel;
545
 
 
546
545
      png_debug1(1, "in %s retrieval function\n", "IHDR");
547
546
      *width = info_ptr->width;
548
547
      *height = info_ptr->height;
560
559
         *interlace_type = info_ptr->interlace_type;
561
560
 
562
561
      /* check for potential overflow of rowbytes */
563
 
      if (*color_type == PNG_COLOR_TYPE_PALETTE)
564
 
         channels = 1;
565
 
      else if (*color_type & PNG_COLOR_MASK_COLOR)
566
 
         channels = 3;
567
 
      else
568
 
         channels = 1;
569
 
      if (*color_type & PNG_COLOR_MASK_ALPHA)
570
 
         channels++;
571
 
      pixel_depth = *bit_depth * channels;
572
 
      rowbytes_per_pixel = (pixel_depth + 7) >> 3;
573
 
      if (width == 0 || *width > PNG_MAX_UINT)
 
562
      if (*width == 0 || *width > PNG_UINT_31_MAX)
574
563
        png_error(png_ptr, "Invalid image width");
575
 
      if (height == 0 || *height > PNG_MAX_UINT)
 
564
      if (*height == 0 || *height > PNG_UINT_31_MAX)
576
565
        png_error(png_ptr, "Invalid image height");
577
 
      if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
 
566
      if (info_ptr->width > (PNG_UINT_32_MAX
 
567
                 >> 3)      /* 8-byte RGBA pixels */
 
568
                 - 64       /* bigrowbuf hack */
 
569
                 - 1        /* filter byte */
 
570
                 - 7*8      /* rounding of width to multiple of 8 pixels */
 
571
                 - 8)       /* extra max_pixel_depth pad */
578
572
      {
579
 
         png_error(png_ptr,
 
573
         png_warning(png_ptr,
580
574
            "Width too large for libpng to process image data.");
581
575
      }
582
576
      return (1);
827
821
}
828
822
#endif
829
823
 
830
 
 
 
824
#ifdef PNG_WRITE_SUPPORTED
831
825
png_uint_32 PNGAPI
832
826
png_get_compression_buffer_size(png_structp png_ptr)
833
827
{
834
828
   return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
835
829
}
836
 
 
 
830
#endif
837
831
 
838
832
#ifndef PNG_1_0_X
839
833
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
923
917
{
924
918
    return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
925
919
}
926
 
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
927
 
#endif /* PNG_1_0_X */
 
920
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
 
921
#endif /* ?PNG_1_0_X */
 
922
 
 
923
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
 
924
/* these functions were added to libpng 1.2.6 */
 
925
png_uint_32 PNGAPI
 
926
png_get_user_width_max (png_structp png_ptr)
 
927
{
 
928
    return (png_ptr? png_ptr->user_width_max : 0);
 
929
}
 
930
png_uint_32 PNGAPI
 
931
png_get_user_height_max (png_structp png_ptr)
 
932
{
 
933
    return (png_ptr? png_ptr->user_height_max : 0);
 
934
}
 
935
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
 
936
 
 
937
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */