aboutsummaryrefslogtreecommitdiffstats
path: root/example.c
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-09 11:52:12 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-09 11:52:12 -0700
commit4215dd1533c56e1a89ae6f1d6ea68677fac27fda (patch)
tree99318267166103602095f7af976be5b7f0e25d04 /example.c
parent893912bfc2683463dc3e2c445336752d012563d3 (diff)
downloadexternal_libpng-4215dd1533c56e1a89ae6f1d6ea68677fac27fda.zip
external_libpng-4215dd1533c56e1a89ae6f1d6ea68677fac27fda.tar.gz
external_libpng-4215dd1533c56e1a89ae6f1d6ea68677fac27fda.tar.bz2
auto import from //branches/cupcake/...@137197
Diffstat (limited to 'example.c')
-rw-r--r--example.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/example.c b/example.c
index 0815873..83dd05b 100644
--- a/example.c
+++ b/example.c
@@ -2,9 +2,9 @@
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
- * Last changed in libpng 1.2.1 December 7, 2001.
+ * Last changed in libpng 1.2.35 [February 14, 2009]
* This file has been placed in the public domain by the authors.
- * Maintained 1998-2007 Glenn Randers-Pehrson
+ * Maintained 1998-2009 Glenn Randers-Pehrson
* Maintained 1996, 1997 Andreas Dilger)
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/
@@ -204,7 +204,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
- png_set_gray_1_2_4_to_8(png_ptr);
+ png_set_expand_gray_1_2_4_to_8(png_ptr);
/* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets.
@@ -342,11 +342,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* The easiest way to read the image: */
png_bytep row_pointers[height];
+ /* Clear the pointer array */
+ for (row = 0; row < height; row++)
+ row_pointers[row] = NULL;
+
for (row = 0; row < height; row++)
- {
row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
info_ptr));
- }
/* Now it's time to read the image. One of these methods is REQUIRED */
#ifdef entire /* Read the entire image in one go */
@@ -505,7 +507,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
* shown below:
*/
/* Check if row_num is in bounds. */
- if((row_num >= 0) && (row_num < height))
+ if ((row_num >= 0) && (row_num < height))
{
/* Get pointer to corresponding row in our
* PNG read buffer.
@@ -515,7 +517,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
/* If both rows are allocated then copy the new row
* data to the corresponding row data.
*/
- if((old_row != NULL) && (new_row != NULL))
+ if ((old_row != NULL) && (new_row != NULL))
png_progressive_combine_row(png_ptr, old_row, new_row);
}
/*
@@ -608,7 +610,7 @@ void write_png(char *file_name /* , ... other image information ... */)
/* set up the output control if you are using standard C streams */
png_init_io(png_ptr, fp);
#else no_streams /* I/O initialization method 2 */
- /* If you are using replacement read functions, instead of calling
+ /* If you are using replacement write functions, instead of calling
* png_init_io() here you would call */
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
user_IO_flush_function);
@@ -637,7 +639,7 @@ void write_png(char *file_name /* , ... other image information ... */)
/* set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
- * png_sizeof (png_color));
+ * png_sizeof(png_color));
/* ... set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
/* You must not free palette here, because png_set_PLTE only makes a link to
@@ -771,9 +773,7 @@ void write_png(char *file_name /* , ... other image information ... */)
/* If you are only writing one row at a time, this works */
for (y = 0; y < height; y++)
- {
png_write_rows(png_ptr, &row_pointers[y], 1);
- }
}
#endif no_entire /* use only one output method */
@@ -793,13 +793,13 @@ void write_png(char *file_name /* , ... other image information ... */)
allocated it with malloc() instead of png_malloc(), use free() instead
of png_free(). */
png_free(png_ptr, palette);
- palette=NULL;
+ palette = NULL;
/* Similarly, if you png_malloced any data that you passed in with
png_set_something(), such as a hist or trans array, free it here,
when you can be sure that libpng is through with it. */
png_free(png_ptr, trans);
- trans=NULL;
+ trans = NULL;
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, &info_ptr);