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

« back to all changes in this revision

Viewing changes to PNG/libpng/example.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
#if 0 /* in case someone actually tries to compile this */
3
3
 
4
 
/* example.c - an example of using libpng */
 
4
/* example.c - an example of using libpng
 
5
 * Last changed in libpng 1.2.1 December 7, 2001.
 
6
 * This file has been placed in the public domain by the authors.
 
7
 * Maintained 1998-2001 Glenn Randers-Pehrson
 
8
 * Maintained 1996, 1997 Andreas Dilger)
 
9
 * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
 
10
 */
5
11
 
6
12
/* This is an example of how to use libpng to read and write PNG files.
7
13
 * The file libpng.txt is much more verbose then this.  If you have not
194
200
 
195
201
   /* Expand paletted colors into true RGB triplets */
196
202
   if (color_type == PNG_COLOR_TYPE_PALETTE)
197
 
      png_set_palette_rgb(png_ptr);
 
203
      png_set_palette_to_rgb(png_ptr);
198
204
 
199
205
   /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
200
206
   if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
490
496
 * In this function you will receive a pointer to new row data from
491
497
 * libpng called new_row that is to replace a corresponding row (of
492
498
 * the same data format) in a buffer allocated by your application.
493
 
 * 
 
499
 *
494
500
 * The new row data pointer new_row may be NULL, indicating there is
495
501
 * no new data to be replaced (in cases of interlace loading).
496
 
 * 
 
502
 *
497
503
 * If new_row is not NULL then you need to call
498
504
 * png_progressive_combine_row() to replace the corresponding row as
499
505
 * shown below:
631
637
 
632
638
   /* set the palette if there is one.  REQUIRED for indexed-color images */
633
639
   palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
634
 
             * sizeof (png_color));
 
640
             * png_sizeof (png_color));
635
641
   /* ... set palette colors ... */
636
642
   png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
637
643
   /* You must not free palette here, because png_set_PLTE only makes a link to
741
747
   png_uint_32 k, height, width;
742
748
   png_byte image[height][width*bytes_per_pixel];
743
749
   png_bytep row_pointers[height];
 
750
 
 
751
   if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
 
752
     png_error (png_ptr, "Image is too tall to process in memory");
 
753
 
744
754
   for (k = 0; k < height; k++)
745
755
     row_pointers[k] = image + k*width*bytes_per_pixel;
746
756