< prev index next >

src/java.desktop/share/native/libsplashscreen/libpng/pngtest.c

Print this page




  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 /* pngtest.c - a simple test program to test libpng
  26  *
  27  * This file is available under and governed by the GNU General Public
  28  * License version 2 only, as published by the Free Software Foundation.
  29  * However, the following notice accompanied the original version of this
  30  * file and, per its terms, should not be removed:
  31  *
  32  * Last changed in libpng 1.5.25 [December 3, 2015]
  33  * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  34  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  35  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  36  *
  37  * This code is released under the libpng license.
  38  * For conditions of distribution and use, see the disclaimer
  39  * and license in png.h
  40  *
  41  * This program reads in a PNG image, writes it out again, and then
  42  * compares the two files.  If the files are identical, this shows that
  43  * the basic chunk handling, filtering, and (de)compression code is working
  44  * properly.  It does not currently test all of the transforms, although
  45  * it probably should.
  46  *
  47  * The program will report "FAIL" in certain legitimate cases:
  48  * 1) when the compression level or filter selection method is changed.
  49  * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192.
  50  * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks
  51  *    exist in the input file.
  52  * 4) others not listed here...
  53  * In these cases, it is best to check with another tool such as "pngcheck"
  54  * to see what the differences between the two files are.
  55  *
  56  * If a filename is given on the command-line, then this file is used
  57  * for the input, rather than the default "pngtest.png".  This allows
  58  * testing a wide variety of files easily.  You can also test a number
  59  * of files at once by typing "pngtest -m file1.png file2.png ..."
  60  */
  61 
  62 #define _POSIX_SOURCE 1
  63 
  64 #include <stdio.h>
  65 #include <stdlib.h>
  66 #include <string.h>
  67 
  68 /* Defined so I can write to a file on gui/windowing platforms */
  69 /*  #define STDERR stderr  */
  70 #define STDERR stdout   /* For DOS */
  71 
  72 #include "png.h"
  73 









  74 /* Known chunks that exist in pngtest.png must be supported or pngtest will fail
  75  * simply as a result of re-ordering them.  This may be fixed in 1.7
  76  *
  77  * pngtest allocates a single row buffer for each row and overwrites it,
  78  * therefore if the write side doesn't support the writing of interlaced images
  79  * nothing can be done for an interlaced image (and the code below will fail
  80  * horribly trying to write extra data after writing garbage).
  81  */
  82 #if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
  83    defined PNG_READ_bKGD_SUPPORTED &&\
  84    defined PNG_READ_cHRM_SUPPORTED &&\
  85    defined PNG_READ_gAMA_SUPPORTED &&\
  86    defined PNG_READ_oFFs_SUPPORTED &&\
  87    defined PNG_READ_pCAL_SUPPORTED &&\
  88    defined PNG_READ_pHYs_SUPPORTED &&\
  89    defined PNG_READ_sBIT_SUPPORTED &&\
  90    defined PNG_READ_sCAL_SUPPORTED &&\
  91    defined PNG_READ_sRGB_SUPPORTED &&\
  92    defined PNG_READ_sPLT_SUPPORTED &&\
  93    defined PNG_READ_tEXt_SUPPORTED &&\


2076       fprintf(STDERR, "  cache_max  = unlimited\n");
2077    else
2078       fprintf(STDERR, "  cache_max  = %lu\n",
2079          (unsigned long) png_get_chunk_cache_max(dummy_ptr));
2080    if (png_get_chunk_malloc_max(dummy_ptr) == 0)
2081       fprintf(STDERR, "  malloc_max = unlimited\n");
2082    else
2083       fprintf(STDERR, "  malloc_max = %lu\n",
2084          (unsigned long) png_get_chunk_malloc_max(dummy_ptr));
2085    png_destroy_read_struct(&dummy_ptr, NULL, NULL);
2086 
2087    return (int)(ierror != 0);
2088 }
2089 #else
2090 int
2091 main(void)
2092 {
2093    fprintf(STDERR,
2094       " test ignored because libpng was not built with read support\n");
2095    /* And skip this test */
2096    return PNG_LIBPNG_VER < 10600 ? 0 : 77;
2097 }
2098 #endif
2099 
2100 /* Generate a compiler error if there is an old png.h in the search path. */
2101 typedef png_libpng_version_1_6_20 Your_png_h_is_not_version_1_6_20;


  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 /* pngtest.c - a simple test program to test libpng
  26  *
  27  * This file is available under and governed by the GNU General Public
  28  * License version 2 only, as published by the Free Software Foundation.
  29  * However, the following notice accompanied the original version of this
  30  * file and, per its terms, should not be removed:
  31  *
  32  * Last changed in libpng 1.5.25 [December 3, 2015]
  33  * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
  34  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  35  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  36  *
  37  * This code is released under the libpng license.
  38  * For conditions of distribution and use, see the disclaimer
  39  * and license in png.h
  40  *
  41  * This program reads in a PNG image, writes it out again, and then
  42  * compares the two files.  If the files are identical, this shows that
  43  * the basic chunk handling, filtering, and (de)compression code is working
  44  * properly.  It does not currently test all of the transforms, although
  45  * it probably should.
  46  *
  47  * The program will report "FAIL" in certain legitimate cases:
  48  * 1) when the compression level or filter selection method is changed.
  49  * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192.
  50  * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks
  51  *    exist in the input file.
  52  * 4) others not listed here...
  53  * In these cases, it is best to check with another tool such as "pngcheck"
  54  * to see what the differences between the two files are.
  55  *
  56  * If a filename is given on the command-line, then this file is used
  57  * for the input, rather than the default "pngtest.png".  This allows
  58  * testing a wide variety of files easily.  You can also test a number
  59  * of files at once by typing "pngtest -m file1.png file2.png ..."
  60  */
  61 
  62 #define _POSIX_SOURCE 1
  63 
  64 #include <stdio.h>
  65 #include <stdlib.h>
  66 #include <string.h>
  67 
  68 /* Defined so I can write to a file on gui/windowing platforms */
  69 /*  #define STDERR stderr  */
  70 #define STDERR stdout   /* For DOS */
  71 
  72 #include "png.h"
  73 
  74 /* 1.6.1 added support for the configure test harness, which uses 77 to indicate
  75  * a skipped test, in earlier versions we need to succeed on a skipped test, so:
  76  */
  77 #if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
  78 #  define SKIP 77
  79 #else
  80 #  define SKIP 0
  81 #endif
  82 
  83 /* Known chunks that exist in pngtest.png must be supported or pngtest will fail
  84  * simply as a result of re-ordering them.  This may be fixed in 1.7
  85  *
  86  * pngtest allocates a single row buffer for each row and overwrites it,
  87  * therefore if the write side doesn't support the writing of interlaced images
  88  * nothing can be done for an interlaced image (and the code below will fail
  89  * horribly trying to write extra data after writing garbage).
  90  */
  91 #if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
  92    defined PNG_READ_bKGD_SUPPORTED &&\
  93    defined PNG_READ_cHRM_SUPPORTED &&\
  94    defined PNG_READ_gAMA_SUPPORTED &&\
  95    defined PNG_READ_oFFs_SUPPORTED &&\
  96    defined PNG_READ_pCAL_SUPPORTED &&\
  97    defined PNG_READ_pHYs_SUPPORTED &&\
  98    defined PNG_READ_sBIT_SUPPORTED &&\
  99    defined PNG_READ_sCAL_SUPPORTED &&\
 100    defined PNG_READ_sRGB_SUPPORTED &&\
 101    defined PNG_READ_sPLT_SUPPORTED &&\
 102    defined PNG_READ_tEXt_SUPPORTED &&\


2085       fprintf(STDERR, "  cache_max  = unlimited\n");
2086    else
2087       fprintf(STDERR, "  cache_max  = %lu\n",
2088          (unsigned long) png_get_chunk_cache_max(dummy_ptr));
2089    if (png_get_chunk_malloc_max(dummy_ptr) == 0)
2090       fprintf(STDERR, "  malloc_max = unlimited\n");
2091    else
2092       fprintf(STDERR, "  malloc_max = %lu\n",
2093          (unsigned long) png_get_chunk_malloc_max(dummy_ptr));
2094    png_destroy_read_struct(&dummy_ptr, NULL, NULL);
2095 
2096    return (int)(ierror != 0);
2097 }
2098 #else
2099 int
2100 main(void)
2101 {
2102    fprintf(STDERR,
2103       " test ignored because libpng was not built with read support\n");
2104    /* And skip this test */
2105    return SKIP;
2106 }
2107 #endif
2108 
2109 /* Generate a compiler error if there is an old png.h in the search path. */
2110 typedef png_libpng_version_1_6_23 Your_png_h_is_not_version_1_6_23;
< prev index next >