3157N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 342N/A * This code is free software; you can redistribute it and/or modify it 342N/A * under the terms of the GNU General Public License version 2 only, as 342N/A * published by the Free Software Foundation. Oracle designates this 342N/A * particular file as subject to the "Classpath" exception as provided 342N/A * by Oracle in the LICENSE file that accompanied this code. 342N/A * This code is distributed in the hope that it will be useful, but WITHOUT 342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 342N/A * version 2 for more details (a copy is included in the LICENSE file that 342N/A * accompanied this code). 342N/A * You should have received a copy of the GNU General Public License version 342N/A * 2 along with this work; if not, write to the Free Software Foundation, 342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1879N/A * This file is available under and governed by the GNU General Public 1879N/A * License version 2 only, as published by the Free Software Foundation. 1879N/A * However, the following notice accompanied the original version of this 1879N/A * file and, per its terms, should not be removed: 3678N/A * Last changed in libpng 1.5.4 [July 7, 2011] 1879N/A * Copyright (c) 1998-2011 Glenn Randers-Pehrson 4141N/A * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 4141N/A * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 4141N/A * This code is released under the libpng license. 1879N/A * For conditions of distribution and use, see the disclaimer 1879N/A * This file contains routines that an application calls directly to 1879N/A * read a PNG file or stream. 1879N/A/* Create a PNG structure for reading, and allocate any memory needed. */ 342N/A/* Alternate create PNG structure for reading, and allocate any memory 342N/A#
endif /* PNG_USER_MEM_SUPPORTED */ 342N/A /* Added at libpng-1.2.6 */ 342N/A /* Added at libpng-1.2.43 and 1.4.0 */ 358N/A /* Added at libpng-1.2.43 and 1.4.1 */ 342N/A/* Applications that neglect to set up their own setjmp() and then 342N/A encounter a png_error() will longjmp here. Since the jmpbuf is 342N/A then meaningless we abort instead of returning. */ 342N/A#
endif /* PNG_SETJMP_SUPPORTED */ 342N/A /* Call the general version checker (shared with read and write code): */ 342N/A /* Initialize zbuf - compression buffer */ 941N/A /* Clean up PNG structure and deallocate any memory. */ 2597N/A/* Read the information before the actual image data. This has been 2597N/A * changed in v0.90 to allow reading a file that already has the magic 2597N/A * bytes read from the stream. You can tell libpng how many bytes have 3679N/A * been read from the beginning of the stream (up to the maximum of 8) 2597N/A * via png_set_sig_bytes(), and we will only check the remaining bytes 2597N/A * here. The application can then have access to the signature bytes we 2597N/A * read if it is determined that this isn't a valid PNG file. 342N/A /* Read and check the PNG file signature. */ 342N/A /* This should be a binary subdivision search or a hash for 342N/A * matching the chunk name rather than a linear search. #
endif /* PNG_SEQUENTIAL_READ_SUPPORTED *//* Optional call to update the users info_ptr structure */ "Ignoring extra png_read_update_info() call;" " row buffer not reallocated");
/* Initialize palette, background, etc, after transformations * are set, but before any reading takes place. This allows * the user to obtain a gamma-corrected palette, for example. * If the user doesn't call this, we will do it ourselves. "Ignoring extra png_start_read_image() call;" " row buffer not reallocated");
#
endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ png_debug2(
1,
"in png_read_row (row %lu, pass %d)",
/* Check for transforms that have been set but were defined out */ /* If interlaced and we do not need a new row, combine row and return */ /* Intrapixel differencing */ /* Blow up interlaced rows to full size */ /* Old interface (pre-1.0.9): * png_do_read_interlace(&(png_ptr->row_info), * png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); #
endif /* PNG_SEQUENTIAL_READ_SUPPORTED *//* Read one or more rows of image data. If the image is interlaced, * and png_set_interlace_handling() has been called, the rows need to * contain the contents of the rows from the previous pass. If the * image has alpha or transparency, and png_handle_alpha()[*] has been * called, the rows contents must be initialized to the contents of the * "row" holds the actual image, and pixels are placed in it * as they arrive. If the image is displayed after each pass, it will * appear to "sparkle" in. "display_row" can be used to display a * "chunky" progressive image, with finer detail added as it becomes * available. If you do not want this "chunky" display, you may pass * NULL for display_row. If you do not want the sparkle display, and * you have not called png_handle_alpha(), you may pass NULL for rows. * If you have called png_handle_alpha(), and the image has either an * alpha channel or a transparency chunk, you must provide a buffer for * rows. In this case, you do not have to provide a display_row buffer * also, but you may. If the image is not interlaced, or if you have * not called png_set_interlace_handling(), the display_row buffer will * be ignored, so pass NULL to it. * [*] png_handle_alpha() does not exist yet, as of this version of libpng #
endif /* PNG_SEQUENTIAL_READ_SUPPORTED *//* Read the entire image. If the image has an alpha channel or a tRNS * chunk, and you have called png_handle_alpha()[*], you will need to * initialize the image to the current image that PNG will be overlaying. * We set the num_rows again here, in case it was incorrectly set in * png_read_start_row() by a call to png_read_update_info() or * png_start_read_image() if png_set_interlace_handling() wasn't called * prior to either of these functions like it should have been. You can * only call this function once. If you desire to have an image for * each pass of a interlaced image, use png_read_rows() instead. * [*] png_handle_alpha() does not exist yet, as of this version of libpng /* And make sure transforms are initialized. */ /* Caller called png_start_read_image or png_read_update_info without * first turning on the PNG_INTERLACE transform. We can fix this here, * but the caller should do it! /* Make sure this is set correctly */ /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in "Cannot read interlaced image -- interlace handler disabled");
for (j = 0; j <
pass; j++)
#
endif /* PNG_SEQUENTIAL_READ_SUPPORTED *//* Read the end of the PNG file. Will not read past the end of the * file, will verify the end is accurate, and will read any comments * or time information at the end of the file, if info is not NULL. /* Zero length IDATs are legal after the last IDAT has been * read, but not after other chunks have been read. #
endif /* PNG_SEQUENTIAL_READ_SUPPORTED *//* Free all memory used by the read */ /* Free all memory used by the read (old method) */ for (i = 0; i <
istop; i++)
for (i = 0; i <
istop; i++)
for (i = 0; i <
istop; i++)
#
endif /* PNG_TEXT_SUPPORTED */#
endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ /* Save the important info out of the png_struct, in case it is /* png_read_info() gives us all of the information from the * PNG file before the first IDAT (image data chunk). /* -------------- image transformations start here ------------------- */ /* Tell libpng to strip 16-bit/color files down to 8 bits per color. /* Added at libpng-1.5.4. "strip_16" produces the same result that it * did in earlier versions, while "scale_16" is now more accurate. /* If both SCALE and STRIP are required pngrtran will effectively cancel the * latter by doing SCALE first. This is ok and allows apps not to check for * which is supported to get the right answer. /* Strip alpha bytes from the input data without combining with * the background (not recommended). /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single * byte into separate bytes (useful for paletted and grayscale images). /* Change the order of packed pixels to least significant bit first * (not useful if you are using png_set_packing). /* Expand paletted colors into true RGB triplets * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel * Expand paletted or RGB images with transparency to full alpha * channels so the data will be available as RGBA quartets. /* We don't handle background color or gamma transformation or quantizing. /* Invert monochrome files to have 0 as white and 1 as black /* If you want to shift the pixel values from the range [0,255] or * [0,65535] to the original [0,7] or [0,31], or whatever range the * colors were originally in: /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ /* Swap bytes of 16-bit files to least significant byte first */ /* Added at libpng-1.2.41 */ /* Invert the alpha channel from opacity to transparency */ /* Added at libpng-1.2.41 */ /* Expand grayscale image to RGB */ /* Added at libpng-1.5.4 */ /* We don't handle adding filler bytes */ /* We use png_read_image and rely on that for interlace handling, but we also * call png_read_update_info therefore must turn on interlace handling now: /* Optional call to gamma correct and add the background to the palette * and update info structure. REQUIRED if you are expecting libpng to * update the palette for you (i.e., you selected such a transform above). /* -------------- image transformations end here ------------------- */ /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ #
endif /* PNG_INFO_IMAGE_SUPPORTED */#
endif /* PNG_SEQUENTIAL_READ_SUPPORTED */#
endif /* PNG_READ_SUPPORTED */