Compare commits
51 Commits
v1.0.5d
...
v1.0.12bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e68f5a361b | ||
|
|
328353990f | ||
|
|
82ae383331 | ||
|
|
e1eff58f87 | ||
|
|
f64a06f5ec | ||
|
|
87c6bc984a | ||
|
|
13cfbac075 | ||
|
|
e164447858 | ||
|
|
1909560348 | ||
|
|
d4e8109a48 | ||
|
|
be9de0f428 | ||
|
|
cdf140beec | ||
|
|
231e687411 | ||
|
|
76e5fd642e | ||
|
|
f05f8033b8 | ||
|
|
408b421265 | ||
|
|
2ad31ae31f | ||
|
|
f6b4f45c7e | ||
|
|
d56aca7104 | ||
|
|
f5ed0e130c | ||
|
|
fbbb5ecb52 | ||
|
|
5e5c1e1f56 | ||
|
|
32fc5ceb91 | ||
|
|
4766a244b2 | ||
|
|
a4d54bdb4a | ||
|
|
ff9c947a1a | ||
|
|
15dac0b14e | ||
|
|
316f97a063 | ||
|
|
3d5a520610 | ||
|
|
98b0ff4998 | ||
|
|
1394480f4b | ||
|
|
1f2d559f70 | ||
|
|
db66d44801 | ||
|
|
d436672048 | ||
|
|
104622bebb | ||
|
|
fc4a143ec6 | ||
|
|
ec61c23d56 | ||
|
|
1ef65b6742 | ||
|
|
752945701e | ||
|
|
98c9d73605 | ||
|
|
6942d53c25 | ||
|
|
326320e5a9 | ||
|
|
228bd390ac | ||
|
|
4accabb590 | ||
|
|
38e6e77419 | ||
|
|
81fdf8aca1 | ||
|
|
68ea243ca3 | ||
|
|
520a764cd7 | ||
|
|
a77ef625a6 | ||
|
|
61c32d9e66 | ||
|
|
166c5a397e |
52
ANNOUNCE
@@ -1,46 +1,20 @@
|
||||
|
||||
Libpng 1.0.5d - November 29, 1999
|
||||
Libpng 1.0.12beta1 - May 14, 2001
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
This is a public release of libpng, intended for use in production codes.
|
||||
|
||||
Changes since the last public release (1.0.5):
|
||||
Changes since the last public release (1.0.11):
|
||||
|
||||
version libpng-1.0.5a October 23, 1999
|
||||
Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
|
||||
Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
|
||||
Further optimization and bugfix of pngvcrd.c
|
||||
Revised pngset.c so that it does not allocate or free memory in the user's
|
||||
text_ptr structure. Instead, it makes its own copy.
|
||||
Created separate write_end_info_struct in pngtest.c for a more severe test.
|
||||
Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak.
|
||||
version libpng-1.0.5b November 23, 1999
|
||||
Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and
|
||||
PNG_FLAG_WROTE_tIME from flags to mode.
|
||||
Added png_write_info_before_PLTE() function.
|
||||
Fixed some typecasting in contrib/gregbook/*.c
|
||||
Updated scripts/makevms.com and added makevms.com to contrib/gregbook
|
||||
and contrib/pngminus (Martin Zinser)
|
||||
version libpng-1.0.5c November 26, 1999
|
||||
Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr.
|
||||
Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
|
||||
accomodate making DLL's: Moved usr_png_ver from global variable to function
|
||||
png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and
|
||||
eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays
|
||||
into pngtypes.h. Eliminated use of global png_pass arrays. Declared the
|
||||
png_CHNK and png_pass arrays to be "const". Made the global arrays
|
||||
available to applications (although none are used in libpng itself) when
|
||||
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
|
||||
Removed some extraneous "-I" from contrib/pngminus/makefile.std
|
||||
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
|
||||
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
|
||||
version 1.0.5d [November 29, 1999]
|
||||
Add type cast (png_const_charp) two places in png.c
|
||||
Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
|
||||
Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
|
||||
to applications a macro "PNG_USE_LOCAL_ARRAYS".
|
||||
#ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
|
||||
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
|
||||
Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot)
|
||||
Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h
|
||||
Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings.
|
||||
Bumped DLLNUM to 2.
|
||||
Added a check for attempts to read or write PLTE in grayscale PNG datastreams.
|
||||
Eliminated the png_error about apps using png_read|write_init(). Instead,
|
||||
libpng will reallocate the png_struct and info_struct if they are too small.
|
||||
This achieves future binary compatibility for old applications written for
|
||||
libpng-0.88 and earlier.
|
||||
Modified png_create_struct so it passes user mem_ptr to user memory allocator.
|
||||
|
||||
Send comments/corrections/commendations to
|
||||
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
|
||||
|
||||
441
CHANGES
@@ -123,6 +123,7 @@ version 0.90 [January, 1997]
|
||||
- all chunk handling routines have the same prototypes, so we will
|
||||
be able to handle all chunks via a callback mechanism
|
||||
try to fix Linux "setjmp" buffer size problems
|
||||
removed png_large_malloc, png_large_free, and png_realloc functions.
|
||||
version 0.95 [March, 1997]
|
||||
fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
|
||||
fixed bug in PNG file signature compares when start != 0
|
||||
@@ -259,6 +260,7 @@ version 0.99h [March 6, 1998, evening]
|
||||
Minor changes to previous minor changes to pngtest.c
|
||||
Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED
|
||||
and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
|
||||
Added user transform capability
|
||||
version 1.00 [March 7, 1998]
|
||||
Changed several typedefs in pngrutil.c
|
||||
Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
|
||||
@@ -377,7 +379,7 @@ version 1.0.2a [December 30, 1998]
|
||||
Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
|
||||
Removed lines after Dynamic Dependencies" in makefile.aco .
|
||||
Revised makefile.dec to make a shared library (Jeremie Petit).
|
||||
Removed trailing blanks from all files.
|
||||
Removed trailing blanks from all files.
|
||||
version 1.0.2a [January 6, 1999]
|
||||
Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h
|
||||
Added "if" tests to silence complaints about unused png_ptr in png.h and png.c
|
||||
@@ -390,7 +392,7 @@ version 1.0.3 [January 14, 1999]
|
||||
version 1.0.3a [August 12, 1999]
|
||||
Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
|
||||
if an attempt is made to read an interlaced image when it's not supported.
|
||||
Added check if png_ptr->trans is defined before free'ing it in pngread.c
|
||||
Added check if png_ptr->trans is defined before freeing it in pngread.c
|
||||
Modified the Y2K statement to include versions back to version 0.71
|
||||
Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
|
||||
Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
|
||||
@@ -503,7 +505,7 @@ version 1.0.5c [November 26, 1999]
|
||||
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
|
||||
Removed some extraneous "-I" from contrib/pngminus/makefile.std
|
||||
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
|
||||
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
|
||||
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
|
||||
version 1.0.5d [November 29, 1999]
|
||||
Add type cast (png_const_charp) two places in png.c
|
||||
Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
|
||||
@@ -511,3 +513,436 @@ version 1.0.5d [November 29, 1999]
|
||||
to applications a macro "PNG_USE_LOCAL_ARRAYS".
|
||||
#ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
|
||||
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
|
||||
version 1.0.5e [November 30, 1999]
|
||||
Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
|
||||
structure; refactored the inflate/deflate support to make adding new chunks
|
||||
with trailing compressed parts easier in the future, and added new functions
|
||||
png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
|
||||
png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
|
||||
NOTE: Applications that write text chunks MUST define png_text->lang
|
||||
before calling png_set_text(). It must be set to NULL if you want to
|
||||
write tEXt or zTXt chunks. If you want your application to be able to
|
||||
run with older versions of libpng, use
|
||||
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
png_text[i].lang = NULL;
|
||||
#endif
|
||||
|
||||
Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
|
||||
offsets (Eric S. Raymond).
|
||||
Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
|
||||
PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
|
||||
macros, leaving the separate macros also available.
|
||||
Removed comments on #endifs at the end of many short, non-nested #if-blocks.
|
||||
version 1.0.5f [December 6, 1999]
|
||||
Changed makefile.solaris to issue a warning about potential problems when
|
||||
the ucb "ld" is in the path ahead of the ccs "ld".
|
||||
Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
|
||||
Added sCAL chunk support (Eric S. Raymond).
|
||||
version 1.0.5g [December 7, 1999]
|
||||
Fixed "png_free_spallettes" typo in png.h
|
||||
Added code to handle new chunks in pngpread.c
|
||||
Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block
|
||||
Added "translated_key" to png_text structure and png_write_iTXt().
|
||||
Added code in pngwrite.c to work around a newly discovered zlib bug.
|
||||
version 1.0.5h [December 10, 1999]
|
||||
NOTE: regarding the note for version 1.0.5e, the following must also
|
||||
be included in your code:
|
||||
png_text[i].translated_key = NULL;
|
||||
Unknown chunk handling is now supported.
|
||||
Option to eliminate all floating point support was added. Some new
|
||||
fixed-point functions such as png_set_gAMA_fixed() were added.
|
||||
Expanded tabs and removed trailing blanks in source files.
|
||||
version 1.0.5i [December 13, 1999]
|
||||
Added some type casts to silence compiler warnings.
|
||||
Renamed "png_free_spalette" to "png_free_spalettes" for consistency.
|
||||
Removed leading blanks from a #define in pngvcrd.c
|
||||
Added some parameters to the new png_set_keep_unknown_chunks() function.
|
||||
Added a test for up->location != 0 in the first instance of writing
|
||||
unknown chunks in pngwrite.c
|
||||
Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to
|
||||
prevent recursion.
|
||||
Added png_free_hIST() function.
|
||||
Various patches to fix bugs in the sCAL and integer cHRM processing,
|
||||
and to add some convenience macros for use with sCAL.
|
||||
version 1.0.5j [December 21, 1999]
|
||||
Changed "unit" parameter of png_write_sCAL from png_byte to int, to work
|
||||
around buggy compilers.
|
||||
Added new type "png_fixed_point" for integers that hold float*100000 values
|
||||
Restored backward compatibility of tEXt/zTXt chunk processing:
|
||||
Restored the first four members of png_text to the same order as v.1.0.5d.
|
||||
Added members "lang_key" and "itxt_length" to png_text struct. Set
|
||||
text_length=0 when "text" contains iTXt data. Use the "compression"
|
||||
member to distinguish among tEXt/zTXt/iTXt types. Added
|
||||
PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros.
|
||||
The "Note" above, about backward incompatibility of libpng-1.0.5e, no
|
||||
longer applies.
|
||||
Fixed png_read|write_iTXt() to read|write parameters in the right order,
|
||||
and to write the iTXt chunk after IDAT if it appears in the end_ptr.
|
||||
Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs)
|
||||
Reversed the order of trying to write floating-point and fixed-point gAMA.
|
||||
version 1.0.5k [December 27, 1999]
|
||||
Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
|
||||
Added png_handle_as_unknown() function (Glenn)
|
||||
Added png_free_chunk_list() function and chunk_list and num_chunk_list members
|
||||
of png_ptr.
|
||||
Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE.
|
||||
Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings
|
||||
about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored)
|
||||
Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR).
|
||||
Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is.
|
||||
Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP().
|
||||
version 1.0.5l [January 1, 2000]
|
||||
Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr()
|
||||
for setting a callback function to handle unknown chunks and for
|
||||
retrieving the associated user pointer (Glenn).
|
||||
version 1.0.5m [January 7, 2000]
|
||||
Added high-level functions png_read_png(), png_write_png(), png_free_pixels().
|
||||
version 1.0.5n [January 9, 2000]
|
||||
Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its
|
||||
own memory for info_ptr->palette. This makes it safe for the calling
|
||||
application to free its copy of the palette any time after it calls
|
||||
png_set_PLTE().
|
||||
version 1.0.5o [January 20, 2000]
|
||||
Cosmetic changes only (removed some trailing blanks and TABs)
|
||||
version 1.0.5p [January 31, 2000]
|
||||
Renamed pngdll.mak to makefile.bd32
|
||||
Cosmetic changes in pngtest.c
|
||||
version 1.0.5q [February 5, 2000]
|
||||
Relocated the makefile.solaris warning about PATH problems.
|
||||
Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
|
||||
Revised makefile.gcmmx
|
||||
Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros
|
||||
version 1.0.5r [February 7, 2000]
|
||||
Removed superfluous prototype for png_get_itxt from png.h
|
||||
Fixed a bug in pngrtran.c that improperly expanded the background color.
|
||||
Return *num_text=0 from png_get_text() when appropriate, and fix documentation
|
||||
of png_get_text() in libpng.txt/libpng.3.
|
||||
version 1.0.5s [February 18, 2000]
|
||||
Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the
|
||||
new error handler that's planned for the next libpng release, and changed
|
||||
example.c, pngtest.c, and contrib programs to use this macro.
|
||||
Revised some of the DLL-export macros in pngconf.h (Greg Roelofs)
|
||||
Fixed a bug in png_read_png() that caused it to fail to expand some images
|
||||
that it should have expanded.
|
||||
Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions
|
||||
in pngget.c
|
||||
Changed the allocation of palette, history, and trans arrays back to
|
||||
the version 1.0.5 method (linking instead of copying) which restores
|
||||
backward compatibility with version 1.0.5. Added some remarks about
|
||||
that in example.c. Added "free_me" member to info_ptr and png_ptr
|
||||
and added png_free_data() function.
|
||||
Updated makefile.linux and makefile.gccmmx to make directories conditionally.
|
||||
Made cosmetic changes to pngasmrd.h
|
||||
Added png_set_rows() and png_get_rows(), for use with png_read|write_png().
|
||||
Modified png_read_png() to allocate info_ptr->row_pointers only if it
|
||||
hasn't already been allocated.
|
||||
version 1.0.5t [March 4, 2000]
|
||||
Changed png_jmp_env() migration aiding macro to png_jmpbuf().
|
||||
Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c
|
||||
Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when
|
||||
PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b
|
||||
Files in contrib/gregbook were revised to use png_jmpbuf() and to select
|
||||
a 24-bit visual if one is available, and to allow abbreviated options.
|
||||
Files in contrib/pngminus were revised to use the png_jmpbuf() macro.
|
||||
Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s
|
||||
version 1.0.5u [March 5, 2000]
|
||||
Simplified the code that detects old png.h in png.c and pngtest.c
|
||||
Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp)
|
||||
Increased precision of rgb_to_gray calculations from 8 to 15 bits and
|
||||
added png_set_rgb_to_gray_fixed() function.
|
||||
Added makefile.bc32 (32-bit Borland C++, C mode)
|
||||
version 1.0.5v [March 11, 2000]
|
||||
Added some parentheses to the png_jmpbuf macro definition.
|
||||
Updated references to the zlib home page, which has moved to freesoftware.com.
|
||||
Corrected bugs in documentation regarding png_read_row() and png_write_row().
|
||||
Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt.
|
||||
Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3,
|
||||
revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin)
|
||||
version 1.0.6 [March 20, 2000]
|
||||
Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c
|
||||
Added makefile.sggcc (SGI IRIX with gcc)
|
||||
version 1.0.6d [April 7, 2000]
|
||||
Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO
|
||||
Added data_length parameter to png_decompress_chunk() function
|
||||
Revised documentation to remove reference to abandoned png_free_chnk functions
|
||||
Fixed an error in png_rgb_to_gray_fixed()
|
||||
Revised example.c, usage of png_destroy_write_struct().
|
||||
Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
|
||||
Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c
|
||||
Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
|
||||
version 1.0.6e [April 9, 2000]
|
||||
Added png_data_freer() function.
|
||||
In the code that checks for over-length tRNS chunks, added check of
|
||||
info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann)
|
||||
Minor revisions of libpng.txt/libpng.3.
|
||||
Check for existing data and free it if the free_me flag is set, in png_set_*()
|
||||
and png_handle_*().
|
||||
Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED
|
||||
is defined.
|
||||
Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c
|
||||
and mentioned the purposes of the two macros in libpng.txt/libpng.3.
|
||||
version 1.0.6f [April 14, 2000]
|
||||
Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data.
|
||||
Add checks in png_set_text() for NULL members of the input text structure.
|
||||
Revised libpng.txt/libpng.3.
|
||||
Removed superfluous prototype for png_set_itxt from png.h
|
||||
Removed "else" from pngread.c, after png_error(), and changed "0" to "length".
|
||||
Changed several png_errors about malformed ancillary chunks to png_warnings.
|
||||
version 1.0.6g [April 24, 2000]
|
||||
Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined.
|
||||
Relocated paragraph about png_set_background() in libpng.3/libpng.txt
|
||||
and other revisions (Matthias Benckmann)
|
||||
Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and
|
||||
png_ptr members to restore binary compatibility with libpng-1.0.5
|
||||
(breaks compatibility with libpng-1.0.6).
|
||||
version 1.0.6h [April 24, 2000]
|
||||
Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds
|
||||
libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h)
|
||||
This is a temporary change for test purposes.
|
||||
version 1.0.6i [May 2, 2000]
|
||||
Rearranged some members at the end of png_info and png_struct, to put
|
||||
unknown_chunks_num and free_me within the original size of the png_structs
|
||||
and free_me, png_read_user_fn, and png_free_fn within the original png_info,
|
||||
because some old applications allocate the structs directly instead of
|
||||
using png_create_*().
|
||||
Added documentation of user memory functions in libpng.txt/libpng.3
|
||||
Modified png_read_png so that it will use user_allocated row_pointers
|
||||
if present, unless free_me directs that it be freed, and added description
|
||||
of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3.
|
||||
Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version
|
||||
1.00) members of png_struct and png_info, to regain binary compatibility
|
||||
when you define this macro. Capabilities lost in this event
|
||||
are user transforms (new in version 1.0.0),the user transform pointer
|
||||
(new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT,
|
||||
the high-level interface, and unknown chunks support (all new in 1.0.6).
|
||||
This was necessary because of old applications that allocate the structs
|
||||
directly as authors were instructed to do in libpng-0.88 and earlier,
|
||||
instead of using png_create_*().
|
||||
Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which
|
||||
can be used to detect codes that directly allocate the structs, and
|
||||
code to check these modes in png_read_init() and png_write_init() and
|
||||
generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED
|
||||
was not defined.
|
||||
Added makefile.intel and updated makefile.watcom (Pawel Mrochen)
|
||||
version 1.0.6j [May 3, 2000]
|
||||
Overloaded png_read_init() and png_write_init() with macros that convert
|
||||
calls to png_read_init_2() or png_write_init_2() that check the version
|
||||
and structure sizes.
|
||||
version 1.0.7beta11 [May 7, 2000]
|
||||
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
|
||||
which are no longer used.
|
||||
Eliminated the three new members of png_text when PNG_NO_iTXt_SUPPORTED
|
||||
or PNG_LEGACY_SUPPORTED is defined.
|
||||
Made PNG_NO_ITXT_SUPPORTED the default setting, to avoid memory overrun
|
||||
when old applications fill the info_ptr->text structure directly.
|
||||
Added PNGAPI macro, and added it to the definitions of all exported functions.
|
||||
Relocated version macro definitions ahead of the includes of zlib.h and
|
||||
pngconf.h in png.h.
|
||||
version 1.0.7beta12 [May 12, 2000]
|
||||
Revised pngset.c to avoid a problem with expanding the png_debug macro.
|
||||
Deleted some extraneous defines from pngconf.h
|
||||
Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined.
|
||||
Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined.
|
||||
Added png_access_version_number() function.
|
||||
Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data().
|
||||
Expanded libpng.3/libpng.txt information about png_data_freer().
|
||||
version 1.0.7beta14 [May 17, 2000] (beta13 was not published)
|
||||
Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as
|
||||
warnings instead of errors, as pngrutil.c does.
|
||||
Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png()
|
||||
will actually write IDATs.
|
||||
Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32.
|
||||
Make png_free_data() ignore its final parameter except when freeing data
|
||||
that can have multiple instances (text, sPLT, unknowns).
|
||||
Fixed a new bug in png_set_rows().
|
||||
Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5.
|
||||
Added png_set_invalid() function.
|
||||
Fixed incorrect illustrations of png_destroy_write_struct() in example.c.
|
||||
version 1.0.7beta15 [May 30, 2000]
|
||||
Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce
|
||||
fewer error messages.
|
||||
Rearranged checks for Z_OK to check the most likely path first in pngpread.c
|
||||
and pngwutil.c.
|
||||
Added checks in pngtest.c for png_create_*() returning NULL, and mentioned
|
||||
in libpng.txt/libpng.3 the need for applications to check this.
|
||||
Changed names of png_default_*() functions in pngtest to pngtest_*().
|
||||
Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32.
|
||||
Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c
|
||||
Set each pointer to NULL after freeing it in png_free_data().
|
||||
Worked around a problem in pngconf.h; AIX's strings.h defines an "index"
|
||||
macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos)
|
||||
Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux).
|
||||
version 1.0.7beta16 [June 4, 2000]
|
||||
Revised the workaround of AIX string.h "index" bug.
|
||||
Added a check for overlength PLTE chunk in pngrutil.c.
|
||||
Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer
|
||||
indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler.
|
||||
Added a warning in png_decompress_chunk() when it runs out of data, e.g.
|
||||
when it tries to read an erroneous PhotoShop iCCP chunk.
|
||||
Added PNG_USE_DLL macro.
|
||||
Revised the copyright/disclaimer/license notice.
|
||||
Added contrib/msvctest directory
|
||||
version 1.0.7rc1 [June 9, 2000]
|
||||
Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200)
|
||||
Added contrib/visupng directory (Willem van Schaik)
|
||||
version 1.0.7beta18 [June 23, 2000]
|
||||
Revised PNGAPI definition, and pngvcrd.c to work with __GCC__
|
||||
and do not redefine PNGAPI if it is passed in via a compiler directive.
|
||||
Revised visupng/PngFile.c to remove returns from within the Try block.
|
||||
Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros.
|
||||
Updated contrib/visupng/cexcept.h to version 1.0.0.
|
||||
Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks.
|
||||
version 1.0.7rc2 [June 28, 2000]
|
||||
Updated license to include disclaimers required by UCITA.
|
||||
Fixed "DJBPP" typo in pnggccrd.c introduced in beta18.
|
||||
version 1.0.7 [July 1, 2000]
|
||||
Revised the definition of "trans_values" in libpng.3/libpng.txt
|
||||
version 1.0.8beta1 [July 8, 2000]
|
||||
Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks.
|
||||
Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and
|
||||
pngwutil.c.
|
||||
Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h.
|
||||
Removed unused "#include <assert.h>" from png.c
|
||||
Added WindowsCE support.
|
||||
Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment.
|
||||
version 1.0.8beta2 [July 10, 2000]
|
||||
Added project files to the wince directory and made further revisions
|
||||
of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE.
|
||||
version 1.0.8beta3 [July 11, 2000]
|
||||
Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS()
|
||||
for indexed-color input files to avoid potential double-freeing trans array
|
||||
under some unusual conditions; problem was introduced in version 1.0.6f.
|
||||
Further revisions to pngtest.c and files in the wince subdirectory.
|
||||
version 1.0.8beta4 [July 14, 2000]
|
||||
Added the files pngbar.png and pngbar.jpg to the distribution.
|
||||
Added makefile.cygwin, and cygwin support in pngconf.h
|
||||
Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory)
|
||||
version 1.0.8rc1 [July 16, 2000]
|
||||
Revised png_debug() macros and statements to eliminate compiler warnings.
|
||||
version 1.0.8 [July 24, 2000]
|
||||
Added png_flush() in pngwrite.c, after png_write_IEND().
|
||||
Updated makefile.hpux to build a shared library.
|
||||
version 1.0.9beta1 [November 10, 2000]
|
||||
Fixed typo in scripts/makefile.hpux
|
||||
Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
|
||||
Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
|
||||
Changed "cdrom.com" in documentation to "libpng.org"
|
||||
Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
|
||||
Changed type of "params" from voidp to png_voidp in png_read|write_png().
|
||||
Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h.
|
||||
Revised the 3 instances of WRITEFILE in pngtest.c.
|
||||
Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory.
|
||||
Updated png.rc in dll/msvc project
|
||||
Revised makefile.dec to define and use LIBPATH and INCPATH
|
||||
Increased size of global png_libpng_ver[] array from 12 to 18 chars.
|
||||
Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const.
|
||||
Removed duplicate png_crc_finish() from png_handle_bKGD() function.
|
||||
Added a warning when application calls png_read_update_info() multiple times.
|
||||
Revised makefile.cygwin
|
||||
Fixed bugs in iCCP support in pngrutil.c and pngwutil.c.
|
||||
Replaced png_set_empty_plte_permitted() with png_permit_mng_features().
|
||||
version 1.0.9beta2 [November 19, 2000]
|
||||
Renamed the "dll" subdirectory "projects".
|
||||
Added borland project files to "projects" subdirectory.
|
||||
Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate.
|
||||
Add error message in png_set_compression_buffer_size() when malloc fails.
|
||||
version 1.0.9beta3 [November 23, 2000]
|
||||
Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project.
|
||||
Removed the png_flush() in pngwrite.c that crashes some applications
|
||||
that don't set png_output_flush_fn.
|
||||
Added makefile.macosx and makefile.aix to scripts directory.
|
||||
version 1.0.9beta4 [December 1, 2000]
|
||||
Change png_chunk_warning to png_warning in png_check_keyword().
|
||||
Increased the first part of msg buffer from 16 to 18 in png_chunk_error().
|
||||
version 1.0.9beta5 [December 15, 2000]
|
||||
Added support for filter method 64 (for PNG datastreams embedded in MNG).
|
||||
version 1.0.9beta6 [December 18, 2000]
|
||||
Revised png_set_filter() to accept filter method 64 when appropriate.
|
||||
Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to
|
||||
help prevent applications from using MNG features in PNG datastreams.
|
||||
Added png_permit_mng_features() function.
|
||||
Revised libpng.3/libpng.txt. Changed "filter type" to "filter method".
|
||||
version 1.0.9rc1 [December 23, 2000]
|
||||
Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c
|
||||
Fixed error handling of unknown compression type in png_decompress_chunk().
|
||||
In pngconf.h, define __cdecl when _MSC_VER is defined.
|
||||
version 1.0.9beta7 [December 28, 2000]
|
||||
Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places.
|
||||
Revised memory management in png_set_hIST and png_handle_hIST in a backward
|
||||
compatible manner. PLTE and tRNS were revised similarly.
|
||||
Revised the iCCP chunk reader to ignore trailing garbage.
|
||||
version 1.0.9beta8 [January 12, 2001]
|
||||
Moved pngasmrd.h into pngconf.h.
|
||||
Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop.
|
||||
version 1.0.9beta9 [January 15, 2001]
|
||||
Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to
|
||||
wince and msvc project module definition files.
|
||||
Minor revision of makefile.cygwin.
|
||||
Fixed bug with progressive reading of narrow interlaced images in pngpread.c
|
||||
version 1.0.9beta10 [January 16, 2001]
|
||||
Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined.
|
||||
Fixed "png_mmx_supported" typo in project definition files.
|
||||
version 1.0.9beta11 [January 19, 2001]
|
||||
Updated makefile.sgi to make shared library.
|
||||
Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED
|
||||
by default, for the benefit of DLL forward compatibility. These will
|
||||
be re-enabled in version 1.2.0.
|
||||
version 1.0.9rc2 [January 22, 2001]
|
||||
Revised cygwin support.
|
||||
version 1.0.9 [January 31, 2001]
|
||||
Added check of cygwin's ALL_STATIC in pngconf.h
|
||||
Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos.
|
||||
version 1.0.10beta1 [March 14, 2001]
|
||||
Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc.
|
||||
Reformatted libpng.3 to eliminate bad line breaks.
|
||||
Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c
|
||||
Added prototype for png_mmx_support() near the top of pnggccrd.c
|
||||
Moved some error checking from png_handle_IHDR to png_set_IHDR.
|
||||
Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros.
|
||||
Revised png_mmx_support() function in pnggccrd.c
|
||||
Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c
|
||||
Fixed memory leak in contrib/visupng/PngFile.c
|
||||
Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version)
|
||||
Added warnings when retrieving or setting gamma=0.
|
||||
Increased the first part of msg buffer from 16 to 18 in png_chunk_warning().
|
||||
version 1.0.10rc1 [March 23, 2001]
|
||||
Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy,
|
||||
and png_strlen.
|
||||
Revised png_mmx_supported() function in pnggccrd.c to return proper value.
|
||||
Fixed bug in progressive reading (pngpread.c) with small images (height < 8).
|
||||
version 1.0.10 [March 30, 2001]
|
||||
Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin
|
||||
Added beos project files (Chris Herborth)
|
||||
version 1.0.11beta1 [April 3, 2001]
|
||||
Added type casts on several png_malloc() calls (Dimitri Papadapoulos).
|
||||
Removed a no-longer needed AIX work-around from pngconf.h
|
||||
Changed several "//" single-line comments to C-style in pnggccrd.c
|
||||
version 1.0.11beta2 [April 11, 2001]
|
||||
Removed PNGAPI from several functions whose prototypes did not have PNGAPI.
|
||||
Updated scripts/pngos2.def
|
||||
version 1.0.11beta3 [April 14, 2001]
|
||||
Added checking the results of many instances of png_malloc() for NULL
|
||||
version 1.0.11beta4 [April 20, 2001]
|
||||
Undid the changes from version 1.0.11beta3. Added a check for NULL return
|
||||
from user's malloc_fn().
|
||||
Removed some useless type casts of the NULL pointer.
|
||||
Added makefile.netbsd
|
||||
version 1.0.11 [April 27, 2001]
|
||||
Revised makefile.netbsd
|
||||
version 1.0.12beta1 [May 14, 2001]
|
||||
Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot)
|
||||
Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h
|
||||
Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings.
|
||||
Bumped DLLNUM to 2.
|
||||
Added a check for attempts to read or write PLTE in grayscale PNG datastreams.
|
||||
Eliminated the png_error about apps using png_read|write_init(). Instead,
|
||||
libpng will reallocate the png_struct and info_struct if they are too small.
|
||||
This achieves future binary compatibility for old applications written for
|
||||
libpng-0.88 and earlier.
|
||||
Modified png_create_struct so it passes user mem_ptr to user memory allocator.
|
||||
|
||||
Send comments/corrections/commendations to
|
||||
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
|
||||
|
||||
Glenn R-P
|
||||
|
||||
63
INSTALL
@@ -1,5 +1,5 @@
|
||||
|
||||
Installing libpng version 1.0.5d - November 29, 1999
|
||||
Installing libpng version 1.0.12beta1 - May 14, 2001
|
||||
|
||||
Before installing libpng, you must first install zlib. zlib
|
||||
can usually be found wherever you got libpng. zlib can be
|
||||
@@ -10,7 +10,7 @@ zlib.h and zconf.h include files that correspond to the
|
||||
version of zlib that's installed.
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-1.0.5d" or "lpng103" and "zlib-1.1.3"
|
||||
might be called "libpng-1.0.12beta1" or "lpng109" and "zlib-1.1.3"
|
||||
or "zlib113") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
@@ -23,8 +23,15 @@ Your directory structure should look like this:
|
||||
*.c
|
||||
contrib
|
||||
gregbook
|
||||
msvctest
|
||||
pngminus
|
||||
pngsuite
|
||||
visupng
|
||||
projects
|
||||
beos
|
||||
borland
|
||||
msvc
|
||||
wince
|
||||
scripts
|
||||
makefile.*
|
||||
pngtest.png
|
||||
@@ -36,23 +43,44 @@ Your directory structure should look like this:
|
||||
contrib
|
||||
etc.
|
||||
|
||||
First enter the zlib directory and follow the instructions
|
||||
in zlib/README. Then come back here and choose the
|
||||
appropriate makefile.sys in the scripts directory.
|
||||
If the line endings in the files look funny, you may wish to get the other
|
||||
distribution of libpng. It is available in both tar.gz (UNIX style line
|
||||
endings) and zip (DOS style line endings) formats.
|
||||
|
||||
If you are building libpng with MSVC, you can enter the libpng\msvc directory
|
||||
and follow the instructions in msvc\README.txt. You can build libpng for
|
||||
WindowsCE by entering the libpng\wince directory and following the
|
||||
instructions in the README* files.
|
||||
|
||||
Else enter the zlib directory and follow the instructions in zlib/README,
|
||||
then come back here and choose the appropriate makefile.sys in the scripts
|
||||
directory.
|
||||
|
||||
The files that are presently available in the scripts directory
|
||||
include
|
||||
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.12beta1)
|
||||
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.12beta1,
|
||||
uses assembler code tuned for Intel MMX platform)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
ftp://ftp.cs.wisc.edu/ghost)
|
||||
makefile.aix => AIX makefile
|
||||
makefile.cygwin => Cygwin/gcc makefile
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.hpgcc => HPUX makefile using gcc
|
||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
|
||||
makefile.intel => Intel C/C++ version 4.0 and later
|
||||
libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later
|
||||
makefile.macosx => MACOS X Makefile
|
||||
makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.12beta1)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5d)
|
||||
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5d)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.12beta1)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.mips => MIPS makefile
|
||||
makefile.acorn => Acorn makefile
|
||||
@@ -61,20 +89,21 @@ include
|
||||
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
|
||||
makefile.atari => Atari makefile
|
||||
makefile.beos => BEOS makefile for X86
|
||||
makefile.borland => Borland makefile
|
||||
build.bat => MS-DOS batch file for Borland compiler
|
||||
makefile.bor => Borland makefile (uses bcc)
|
||||
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
|
||||
makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5
|
||||
makefile.tc3 => Turbo C 3.0 makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses
|
||||
assembler code)
|
||||
assembler code tuned for Intel MMX platform)
|
||||
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does
|
||||
not use assembler code)
|
||||
makefile.turboc3 => Turbo C 3.0 makefile
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
||||
pngos2.def => OS/2 module definition file used by makefile.os2
|
||||
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||
makevms.com => VMS build script
|
||||
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
|
||||
SCOPTIONS.ppc => Used with smakefile.ppc
|
||||
|
||||
@@ -104,5 +133,5 @@ put the library in its final resting place (if you want to
|
||||
do that, run "make install" in the zlib directory first if necessary).
|
||||
|
||||
Further information can be found in the README and libpng.txt
|
||||
files, in the individual makefiles, in png.h, and the manual pages
|
||||
libpng.3 and png.5.
|
||||
files, in the individual makefiles, in png.h, in the README files in
|
||||
subdirectories of the LIB directory, and the manual pages libpng.3 and png.5.
|
||||
|
||||
60
KNOWNBUG
@@ -1,59 +1,7 @@
|
||||
|
||||
Known bugs and suggested enhancements in libpng-1.0.5
|
||||
Known bugs in libpng-1.0.11
|
||||
|
||||
1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when
|
||||
reading interlaced PNG files, when assembler code is enabled.
|
||||
|
||||
1. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
|
||||
|
||||
Loops need to be optimized everywhere
|
||||
|
||||
Make them count down instead of up -- Kevin Bracey
|
||||
|
||||
Optimizing compilers don't need this, and making
|
||||
the change would be error prone -- Tom Lane, Glenn R-P
|
||||
|
||||
Question whether i-- or --i is better.
|
||||
|
||||
STATUS: Under investigation, postponed until after
|
||||
libpng-1.0.5. About 160 loops will be turned around
|
||||
in libpng-1.0.Nn, for testing.
|
||||
|
||||
2. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
|
||||
|
||||
libpng-1.0.5 and earlier transform colors to gamma=1.0 space for
|
||||
merging with background, and then back to the image's gamma. The
|
||||
bit_depth of the intermediate (gamma=1.0) representation is probably
|
||||
not sufficient. In the typical gamma=1/2.2 situation, the linear
|
||||
pixels need about 4 more bits than the gamma-encoded ones, to avoid
|
||||
loss of precision. A similar situation exists with the rgb_to_gray
|
||||
operation.
|
||||
|
||||
STATUS: under development.
|
||||
|
||||
3. September 1999 -- ENHANCEMENT --
|
||||
|
||||
It should be possible to use libpng without floating-point aritmetic.
|
||||
|
||||
STATUS: Under investigation, implementation postponed until after
|
||||
libpng-1.0.5. The application interface will change because replacements
|
||||
for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
|
||||
functions will be needed.
|
||||
|
||||
4. October 1999 -- BUG
|
||||
|
||||
pngvcrd.c is failing for interlaced PNGs that have empty passes.
|
||||
|
||||
STATUS: A check for "width != 0" is required in several places.
|
||||
Fixed in libpng-1.0.5a/1.0.6
|
||||
|
||||
5. October 1999 -- BUG
|
||||
|
||||
Under MSVC++6.0 with debugging enabled, heap corruption was detected
|
||||
while destroying the png_write_ptr.
|
||||
|
||||
STATUS: This was fixed by modifying png_set_text (in pngset.c) to
|
||||
refrain from writing into the user's text_ptr. With this fix, however,
|
||||
pngwrite.c, while destroying the info_ptr, was failing to free the
|
||||
text->key strings. Fix for the latter problem is to duplicate code
|
||||
from png.c.
|
||||
|
||||
Fixed in libpng-1.0.5a/1.0.6
|
||||
STATUS: Under investigation.
|
||||
|
||||
84
LICENSE
@@ -1,28 +1,62 @@
|
||||
COPYRIGHT NOTICE:
|
||||
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
(libpng versions 0.5, May 1995, through 0.89c, May 1996)
|
||||
This copy of the libpng notices is provided for your convenience. In case of
|
||||
any discrepancy between this copy and the notices in the file png.h that is
|
||||
included in the libpng distribution, the latter shall prevail.
|
||||
|
||||
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
|
||||
If you modify libpng you may insert additional notices immediately following
|
||||
this sentence.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.0.12beta1, May 14, 2001, are
|
||||
Copyright (c) 2000, 2001 Glenn Randers-Pehrson
|
||||
and are distributed according to the same disclaimer and license as libpng-1.0.6
|
||||
with the following individuals added to the list of Contributing Authors
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Gilles Vollant
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
There is no warranty against interference with your enjoyment of the
|
||||
library or against infringement. There is no warranty that our
|
||||
efforts or the library will fulfill any of your particular purposes
|
||||
or needs. This library is provided with all faults, and the entire
|
||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
the user.
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-0.96,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
(libpng versions 0.90, December 1996, through 0.96, May 1997)
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
(libpng versions 0.97, January 1998, through 1.0.5d, November 29, 1999)
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
Sam Bushell
|
||||
Andreas Dilger
|
||||
Magnus Holmgren
|
||||
Tom Lane
|
||||
Dave Martindale
|
||||
Glenn Randers-Pehrson
|
||||
Greg Roelofs
|
||||
Tom Tanner
|
||||
|
||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
|
||||
Andreas Dilger
|
||||
Dave Martindale
|
||||
Guy Eric Schalnat
|
||||
Paul Schmidt
|
||||
Tom Tanner
|
||||
Willem van Schaik
|
||||
Tim Wegner
|
||||
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
@@ -37,16 +71,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
|
||||
source code, or portions hereof, for any purpose, without fee, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be
|
||||
misrepresented.
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
|
||||
2. Altered versions must be plainly marked as such
|
||||
and must not be misrepresented as being the
|
||||
original source.
|
||||
2. Altered versions must be plainly marked as such and
|
||||
must not be misrepresented as being the original source.
|
||||
|
||||
3. This Copyright notice may not be removed or
|
||||
altered from any source or altered source
|
||||
distribution.
|
||||
3. This Copyright notice may not be removed or altered from
|
||||
any source or altered source distribution.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
fee, and encourage the use of this source code as a component to
|
||||
@@ -54,17 +85,18 @@ supporting the PNG file format in commercial products. If you use this
|
||||
source code in a product, acknowledgment is not required but would be
|
||||
appreciated.
|
||||
|
||||
|
||||
A "png_get_copyright" function is available, for convenient use in "about"
|
||||
boxes and the like:
|
||||
|
||||
printf("%s",png_get_copyright(NULL));
|
||||
|
||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||
file "pngnow.png".
|
||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified is a
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
||||
certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
randeg@alum.rpi.edu
|
||||
November 29, 1999
|
||||
May 14, 2001
|
||||
|
||||
62
README
@@ -1,8 +1,12 @@
|
||||
README for libpng 1.0.5d - November 29, 1999 (shared library 2.1)
|
||||
README for libpng 1.0.12beta1 - May 14, 2001 (shared library 2.1)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
Libpng comes in two distribution formats. Get libpng-*.tar.gz if you
|
||||
want UNIX-style line endings in the text files, or lpng*.zip if you want
|
||||
DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
extensive use and testing since mid-1995. By late 1997 it had
|
||||
@@ -125,22 +129,27 @@ gladly listen. Even if your suggestion is not used for version
|
||||
|
||||
Files in this distribution:
|
||||
|
||||
ANNOUNCE => Announcement of this version, with recent changes
|
||||
CHANGES => Description of changes between libpng versions
|
||||
KNOWNBUG => List of known bugs and deficiencies
|
||||
LICENSE => License to use and redistribute libpng
|
||||
README => This file
|
||||
TODO => Things not implemented in the current library
|
||||
build.bat => MS-DOS batch file for Borland compiler
|
||||
descrip.mms => VMS project file
|
||||
Y2KINFO => Statement of Y2K compliance
|
||||
example.c => Example code for using libpng functions
|
||||
libpng.3 => manual page for libpng
|
||||
libpng.3 => manual page for libpng (includes libpng.txt)
|
||||
libpng.txt => Description of libpng and its functions
|
||||
libpngpf.3 => manual page for libpng's private functions
|
||||
png.5 => manual page for the PNG format
|
||||
png.c => Basic interface functions common to library
|
||||
png.h => Library function and interface declarations
|
||||
pngconf.h => System specific library configuration
|
||||
pngasmrd.h => Header file for assembler-coded functions
|
||||
pngerror.c => Error/warning message I/O functions
|
||||
pngget.c => Functions for retrieving info from struct
|
||||
pngmem.c => Memory handling functions
|
||||
pngbar.png => PNG logo, 88x31
|
||||
pngnow.png => PNG logo, 98x31
|
||||
pngpread.c => Progressive reading functions
|
||||
pngread.c => Read data/helper high-level functions
|
||||
pngrio.c => Lowest-level data read I/O functions
|
||||
@@ -158,22 +167,45 @@ Files in this distribution:
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
msvctest => Builds and runs pngtest using a MSVC workspace
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
projects => Contains project files and workspaces for building DLL
|
||||
beos => Contains a Beos workspace for building libpng
|
||||
borland => Contains a Borland workspace for building libpng
|
||||
and zlib
|
||||
msvc => Contains a Microsoft Visual C++ (MSVC) workspace
|
||||
for building libpng and zlib
|
||||
wince => Contains a Microsoft Visual C++ (Windows CD Toolkit)
|
||||
workspace for building libpng and zlib on WindowsCE
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng.so.2.1.0.12beta1)
|
||||
makefile.gcmmx => Linux/ELF makefile (gcc, creates
|
||||
libpng.so.2.1.0.12beta1, uses assembler code
|
||||
tuned for Intel MMX platform)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
ftp://ftp.cs.wisc.edu/ghost)
|
||||
makefile.aix => AIX makefile
|
||||
makefile.cygwin => Cygwin/gcc makefile
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.hpgcc => HPUX makefile using gcc
|
||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
|
||||
makefile.intel => Intel C/C++ version 4.0 and later
|
||||
libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later
|
||||
makefile.macosx => MACOS X Makefile
|
||||
makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD
|
||||
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
|
||||
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.12beta1)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.solaris => Solaris 2.X makefile
|
||||
(gcc, creates libpng.so.2.1.0.5d)
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng.so.2.1.0.5d)
|
||||
(gcc, creates libpng.so.2.1.0.12beta1)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.mips => MIPS makefile
|
||||
makefile.acorn => Acorn makefile
|
||||
@@ -183,20 +215,21 @@ Files in this distribution:
|
||||
scripts/SCOPTIONS.ppc)
|
||||
makefile.atari => Atari makefile
|
||||
makefile.beos => BEOS makefile for X86
|
||||
makefile.borland => Borland makefile
|
||||
build.bat => MS-DOS batch file for Borland compiler
|
||||
makefile.bor => Borland makefile (uses bcc)
|
||||
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
|
||||
makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5
|
||||
makefile.tc3 => Turbo C 3.0 makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and
|
||||
later (uses assembler code)
|
||||
later (uses assembler code tuned for Intel MMX
|
||||
platform)
|
||||
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and
|
||||
later (does not use assembler code)
|
||||
makefile.turboc3 => Turbo C 3.0 makefile
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
||||
pngos2.def => OS/2 module definition file used by makefile.os2
|
||||
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||
makevms.com => VMS build script
|
||||
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
|
||||
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
|
||||
SCOPTIONS.ppc => Used with smakefile.ppc
|
||||
|
||||
@@ -204,7 +237,6 @@ Good luck, and happy coding.
|
||||
|
||||
-Glenn Randers-Pehrson
|
||||
Internet: randeg@alum.rpi.edu
|
||||
Web: http://www.rpi.edu/~randeg/index.html
|
||||
|
||||
-Andreas Eric Dilger
|
||||
Internet: adilger@enel.ucalgary.ca
|
||||
|
||||
16
TODO
@@ -1,14 +1,12 @@
|
||||
TODO - list of things to do for libpng:
|
||||
|
||||
Final bug fixes.
|
||||
Fix problem with C++ and EXTERN "C".
|
||||
Improve API by hiding the png_struct and png_info structs.
|
||||
Finish work on the no-floating-point version (including gamma compensation)
|
||||
Better C++ wrapper/full C++ implementation?
|
||||
Keep up with public chunks.
|
||||
sPLT chunk handling.
|
||||
Fix problem with C++ and EXTERN "C".
|
||||
cHRM transformation.
|
||||
Support for application-defined chunk handlers.
|
||||
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
|
||||
High-level API for reading images.
|
||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||
Improved dithering.
|
||||
Multi-lingual error and warning message support.
|
||||
@@ -17,8 +15,10 @@ Man pages for function calls.
|
||||
Better documentation.
|
||||
Better filter selection
|
||||
(counting huffman bits/precompression? filter inertia? filter costs?).
|
||||
Optional palette (sPLT) creation.
|
||||
Histogram creation.
|
||||
Text conversion between different code pages (Latin-1 -> Mac and DOS).
|
||||
Improve API by hiding the info_ptr.
|
||||
Make a no-floating-point version.
|
||||
Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety?
|
||||
Build gamma tables using fixed point (and do away with floating point entirely).
|
||||
Use greater precision when changing to linear gamma for compositing against
|
||||
background and doing rgb-to-gray transformation.
|
||||
Investigate pre-incremented loop counters and other loop constructions.
|
||||
|
||||
30
Y2KINFO
@@ -1,29 +1,29 @@
|
||||
Y2K compliance in libpng:
|
||||
=========================
|
||||
|
||||
November 29, 1999
|
||||
|
||||
|
||||
May 14, 2001
|
||||
|
||||
Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.0.5d are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.0.12beta1 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
|
||||
Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||
that will hold years up to 65535. The other two hold the date in text
|
||||
format, and will hold years up to 9999.
|
||||
|
||||
|
||||
The integer is
|
||||
"png_uint_16 year" in png_time_struct.
|
||||
|
||||
|
||||
The strings are
|
||||
"png_charp time_buffer" in png_struct and
|
||||
"near_time_buffer", which is a local character string in png.c.
|
||||
|
||||
|
||||
There are seven time-related functions:
|
||||
|
||||
png_convert_to_rfc_1123() in png.c
|
||||
png_convert_to_rfc_1123() in png.c
|
||||
(formerly png_convert_to_rfc_1152() in error)
|
||||
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
|
||||
png_convert_from_time_t() in pngwrite.c
|
||||
@@ -31,8 +31,8 @@
|
||||
png_handle_tIME() in pngrutil.c, called in pngread.c
|
||||
png_set_tIME() in pngset.c
|
||||
png_write_tIME() in pngwutil.c, called in pngwrite.c
|
||||
|
||||
All appear to handle dates properly in a Y2K environment. The
|
||||
|
||||
All appear to handle dates properly in a Y2K environment. The
|
||||
png_convert_from_time_t() function calls gmtime() to convert from system
|
||||
clock time, which returns (year - 1900), which we properly convert to
|
||||
the full 4-digit year. There is a possibility that applications using
|
||||
@@ -42,14 +42,14 @@
|
||||
but this is not under our control. The libpng documentation has always
|
||||
stated that it works with 4-digit years, and the APIs have been
|
||||
documented as such.
|
||||
|
||||
|
||||
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
|
||||
integer to hold the year, and can hold years as large as 65535.
|
||||
|
||||
zlib, upon which libpng depends, is also Y2K compliant. It contains
|
||||
no date-related code.
|
||||
|
||||
|
||||
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
libpng maintainer
|
||||
PNG Development Group
|
||||
|
||||
6
configure
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
echo "
|
||||
There is no \"configure\" script for Libpng-1.0.12beta1. Instead, please
|
||||
copy the appropriate makefile for your system from the \"scripts\"
|
||||
directory. Read the INSTALL file for more details.
|
||||
"
|
||||
|
||||
26
contrib/gregbook/LICENSE
Normal file
@@ -0,0 +1,26 @@
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
be held liable for any damages arising in any way from the use of
|
||||
this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute
|
||||
it freely, subject to the following restrictions:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, disclaimer, and this list of conditions.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, disclaimer, and this list of conditions in the documenta-
|
||||
tion and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this
|
||||
software must display the following acknowledgment:
|
||||
|
||||
This product includes software developed by Greg Roelofs
|
||||
and contributors for the book, "PNG: The Definitive Guide,"
|
||||
published by O'Reilly and Associates.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
102
contrib/gregbook/Makefile.sgi
Normal file
@@ -0,0 +1,102 @@
|
||||
# Sample makefile for rpng-x / rpng2-x / wpng for SGI using cc and make.
|
||||
# Greg Roelofs
|
||||
# Last modified: 16 January 1000
|
||||
#
|
||||
# The programs built by this makefile are described in the book,
|
||||
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
|
||||
# Associates, 1999). Go buy a copy, eh? Buy some for friends
|
||||
# and family, too. (Not that this is a blatant plug or anything.)
|
||||
#
|
||||
# Invoke this makefile from a shell prompt in the usual way; for example:
|
||||
#
|
||||
# make -f Makefile.sgi
|
||||
#
|
||||
# This makefile assumes libpng and zlib have already been built or downloaded
|
||||
# and are both installed in /usr/local/{include,lib} (as indicated by the
|
||||
# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of
|
||||
# the PNGINC, PNGLIB, ZINC and ZLIB lines.
|
||||
#
|
||||
# This makefile builds dynamically linked executables (against libpng and zlib,
|
||||
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
|
||||
# ZLIB lines.
|
||||
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGINC = -I/usr/local/include
|
||||
PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng
|
||||
#PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng
|
||||
# or:
|
||||
#PNGINC = -I../..
|
||||
#PNGLIB = -L../.. -lpng
|
||||
#PNGLIB = ../../libpng.a
|
||||
|
||||
ZINC = -I/usr/local/include
|
||||
ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
|
||||
#ZLIB = /usr/local/lib/libz.a # statically linked against zlib
|
||||
#ZINC = -I../zlib
|
||||
#ZLIB = -L../zlib -lz
|
||||
#ZLIB = ../../../zlib/libz.a
|
||||
|
||||
XINC = -I/usr/include/X11 # old-style, stock X distributions
|
||||
XLIB = -L/usr/lib/X11 -lX11
|
||||
#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
|
||||
#XLIB = -L/usr/openwin/lib -lX11
|
||||
#XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.)
|
||||
#XLIB = -L/usr/X11R6/lib -lX11
|
||||
|
||||
INCS = $(PNGINC) $(ZINC) $(XINC)
|
||||
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
|
||||
WLIBS = $(PNGLIB) $(ZLIB)
|
||||
|
||||
CC = cc
|
||||
LD = cc
|
||||
RM = rm -f
|
||||
CFLAGS = -O -fullwarn $(INCS)
|
||||
LDFLAGS =
|
||||
O = .o
|
||||
E =
|
||||
|
||||
RPNG = rpng-x
|
||||
RPNG2 = rpng2-x
|
||||
WPNG = wpng
|
||||
|
||||
ROBJS = $(RPNG)$(O) readpng$(O)
|
||||
ROBJS2 = $(RPNG2)$(O) readpng2$(O)
|
||||
WOBJS = $(WPNG)$(O) writepng$(O)
|
||||
|
||||
EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
||||
|
||||
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
||||
all: $(EXES)
|
||||
|
||||
$(RPNG)$(E): $(ROBJS)
|
||||
$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS)
|
||||
|
||||
$(RPNG2)$(E): $(ROBJS2)
|
||||
$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS)
|
||||
|
||||
$(WPNG)$(E): $(WOBJS)
|
||||
$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS)
|
||||
|
||||
$(RPNG)$(O): $(RPNG).c readpng.h
|
||||
$(RPNG2)$(O): $(RPNG2).c readpng2.h
|
||||
$(WPNG)$(O): $(WPNG).c writepng.h
|
||||
|
||||
readpng$(O): readpng.c readpng.h
|
||||
readpng2$(O): readpng2.c readpng2.h
|
||||
writepng$(O): writepng.c writepng.h
|
||||
|
||||
|
||||
# maintenance ---------------------------------------------------------------
|
||||
|
||||
clean:
|
||||
$(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
|
||||
# Greg Roelofs
|
||||
# Last modified: 16 February 1999
|
||||
# Last modified: 28 February 2000
|
||||
#
|
||||
# The programs built by this makefile are described in the book,
|
||||
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
|
||||
@@ -9,11 +9,12 @@
|
||||
#
|
||||
# Invoke this makefile from a shell prompt in the usual way; for example:
|
||||
#
|
||||
# make -f makefile.unx
|
||||
# make -f Makefile.unx
|
||||
#
|
||||
# This makefile assumes libpng and zlib have already been built or downloaded
|
||||
# and are both installed in /usr/local/{include,lib} (as indicated by the
|
||||
# PNGPATH and ZPATH macros below). Edit as appropriate.
|
||||
# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of
|
||||
# the PNGINC, PNGLIB, ZINC and ZLIB lines.
|
||||
#
|
||||
# This makefile builds statically linked executables (against libpng and zlib,
|
||||
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
|
||||
@@ -22,30 +23,38 @@
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGPATH = /usr/local
|
||||
PNGINC = -I$(PNGPATH)/include
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng
|
||||
PNGLIB = $(PNGPATH)/lib/libpng.a
|
||||
PNGINC = -I/usr/local/include
|
||||
#PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng
|
||||
PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng
|
||||
# or:
|
||||
#PNGINC = -I../..
|
||||
#PNGLIB = -L../.. -lpng
|
||||
#PNGLIB = ../../libpng.a
|
||||
|
||||
ZPATH = /usr/local
|
||||
ZINC = -I$(ZPATH)/include
|
||||
#ZLIB = -L$(ZPATH)/lib -lz
|
||||
ZLIB = $(ZPATH)/lib/libz.a
|
||||
ZINC = -I/usr/local/include
|
||||
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
|
||||
ZLIB = /usr/local/lib/libz.a # statically linked against zlib
|
||||
#ZINC = -I../zlib
|
||||
#ZLIB = -L../zlib -lz
|
||||
#ZLIB = ../../../zlib/libz.a
|
||||
|
||||
#XPATH = /usr/X11
|
||||
XPATH = /usr/X11R6
|
||||
XINC = -I$(XPATH)/include
|
||||
XLIB = -L$(XPATH)/lib -lX11
|
||||
#XINC = -I/usr/include/X11 # old-style, stock X distributions
|
||||
#XLIB = -L/usr/lib/X11 -lX11
|
||||
#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
|
||||
#XLIB = -L/usr/openwin/lib -lX11
|
||||
XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.)
|
||||
XLIB = -L/usr/X11R6/lib -lX11
|
||||
|
||||
INCS = $(PNGINC) $(ZINC) $(XINC)
|
||||
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
|
||||
WLIBS = $(PNGLIB) $(ZLIB) -lm
|
||||
WLIBS = $(PNGLIB) $(ZLIB)
|
||||
|
||||
CC = gcc
|
||||
LD = gcc
|
||||
RM = rm -f
|
||||
CFLAGS = -O -Wall $(INCS)
|
||||
# [note that -Wall is a gcc-specific compilation flag ("all warnings on")]
|
||||
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||
# [-ansi, -pedantic and -W can also be used]
|
||||
LDFLAGS =
|
||||
O = .o
|
||||
E =
|
||||
@@ -10,7 +10,7 @@
|
||||
# Invoke this makefile from a DOS prompt window via:
|
||||
#
|
||||
# %devstudio%\vc\bin\vcvars32.bat
|
||||
# nmake -nologo -f makefile.w32
|
||||
# nmake -nologo -f Makefile.w32
|
||||
#
|
||||
# where %devstudio% is the installation directory for MSVC / DevStudio. If
|
||||
# you get "environment out of space" errors, create a desktop shortcut with
|
||||
@@ -32,12 +32,12 @@
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGPATH = ../libpng
|
||||
PNGPATH = ../..
|
||||
PNGINC = -I$(PNGPATH)
|
||||
#PNGLIB = $(PNGPATH)/pngdll.lib
|
||||
PNGLIB = $(PNGPATH)/libpng.lib
|
||||
|
||||
ZPATH = ../zlib
|
||||
ZPATH = ../../../zlib
|
||||
ZINC = -I$(ZPATH)
|
||||
#ZLIB = $(ZPATH)/zlibdll.lib
|
||||
ZLIB = $(ZPATH)/zlibstat.lib
|
||||
@@ -1,52 +1,183 @@
|
||||
PNG: The Definitive Guide: Source Code
|
||||
===========================
|
||||
PNG: The Definitive Guide
|
||||
===========================
|
||||
|
||||
Chapters 13, 14 and 15 of PNG: The Definitive Guide discuss three
|
||||
Source Code
|
||||
|
||||
Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free,
|
||||
cross-platform demo programs that show how to use the libpng reference
|
||||
library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is a
|
||||
very simple example that that shows how a standard file-viewer might use
|
||||
libpng, while the second is designed to process streaming data and shows how
|
||||
a web browser might be written. wpng is a simple command-line program that
|
||||
reads binary PPM files (the ``raw'' RGB subset of NetPBM) and converts them
|
||||
to PNG.
|
||||
library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is
|
||||
a very simple example that that shows how a standard file-viewer might use
|
||||
libpng, while the second is designed to process streaming data and shows
|
||||
how a web browser might be written. wpng is a simple command-line program
|
||||
that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets
|
||||
of PBMPLUS/NetPBM) and converts them to PNG.
|
||||
|
||||
The source code for all three demo programs currently compiles only under
|
||||
Unix and 32-bit Windows. It has been tested with gcc 2.7.2.3 under Linux and
|
||||
Solaris and with Microsoft Visual C++ 5.0 under Windows 95. Brief
|
||||
instructions for compiling the programs are included at the top of the
|
||||
makefiles; makefile.unx is the Unix version, and makefile.w32 is (you
|
||||
guessed it!) the version for 32-bit Windows. libpng and zlib are required.
|
||||
The source code for all three demo programs currently compiles under
|
||||
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
|
||||
zinser@decus.de, for making the necessary changes for OpenVMS and for
|
||||
providing an appropriate build script.) Build instructions can be
|
||||
found below.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Files:
|
||||
|
||||
License
|
||||
README this file
|
||||
README.w32 additional Windows-specific information
|
||||
LICENSE terms of distribution and reuse (BSD-like)
|
||||
|
||||
The source code to the demo programs may be used and distributed freely
|
||||
(even if you didn't buy the book--but feel free to do so at any time),
|
||||
subject to the terms of the following BSD-like license:
|
||||
Makefile.unx Unix makefile
|
||||
Makefile.w32 Windows (MSVC) makefile
|
||||
makevms.com OpenVMS build script
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
rpng-win.c Windows front end for the basic viewer
|
||||
rpng-x.c X Window System (Unix, OpenVMS) front end
|
||||
readpng.c generic back end for the basic viewer
|
||||
readpng.h header file for the basic viewer
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
be held liable for any damages arising in any way from the use of
|
||||
this software.
|
||||
rpng2-win.c Windows front end for the progressive viewer
|
||||
rpng2-x.c X front end for the progressive viewer
|
||||
readpng2.c generic back end for the progressive viewer
|
||||
readpng2.h header file for the progressive viewer
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
wpng.c generic (text) front end for the converter
|
||||
writepng.c generic back end for the converter
|
||||
writepng.h header file for the converter
|
||||
|
||||
1. Redistributions of source code must retain the above
|
||||
copyright notice, disclaimer, and this list of conditions.
|
||||
2. Redistributions in binary form must reproduce the above
|
||||
copyright notice, disclaimer, and this list of conditions in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. All advertising materials mentioning features or use of this
|
||||
software must display the following acknowledgment:
|
||||
toucan.png transparent PNG for testing (by Stefan Schneider)
|
||||
|
||||
This product includes software developed by Greg Roelofs
|
||||
and contributors for the book, "PNG: The Definitive
|
||||
Guide," published by O'Reilly and Associates.
|
||||
Note that the programs are designed to be functional, but their primary
|
||||
purpose is to demonstrate how to use libpng to add PNG support to other
|
||||
programs. As such, their user interfaces are crude and definitely not
|
||||
intended for everyday use.
|
||||
|
||||
----------------------------------------------------------
|
||||
http://www.cdrom.com/pub/png/book/sources.html
|
||||
Please see http://www.cdrom.com/pub/png/pngbook.html for further infor-
|
||||
mation and links to the latest version of the source code, and Chapters
|
||||
13-15 of the book for detailed discussion of the three programs.
|
||||
|
||||
Greg Roelofs
|
||||
19 March 2000
|
||||
|
||||
|
||||
BUILD INSTRUCTIONS
|
||||
|
||||
- Prerequisites:
|
||||
|
||||
- zlib ftp://ftp.cdrom.com/pub/infozip/zlib/zlib.html
|
||||
- libpng http://www.cdrom.com/pub/png/pngcode.html
|
||||
- pngbook http://www.cdrom.com/pub/png/book/sources.html
|
||||
|
||||
The pngbook demo programs are explicitly designed to demonstrate proper
|
||||
coding techniques for using the libpng reference library. As a result,
|
||||
you need to download and build both zlib (on which libpng depends) and
|
||||
libpng. A common build setup is to place the zlib, libpng and pngbook
|
||||
subdirectory trees ("folders") in the same parent directory. Then the
|
||||
libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]),
|
||||
and similarly for the pngbook build.
|
||||
|
||||
Note that all three packages are designed to be built from a command
|
||||
line by default; those who wish to use a graphical or other integrated
|
||||
development environments are on their own.
|
||||
|
||||
|
||||
- Unix:
|
||||
|
||||
Unpack the latest pngbook sources (which should correspond to this
|
||||
README file) into a directory and change into that directory.
|
||||
|
||||
Copy Makefile.unx to Makefile and edit the PNG* and Z* variables
|
||||
appropriately (possibly also the X* variables if necessary).
|
||||
|
||||
make
|
||||
|
||||
There is no "install" target, so copy the three executables somewhere
|
||||
in your path or run them from the current directory. All three will
|
||||
print a basic usage screen when run without any command-line arguments;
|
||||
see the book for more details.
|
||||
|
||||
|
||||
- Windows:
|
||||
|
||||
Unpack the latest pngbook sources (which should correspond to this
|
||||
README file) into a folder, open a "DOS shell" or "command prompt"
|
||||
or equivalent command-line window, and cd into the folder where you
|
||||
unpacked the source code.
|
||||
|
||||
For MSVC, set up the necessary environment variables by invoking
|
||||
|
||||
%devstudio%\vc\bin\vcvars32.bat
|
||||
|
||||
where where %devstudio% is the installation directory for MSVC /
|
||||
DevStudio. If you get "environment out of space" errors under 95/98,
|
||||
create a desktop shortcut with "c:\windows\command.com /e:4096" as
|
||||
the program command line and set the working directory to the pngbook
|
||||
directory. Then double-click to open the new DOS-prompt window with
|
||||
a bigger environment and retry the commands above.
|
||||
|
||||
Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables
|
||||
appropriately (possibly also the "INC" and "LIB" variables if needed).
|
||||
Note that the names of the dynamic and static libpng and zlib libraries
|
||||
used in the makefile may change in later releases of the libraries.
|
||||
Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work.
|
||||
This makefile therefore builds statically linked executables, but if
|
||||
the DLL problems ever get fixed, uncommenting the appropriate PNGLIB
|
||||
and ZLIB lines will build dynamically linked executables instead.
|
||||
|
||||
Do the build by typing
|
||||
|
||||
nmake
|
||||
|
||||
The result should be three executables: rpng-win.exe, rpng2-win.exe,
|
||||
and wpng.exe. Copy them somewhere in your PATH or run them from the
|
||||
current folder. Unlike the Unix versions, the two windowed programs
|
||||
(rpng and rpng2) do not display a usage screen when invoked without
|
||||
command-line arguments; see README.w32 for brief help or the book for
|
||||
details. Note that the programs use the Unix-style "-" character to
|
||||
specify options, instead of the more common DOS/Windows "/" character.
|
||||
|
||||
|
||||
- OpenVMS:
|
||||
|
||||
Unpack the pngbook sources into a subdirectory and change into that
|
||||
subdirectory.
|
||||
|
||||
Edit makevms.com appropriately, specifically the zpath and pngpath
|
||||
variables.
|
||||
|
||||
@makevms
|
||||
|
||||
To run the programs, they probably first need to be set up as "foreign
|
||||
symbols," with "disk" and "dir" set appropriately:
|
||||
|
||||
$ rpng == "$disk:[dir]rpng-x.exe"
|
||||
$ rpng2 == "$disk:[dir]rpng2-x.exe"
|
||||
$ wpng == "$disk:[dir]wpng.exe"
|
||||
|
||||
All three will print a basic usage screen when run without any command-
|
||||
line arguments; see the book for more details. Note that the options
|
||||
style is Unix-like, i.e., preceded by "-" rather than "/".
|
||||
|
||||
|
||||
RUNNING THE PROGRAMS: (VERY) BRIEF INTRO
|
||||
|
||||
rpng is a simple PNG viewer that can display transparent PNGs with a
|
||||
specified background color; for example,
|
||||
|
||||
rpng -bgcolor #ff0000 toucan.png
|
||||
|
||||
would display the image with a red background. rpng2 is a progressive
|
||||
viewer that simulates a web browser in some respects; it can display
|
||||
images against either a background color or a dynamically generated
|
||||
background image. For example:
|
||||
|
||||
rpng2 -bgpat 16 toucan.png
|
||||
|
||||
wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
|
||||
format (.pgm or .ppm) to PNG; for example,
|
||||
|
||||
wpng -time < toucan.ppm > toucan.png
|
||||
|
||||
would convert the specified PPM file (using redirection) to PNG, auto-
|
||||
matically setting the PNG modification-time chunk.
|
||||
|
||||
All options can be abbreviated to the shortest unique value; for example,
|
||||
"-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma.
|
||||
|
||||
53
contrib/gregbook/README.w32
Normal file
@@ -0,0 +1,53 @@
|
||||
See the main README file for basic instructions on compiling and running
|
||||
the programs. See http://www.cdrom.com/pub/png/pngbook.html for further
|
||||
information and links to the source code, and Chapters 13-15 of the book
|
||||
for detailed discussion of the three programs.
|
||||
|
||||
Since the two viewers, rpng and rpng2, are both designed to write infor-
|
||||
mation to the console (i.e., a DOS-window command line) while displaying
|
||||
the image in a graphical window--and since I haven't yet figured out how
|
||||
to do that under Windows--here are the usage screens for the two programs:
|
||||
|
||||
|
||||
rpng-win 1.02 of 19 March 2000: Simple PNG Viewer for Windows
|
||||
Compiled with libpng 1.0.5; using libpng 1.0.5.
|
||||
Compiled with zlib 1.1.3; using zlib 1.1.3.
|
||||
|
||||
Usage: rpng-win [-gamma exp] [-bgcolor bg] file.png
|
||||
exp transfer-function exponent (``gamma'') of the display
|
||||
system in floating-point format (e.g., ``2.2''); equal
|
||||
to the product of the lookup-table exponent (varies)
|
||||
and the CRT exponent (usually 2.2); must be positive
|
||||
bg desired background color in 7-character hex RGB format
|
||||
(e.g., ``#ff7f00'' for orange: same as HTML colors);
|
||||
used with transparent images
|
||||
|
||||
Press Q, Esc or mouse button 1 after image is displayed to quit.
|
||||
|
||||
|
||||
rpng2-win 1.04 of 19 March 2000: Progressive PNG Viewer for Windows
|
||||
Compiled with libpng 1.0.5; using libpng 1.0.5.
|
||||
Compiled with zlib 1.1.3; using zlib 1.1.3.
|
||||
|
||||
Usage: rpng2-win [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing] file.png
|
||||
|
||||
exp transfer-function exponent (``gamma'') of the display
|
||||
system in floating-point format (e.g., ``2.2''); equal
|
||||
to the product of the lookup-table exponent (varies)
|
||||
and the CRT exponent (usually 2.2); must be positive
|
||||
bg desired background color in 7-character hex RGB format
|
||||
(e.g., ``#ff7f00'' for orange: same as HTML colors);
|
||||
used with transparent images; overrides -bgpat
|
||||
pat desired background pattern number (1-16); used with
|
||||
transparent images; overrides -bgcolor
|
||||
-timing enables delay for every block read, to simulate modem
|
||||
download of image (~36 Kbps)
|
||||
|
||||
Press Q, Esc or mouse button 1 after image is displayed to quit.
|
||||
|
||||
|
||||
The usage screen for the third (non-windowed) program, wpng, can be seen
|
||||
simply by invoking it without any parameters (``wpng'').
|
||||
|
||||
Greg Roelofs
|
||||
19 March 2000
|
||||
@@ -1,11 +1,35 @@
|
||||
$!------------------------------------------------------------------------------
|
||||
$! make Contrib programs of libpng under OpenVMS
|
||||
$! make "PNG: The Definitive Guide" demo programs (for X) under OpenVMS
|
||||
$!
|
||||
$! Script created by Martin Zinser for libpng; modified by Greg Roelofs
|
||||
$! for standalone pngbook source distribution.
|
||||
$!
|
||||
$!
|
||||
$! Look for the compiler used
|
||||
$! Set locations where zlib and libpng sources live.
|
||||
$!
|
||||
$ zlibsrc = "[---.zlib]"
|
||||
$ ccopt="/include=(''zlibsrc',[--])"
|
||||
$ zpath = ""
|
||||
$ pngpath = ""
|
||||
$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]"
|
||||
$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]"
|
||||
$!
|
||||
$ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]"
|
||||
$ if f$search("[--]png.h").nes."" then pngpath = "[--]"
|
||||
$!
|
||||
$ if zpath .eqs. ""
|
||||
$ then
|
||||
$ write sys$output "Zlib include not found. Exiting..."
|
||||
$ exit 2
|
||||
$ endif
|
||||
$!
|
||||
$ if pngpath .eqs. ""
|
||||
$ then
|
||||
$ write sys$output "Libpng include not found. Exiting..."
|
||||
$ exit 2
|
||||
$ endif
|
||||
$!
|
||||
$! Look for the compiler used.
|
||||
$!
|
||||
$ ccopt="/include=(''zpath',''pngpath')"
|
||||
$ if f$getsyi("HW_MODEL").ge.1024
|
||||
$ then
|
||||
$ ccopt = "/prefix=all"+ccopt
|
||||
@@ -29,13 +53,16 @@ $ comp = "__decc__=1"
|
||||
$ endif
|
||||
$ endif
|
||||
$ open/write lopt lib.opt
|
||||
$ write lopt "[--]libpng.olb/lib"
|
||||
$ write lopt "''zlibsrc'libz.olb/lib"
|
||||
$ write lopt "''pngpath'libpng.olb/lib"
|
||||
$ write lopt "''zpath'libz.olb/lib"
|
||||
$ close lopt
|
||||
$ open/write xopt x11.opt
|
||||
$ write xopt "sys$library:decw$xlibshr.exe/share"
|
||||
$ close xopt
|
||||
$ write sys$output "Compiling PNG contrib programs ..."
|
||||
$!
|
||||
$! Build 'em.
|
||||
$!
|
||||
$ write sys$output "Compiling PNG book programs ..."
|
||||
$ CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" -
|
||||
readpng.c readpng.h
|
||||
$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" -
|
||||
@@ -45,20 +72,20 @@ $ CALL MAKE writepng.OBJ "cc ''CCOPT' writepng" -
|
||||
$ write sys$output "Building rpng-x..."
|
||||
$ CALL MAKE rpng-x.OBJ "cc ''CCOPT' rpng-x" -
|
||||
rpng-x.c readpng.h
|
||||
$ call make rpng-x.exe -
|
||||
"LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" -
|
||||
$ call make rpng-x.exe -
|
||||
"LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" -
|
||||
rpng-x.obj readpng.obj
|
||||
$ write sys$output "Building rpng2-x..."
|
||||
$ CALL MAKE rpng2-x.OBJ "cc ''CCOPT' rpng2-x" -
|
||||
rpng2-x.c readpng2.h
|
||||
$ call make rpng2-x.exe -
|
||||
"LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" -
|
||||
$ call make rpng2-x.exe -
|
||||
"LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" -
|
||||
rpng2-x.obj readpng2.obj
|
||||
$ write sys$output "Building wpng..."
|
||||
$ CALL MAKE wpng.OBJ "cc ''CCOPT' wpng" -
|
||||
wpng.c writepng.h
|
||||
$ call make wpng.exe -
|
||||
"LINK wpng,writepng,lib.opt/opt" -
|
||||
$ call make wpng.exe -
|
||||
"LINK wpng,writepng,lib.opt/opt" -
|
||||
wpng.obj writepng.obj
|
||||
$ exit
|
||||
$!
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -32,8 +32,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "png.h" /* libpng header; includes zlib.h */
|
||||
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
||||
#include "png.h" /* libpng header; includes zlib.h */
|
||||
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
||||
|
||||
/* future versions of libpng will provide this macro: */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#endif
|
||||
|
||||
|
||||
static png_structp png_ptr = NULL;
|
||||
@@ -44,18 +49,18 @@ int bit_depth, color_type;
|
||||
uch *image_data = NULL;
|
||||
|
||||
|
||||
void readpng_version_info()
|
||||
void readpng_version_info(void)
|
||||
{
|
||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
|
||||
ZLIB_VERSION, zlib_version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */
|
||||
|
||||
int readpng_init(FILE *infile, long *pWidth, long *pHeight)
|
||||
int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
|
||||
{
|
||||
uch sig[8];
|
||||
|
||||
@@ -89,7 +94,7 @@ int readpng_init(FILE *infile, long *pWidth, long *pHeight)
|
||||
/* setjmp() must be called in every function that calls a PNG-reading
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_ptr->jmpbuf)) {
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 2;
|
||||
}
|
||||
@@ -130,7 +135,7 @@ int readpng_get_bgcolor(uch *red, uch *green, uch *blue)
|
||||
/* setjmp() must be called in every function that calls a PNG-reading
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_ptr->jmpbuf)) {
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 2;
|
||||
}
|
||||
@@ -184,7 +189,7 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
/* setjmp() must be called in every function that calls a PNG-reading
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_ptr->jmpbuf)) {
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -54,7 +54,7 @@ typedef unsigned long ulg;
|
||||
|
||||
void readpng_version_info(void);
|
||||
|
||||
int readpng_init(FILE *infile, long *pWidth, long *pHeight);
|
||||
int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight);
|
||||
|
||||
int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -30,10 +30,10 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "readpng2.h" /* typedefs, common macros, public prototypes */
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "readpng2.h" /* typedefs, common macros, public prototypes */
|
||||
|
||||
|
||||
/* local prototypes */
|
||||
@@ -47,13 +47,14 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
|
||||
|
||||
|
||||
|
||||
void readpng2_version_info()
|
||||
void readpng2_version_info(void)
|
||||
{
|
||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||
|
||||
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
|
||||
ZLIB_VERSION, zlib_version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +71,7 @@ int readpng2_check_sig(uch *sig, int num)
|
||||
|
||||
int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
{
|
||||
png_structp png_ptr; /* note: temporary variables! */
|
||||
png_structp png_ptr; /* note: temporary variables! */
|
||||
png_infop info_ptr;
|
||||
|
||||
|
||||
@@ -110,7 +111,6 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
png_set_progressive_read_fn(png_ptr, mainprog_ptr,
|
||||
readpng2_info_callback, readpng2_row_callback, readpng2_end_callback);
|
||||
|
||||
|
||||
/* make sure we save our pointers for use in readpng2_decode_data() */
|
||||
|
||||
mainprog_ptr->png_ptr = png_ptr;
|
||||
@@ -176,7 +176,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
mainprog_ptr = png_get_progressive_ptr(png_ptr);
|
||||
|
||||
if (mainprog_ptr == NULL) { /* we be hosed */
|
||||
if (mainprog_ptr == NULL) { /* we be hosed */
|
||||
fprintf(stderr,
|
||||
"readpng2 error: main struct not recoverable in info_callback.\n");
|
||||
fflush(stderr);
|
||||
@@ -283,7 +283,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
mainprog_ptr->rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
mainprog_ptr->rowbytes = (int)png_get_rowbytes(png_ptr, info_ptr);
|
||||
mainprog_ptr->channels = png_get_channels(png_ptr, info_ptr);
|
||||
|
||||
|
||||
@@ -323,6 +323,11 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
mainprog_ptr = png_get_progressive_ptr(png_ptr);
|
||||
|
||||
|
||||
/* save the pass number for optional use by the front end */
|
||||
|
||||
mainprog_ptr->pass = pass;
|
||||
|
||||
|
||||
/* have libpng either combine the new row data with the existing row data
|
||||
* from previous passes (if interlaced) or else just copy the new row
|
||||
* into the main program's image buffer */
|
||||
@@ -408,7 +413,7 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
|
||||
fflush(stderr);
|
||||
|
||||
mainprog_ptr = png_get_error_ptr(png_ptr);
|
||||
if (mainprog_ptr == NULL) { /* we are completely hosed now */
|
||||
if (mainprog_ptr == NULL) { /* we are completely hosed now */
|
||||
fprintf(stderr,
|
||||
"readpng2 severe error: jmpbuf not recoverable; terminating.\n");
|
||||
fflush(stderr);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -61,10 +61,16 @@ typedef struct _mainprog_info {
|
||||
uch *image_data;
|
||||
uch **row_pointers;
|
||||
jmp_buf jmpbuf;
|
||||
int passes; /* not used */
|
||||
int passes; /* not used */
|
||||
int pass;
|
||||
int rowbytes;
|
||||
int channels;
|
||||
int need_bgcolor;
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
int nommxfilters;
|
||||
int nommxcombine;
|
||||
int nommxinterlace;
|
||||
#endif
|
||||
int done;
|
||||
uch bg_red;
|
||||
uch bg_green;
|
||||
|
||||
@@ -16,7 +16,16 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Changelog:
|
||||
- 1.00: initial public release
|
||||
- 1.01: modified to allow abbreviated options; fixed long/ulong mis-
|
||||
match; switched to png_jmpbuf() macro
|
||||
- 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed
|
||||
command-line parsing bug
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -43,7 +52,7 @@
|
||||
|
||||
#define PROGNAME "rpng-win"
|
||||
#define LONGNAME "Simple PNG Viewer for Windows"
|
||||
#define VERSION "1.0 of 20 February 1999"
|
||||
#define VERSION "1.02 of 19 March 2000"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -53,7 +62,7 @@
|
||||
|
||||
/* #define DEBUG : this enables the Trace() macros */
|
||||
|
||||
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
|
||||
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
|
||||
|
||||
|
||||
/* could just include png.h, but this macro is the only thing we need
|
||||
@@ -61,10 +70,10 @@
|
||||
* only happen with alpha (which could easily be avoided with
|
||||
* "ush acopy = (alpha);") */
|
||||
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +87,7 @@ LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM);
|
||||
static char titlebar[1024], *window_name = titlebar;
|
||||
static char *progname = PROGNAME;
|
||||
static char *appname = LONGNAME;
|
||||
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
|
||||
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
|
||||
static char *filename;
|
||||
static FILE *infile;
|
||||
|
||||
@@ -104,15 +113,15 @@ static HWND global_hwnd;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
{
|
||||
char *args[1024]; /* arbitrary limit, but should suffice */
|
||||
char *args[1024]; /* arbitrary limit, but should suffice */
|
||||
char *p, *q, **argv = args;
|
||||
int argc = 0;
|
||||
int rc, alen, flen;
|
||||
int error = 0;
|
||||
int have_bg = FALSE;
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
MSG msg;
|
||||
|
||||
|
||||
@@ -150,7 +159,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
LUT_exponent = 1.8 / 2.61;
|
||||
/*
|
||||
if (some_mac_function_that_returns_gamma(&mac_gamma))
|
||||
LUT_exponent = mac_gamma / 2.61;
|
||||
LUT_exponent = mac_gamma / 2.61;
|
||||
*/
|
||||
#else
|
||||
LUT_exponent = 1.0; /* assume no LUT: most PCs */
|
||||
@@ -199,20 +208,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
/* Now parse the command line for options and the PNG filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-gamma")) {
|
||||
if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
display_exponent = atof(*argv);
|
||||
if (display_exponent <= 0.0)
|
||||
++error;
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
else {
|
||||
display_exponent = atof(*argv);
|
||||
if (display_exponent <= 0.0)
|
||||
++error;
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgcolor", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else
|
||||
have_bg = TRUE;
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else
|
||||
have_bg = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
filename = *argv;
|
||||
@@ -255,6 +268,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
fclose(infile);
|
||||
}
|
||||
|
||||
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
readpng_version_info();
|
||||
@@ -265,7 +281,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7f00'' for orange: same as HTML colors);\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images\n"
|
||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||
"\n", PROGNAME, default_display_exponent);
|
||||
@@ -336,6 +352,10 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
|
||||
/* wait for the user to tell us when to quit */
|
||||
|
||||
printf(
|
||||
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
||||
fflush(stdout);
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
@@ -371,7 +391,7 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode)
|
||||
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
|
||||
wimage_rowbytes*image_height)))
|
||||
{
|
||||
return 4; /* fail */
|
||||
return 4; /* fail */
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -477,7 +497,7 @@ static int rpng_win_display_image()
|
||||
g = *src++;
|
||||
b = *src++;
|
||||
*dest++ = b;
|
||||
*dest++ = g; /* note reverse order */
|
||||
*dest++ = g; /* note reverse order */
|
||||
*dest++ = r;
|
||||
}
|
||||
} else /* if (image_channels == 4) */ {
|
||||
@@ -582,15 +602,15 @@ LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
|
||||
|
||||
/* wait for the user to tell us when to quit */
|
||||
case WM_CHAR:
|
||||
switch (wP) { /* only need one, so ignore repeat count */
|
||||
switch (wP) { /* only need one, so ignore repeat count */
|
||||
case 'q':
|
||||
case 'Q':
|
||||
case 0x1B: /* Esc key */
|
||||
case 0x1B: /* Esc key */
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_LBUTTONDOWN: /* another way of quitting */
|
||||
case WM_LBUTTONDOWN: /* another way of quitting */
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
This program decodes and displays PNG images, with gamma correction and
|
||||
optionally with a user-specified background color (in case the image has
|
||||
transparency). It is very nearly the most basic PNG viewer possible.
|
||||
This version is for the X Window System (tested under Unix, but may work
|
||||
under VMS or OS/2 with a little tweaking).
|
||||
This version is for the X Window System (tested by author under Unix and
|
||||
by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking).
|
||||
|
||||
to do:
|
||||
- 8-bit support
|
||||
@@ -14,7 +14,17 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Changelog:
|
||||
- 1.01: initial public release
|
||||
- 1.02: modified to allow abbreviated options; fixed long/ulong mis-
|
||||
match; switched to png_jmpbuf() macro
|
||||
- 1.10: added support for non-default visuals; fixed X pixel-conversion
|
||||
- 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed
|
||||
command-line parsing bug
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -41,7 +51,7 @@
|
||||
|
||||
#define PROGNAME "rpng-x"
|
||||
#define LONGNAME "Simple PNG Viewer for X"
|
||||
#define VERSION "1.01 of 31 March 1999"
|
||||
#define VERSION "1.11 of 19 March 2000"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -54,18 +64,18 @@
|
||||
|
||||
/* #define DEBUG : this enables the Trace() macros */
|
||||
|
||||
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
|
||||
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
|
||||
|
||||
|
||||
/* could just include png.h, but this macro is the only thing we need
|
||||
* (name and typedefs changed to local versions); note that side effects
|
||||
* only happen with alpha (which could easily be avoided with
|
||||
* (name and typedefs changed to local versions); note that side effects
|
||||
* only happen with alpha (which could easily be avoided with
|
||||
* "ush acopy = (alpha);") */
|
||||
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
}
|
||||
|
||||
|
||||
@@ -95,15 +105,16 @@ static uch *image_data;
|
||||
static char *displayname;
|
||||
static XImage *ximage;
|
||||
static Display *display;
|
||||
static int bitmap_order;
|
||||
static int depth;
|
||||
static Visual *visual;
|
||||
static int RPixelShift, GPixelShift, BPixelShift;
|
||||
static ulg RedMask, GreenMask, BlueMask;
|
||||
static XVisualInfo *visual_list;
|
||||
static int RShift, GShift, BShift;
|
||||
static ulg RMask, GMask, BMask;
|
||||
static Window window;
|
||||
static GC gc;
|
||||
static Colormap colormap;
|
||||
|
||||
static int have_nondefault_visual = FALSE;
|
||||
static int have_colormap = FALSE;
|
||||
static int have_window = FALSE;
|
||||
/*
|
||||
@@ -123,9 +134,9 @@ int main(int argc, char **argv)
|
||||
int rc, alen, flen;
|
||||
int error = 0;
|
||||
int have_bg = FALSE;
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
XEvent e;
|
||||
KeySym k;
|
||||
|
||||
@@ -188,24 +199,29 @@ int main(int argc, char **argv)
|
||||
/* Now parse the command line for options and the PNG filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-display")) {
|
||||
if (!strncmp(*argv, "-display", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
displayname = *argv;
|
||||
} else if (!strcmp(*argv, "-gamma")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
display_exponent = atof(*argv);
|
||||
if (display_exponent <= 0.0)
|
||||
++error;
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else
|
||||
have_bg = TRUE;
|
||||
displayname = *argv;
|
||||
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
display_exponent = atof(*argv);
|
||||
if (display_exponent <= 0.0)
|
||||
++error;
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgcolor", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else
|
||||
have_bg = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
filename = *argv;
|
||||
@@ -222,8 +238,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
||||
++error;
|
||||
} else {
|
||||
if ((rc = readpng_init(infile, (long *)(&image_width),
|
||||
(long *)(&image_height))) != 0) {
|
||||
if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) {
|
||||
switch (rc) {
|
||||
case 1:
|
||||
fprintf(stderr, PROGNAME
|
||||
@@ -257,21 +272,25 @@ int main(int argc, char **argv)
|
||||
fclose(infile);
|
||||
}
|
||||
|
||||
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
readpng_version_info();
|
||||
fprintf(stderr, "\n"
|
||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
|
||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7f00'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images\n"
|
||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||
"\n", PROGNAME, default_display_exponent);
|
||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
|
||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images\n"
|
||||
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
||||
"is displayed) to quit.\n"
|
||||
"\n", PROGNAME, default_display_exponent);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -344,6 +363,10 @@ int main(int argc, char **argv)
|
||||
|
||||
/* wait for the user to tell us when to quit */
|
||||
|
||||
printf(
|
||||
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
||||
fflush(stdout);
|
||||
|
||||
do
|
||||
XNextEvent(display, &e);
|
||||
while (!(e.type == ButtonPress && e.xbutton.button == Button1) &&
|
||||
@@ -362,11 +385,13 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
|
||||
static int rpng_x_create_window()
|
||||
static int rpng_x_create_window(void)
|
||||
{
|
||||
uch *xdata;
|
||||
int need_colormap = FALSE;
|
||||
int screen, pad;
|
||||
ulg bg_pixel = 0L;
|
||||
ulg attrmask;
|
||||
Window root;
|
||||
XEvent e;
|
||||
XGCValues gcvalues;
|
||||
@@ -378,11 +403,15 @@ static int rpng_x_create_window()
|
||||
XWMHints *wm_hints;
|
||||
|
||||
|
||||
bitmap_order = BitmapBitOrder(display);
|
||||
screen = DefaultScreen(display);
|
||||
depth = DisplayPlanes(display, screen);
|
||||
root = RootWindow(display, screen);
|
||||
|
||||
#ifdef DEBUG
|
||||
XSynchronize(display, True);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* GRR: add 8-bit support */
|
||||
if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) {
|
||||
fprintf(stderr,
|
||||
@@ -394,27 +423,73 @@ static int rpng_x_create_window()
|
||||
XMatchVisualInfo(display, screen, depth,
|
||||
(depth == 8)? PseudoColor : TrueColor, &visual_info);
|
||||
visual = visual_info.visual;
|
||||
#else
|
||||
if (depth != 16 && depth != 24 && depth != 32) {
|
||||
int visuals_matched = 0;
|
||||
|
||||
RedMask = visual->red_mask;
|
||||
GreenMask = visual->green_mask;
|
||||
BlueMask = visual->blue_mask;
|
||||
Trace((stderr, "default depth is %d: checking other visuals\n",
|
||||
depth))
|
||||
|
||||
/* 24-bit first */
|
||||
visual_info.screen = screen;
|
||||
visual_info.depth = 24;
|
||||
visual_list = XGetVisualInfo(display,
|
||||
VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched);
|
||||
if (visuals_matched == 0) {
|
||||
/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */
|
||||
fprintf(stderr, "default screen depth %d not supported, and no"
|
||||
" 24-bit visuals found\n", depth);
|
||||
return 2;
|
||||
}
|
||||
Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n",
|
||||
visuals_matched))
|
||||
visual = visual_list[0].visual;
|
||||
depth = visual_list[0].depth;
|
||||
/*
|
||||
colormap_size = visual_list[0].colormap_size;
|
||||
visual_class = visual->class;
|
||||
visualID = XVisualIDFromVisual(visual);
|
||||
*/
|
||||
have_nondefault_visual = TRUE;
|
||||
need_colormap = TRUE;
|
||||
} else {
|
||||
XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info);
|
||||
visual = visual_info.visual;
|
||||
}
|
||||
#endif
|
||||
|
||||
RMask = visual->red_mask;
|
||||
GMask = visual->green_mask;
|
||||
BMask = visual->blue_mask;
|
||||
|
||||
/* GRR: add/check 8-bit support */
|
||||
if (depth == 8) {
|
||||
if (depth == 8 || need_colormap) {
|
||||
colormap = XCreateColormap(display, root, visual, AllocNone);
|
||||
if (!colormap) {
|
||||
fprintf(stderr, "XCreateColormap() failed\n");
|
||||
return 2;
|
||||
}
|
||||
have_colormap = TRUE;
|
||||
} else if (depth == 16) {
|
||||
RPixelShift = 15 - rpng_x_msb(RedMask); /* these are right-shifts */
|
||||
GPixelShift = 15 - rpng_x_msb(GreenMask);
|
||||
BPixelShift = 15 - rpng_x_msb(BlueMask);
|
||||
} else /* if (depth > 16) */ {
|
||||
RPixelShift = rpng_x_msb(RedMask) - 7; /* these are left-shifts */
|
||||
GPixelShift = rpng_x_msb(GreenMask) - 7;
|
||||
BPixelShift = rpng_x_msb(BlueMask) - 7;
|
||||
}
|
||||
if (depth == 15 || depth == 16) {
|
||||
RShift = 15 - rpng_x_msb(RMask); /* these are right-shifts */
|
||||
GShift = 15 - rpng_x_msb(GMask);
|
||||
BShift = 15 - rpng_x_msb(BMask);
|
||||
} else if (depth > 16) {
|
||||
#define NO_24BIT_MASKS
|
||||
#ifdef NO_24BIT_MASKS
|
||||
RShift = rpng_x_msb(RMask) - 7; /* these are left-shifts */
|
||||
GShift = rpng_x_msb(GMask) - 7;
|
||||
BShift = rpng_x_msb(BMask) - 7;
|
||||
#else
|
||||
RShift = 7 - rpng_x_msb(RMask); /* these are right-shifts, too */
|
||||
GShift = 7 - rpng_x_msb(GMask);
|
||||
BShift = 7 - rpng_x_msb(BMask);
|
||||
#endif
|
||||
}
|
||||
if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) {
|
||||
fprintf(stderr, "rpng internal logic error: negative X shift(s)!\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -423,9 +498,16 @@ static int rpng_x_create_window()
|
||||
|
||||
attr.backing_store = Always;
|
||||
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask;
|
||||
attrmask = CWBackingStore | CWEventMask;
|
||||
if (have_nondefault_visual) {
|
||||
attr.colormap = colormap;
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 1;
|
||||
attrmask |= CWColormap | CWBackPixel | CWBorderPixel;
|
||||
}
|
||||
|
||||
window = XCreateWindow(display, root, 0, 0, image_width, image_height,
|
||||
0, depth, InputOutput, visual, CWBackingStore | CWEventMask, &attr);
|
||||
window = XCreateWindow(display, root, 0, 0, image_width, image_height, 0,
|
||||
depth, InputOutput, visual, attrmask, &attr);
|
||||
|
||||
if (window == None) {
|
||||
fprintf(stderr, "XCreateWindow() failed\n");
|
||||
@@ -446,8 +528,8 @@ static int rpng_x_create_window()
|
||||
if ((size_hints = XAllocSizeHints()) != NULL) {
|
||||
/* window will not be resizable */
|
||||
size_hints->flags = PMinSize | PMaxSize;
|
||||
size_hints->min_width = size_hints->max_width = image_width;
|
||||
size_hints->min_height = size_hints->max_height = image_height;
|
||||
size_hints->min_width = size_hints->max_width = (int)image_width;
|
||||
size_hints->min_height = size_hints->max_height = (int)image_height;
|
||||
}
|
||||
|
||||
if ((wm_hints = XAllocWMHints()) != NULL) {
|
||||
@@ -469,13 +551,13 @@ static int rpng_x_create_window()
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
if (depth == 24 || depth == 32) {
|
||||
bg_pixel = ((ulg)bg_red << RPixelShift) |
|
||||
((ulg)bg_green << GPixelShift) |
|
||||
((ulg)bg_blue << BPixelShift);
|
||||
bg_pixel = ((ulg)bg_red << RShift) |
|
||||
((ulg)bg_green << GShift) |
|
||||
((ulg)bg_blue << BShift);
|
||||
} else if (depth == 16) {
|
||||
bg_pixel = ((((ulg)bg_red << 8) >> RPixelShift) & RedMask) |
|
||||
((((ulg)bg_green << 8) >> GPixelShift) & GreenMask) |
|
||||
((((ulg)bg_blue << 8) >> BPixelShift) & BlueMask);
|
||||
bg_pixel = ((((ulg)bg_red << 8) >> RShift) & RMask) |
|
||||
((((ulg)bg_green << 8) >> GShift) & GMask) |
|
||||
((((ulg)bg_blue << 8) >> BShift) & BMask);
|
||||
} else /* depth == 8 */ {
|
||||
|
||||
/* GRR: add 8-bit support */
|
||||
@@ -524,7 +606,7 @@ static int rpng_x_create_window()
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* to avoid testing the bitmap_order every pixel (or doubling the size of
|
||||
/* to avoid testing the byte order every pixel (or doubling the size of
|
||||
* the drawing routine with a giant if-test), we arbitrarily set the byte
|
||||
* order to MSBFirst and let Xlib worry about inverting things on little-
|
||||
* endian machines (like Linux/x86, old VAXen, etc.)--this is not the most
|
||||
@@ -541,20 +623,24 @@ static int rpng_x_create_window()
|
||||
|
||||
|
||||
|
||||
static int rpng_x_display_image()
|
||||
static int rpng_x_display_image(void)
|
||||
{
|
||||
uch *src;
|
||||
char *dest;
|
||||
uch r, g, b, a;
|
||||
int ximage_rowbytes = ximage->bytes_per_line;
|
||||
ulg i, row, lastrow = 0;
|
||||
ulg pixel;
|
||||
int ximage_rowbytes = ximage->bytes_per_line;
|
||||
/* int bpp = ximage->bits_per_pixel; */
|
||||
|
||||
|
||||
Trace((stderr, "beginning display loop (image_channels == %d)\n",
|
||||
image_channels))
|
||||
Trace((stderr, "(width = %ld, rowbytes = %ld, ximage_rowbytes = %d)\n",
|
||||
Trace((stderr, " (width = %ld, rowbytes = %ld, ximage_rowbytes = %d)\n",
|
||||
image_width, image_rowbytes, ximage_rowbytes))
|
||||
Trace((stderr, " (bpp = %d)\n", ximage->bits_per_pixel))
|
||||
Trace((stderr, " (byte_order = %s)\n", ximage->byte_order == MSBFirst?
|
||||
"MSBFirst" : (ximage->byte_order == LSBFirst? "LSBFirst" : "unknown")))
|
||||
|
||||
if (depth == 24 || depth == 32) {
|
||||
ulg red, green, blue;
|
||||
@@ -567,14 +653,27 @@ static int rpng_x_display_image()
|
||||
red = *src++;
|
||||
green = *src++;
|
||||
blue = *src++;
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
#ifdef NO_24BIT_MASKS
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
#else
|
||||
red = (RShift < 0)? red << (-RShift) : red >> RShift;
|
||||
green = (GShift < 0)? green << (-GShift) : green >> GShift;
|
||||
blue = (BShift < 0)? blue << (-BShift) : blue >> BShift;
|
||||
pixel = (red & RMask) | (green & GMask) | (blue & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
#endif
|
||||
}
|
||||
} else /* if (image_channels == 4) */ {
|
||||
for (i = image_width; i > 0; --i) {
|
||||
@@ -598,20 +697,20 @@ static int rpng_x_display_image()
|
||||
alpha_composite(green, g, a, bg_green);
|
||||
alpha_composite(blue, b, a, bg_blue);
|
||||
}
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
/* display after every 16 lines */
|
||||
if (((row+1) & 0xf) == 0) {
|
||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
||||
image_width, 16);
|
||||
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||
(int)lastrow, image_width, 16);
|
||||
XFlush(display);
|
||||
lastrow = row + 1;
|
||||
}
|
||||
@@ -631,12 +730,12 @@ static int rpng_x_display_image()
|
||||
++src;
|
||||
blue = ((ush)(*src) << 8);
|
||||
++src;
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
} else /* if (image_channels == 4) */ {
|
||||
for (i = image_width; i > 0; --i) {
|
||||
@@ -663,18 +762,18 @@ static int rpng_x_display_image()
|
||||
green = ((ush)g << 8);
|
||||
blue = ((ush)b << 8);
|
||||
}
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
/* display after every 16 lines */
|
||||
if (((row+1) & 0xf) == 0) {
|
||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
||||
image_width, 16);
|
||||
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||
(int)lastrow, image_width, 16);
|
||||
XFlush(display);
|
||||
lastrow = row + 1;
|
||||
}
|
||||
@@ -688,8 +787,8 @@ static int rpng_x_display_image()
|
||||
|
||||
Trace((stderr, "calling final XPutImage()\n"))
|
||||
if (lastrow < image_height) {
|
||||
XPutImage(display, window, gc, ximage, 0, lastrow, 0, lastrow,
|
||||
image_width, image_height-lastrow);
|
||||
XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0,
|
||||
(int)lastrow, image_width, image_height-lastrow);
|
||||
XFlush(display);
|
||||
}
|
||||
|
||||
@@ -699,7 +798,7 @@ static int rpng_x_display_image()
|
||||
|
||||
|
||||
|
||||
static void rpng_x_cleanup()
|
||||
static void rpng_x_cleanup(void)
|
||||
{
|
||||
if (image_data) {
|
||||
free(image_data);
|
||||
@@ -722,6 +821,9 @@ static void rpng_x_cleanup()
|
||||
|
||||
if (have_colormap)
|
||||
XFreeColormap(display, colormap);
|
||||
|
||||
if (have_nondefault_visual)
|
||||
XFree(visual_list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
rpng2 - progressive-model PNG display program rpng2-win.c
|
||||
rpng2 - progressive-model PNG display program rpng2-win.c
|
||||
|
||||
This program decodes and displays PNG files progressively, as if it were
|
||||
a web browser (though the front end is only set up to read from files).
|
||||
@@ -11,7 +11,6 @@
|
||||
Meulen for the "diamond" and "radial waves" patterns, respectively.
|
||||
|
||||
to do:
|
||||
- stdout/stderr don't work! need message window (maybe scrollable?)
|
||||
- handle quoted command-line args (especially filenames with spaces)
|
||||
- finish resizable checkerboard-gradient (sizes 4-128?)
|
||||
- use %.1023s to simplify truncation of title-bar string?
|
||||
@@ -22,10 +21,15 @@
|
||||
Changelog:
|
||||
- 1.01: initial public release
|
||||
- 1.02: fixed cut-and-paste error in usage screen (oops...)
|
||||
- 1.03: modified to allow abbreviated options
|
||||
- 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?];
|
||||
fixed command-line parsing bug
|
||||
- 1.10: enabled "message window" (console), thanks to David Geldreich
|
||||
- 1.20: added runtime MMX-enabling/disabling and new -mmx* options
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -52,15 +56,16 @@
|
||||
|
||||
#define PROGNAME "rpng2-win"
|
||||
#define LONGNAME "Progressive PNG Viewer for Windows"
|
||||
#define VERSION "1.02 of 22 September 1999"
|
||||
#define VERSION "1.20 of 29 January 2001"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
|
||||
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
|
||||
#include <time.h>
|
||||
#include <math.h> /* only for PvdM background code */
|
||||
#include <math.h> /* only for PvdM background code */
|
||||
#include <windows.h>
|
||||
#include <conio.h> /* only for _getch() */
|
||||
|
||||
/* all for PvdM background code: */
|
||||
#ifndef PI
|
||||
@@ -80,9 +85,9 @@
|
||||
#define rgb2_max bg_bsat
|
||||
#define rgb2_min bg_brot
|
||||
|
||||
/* #define DEBUG */ /* this enables the Trace() macros */
|
||||
/* #define DEBUG */ /* this enables the Trace() macros */
|
||||
|
||||
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
|
||||
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
|
||||
|
||||
|
||||
/* could just include png.h, but this macro is the only thing we need
|
||||
@@ -90,18 +95,18 @@
|
||||
* only happen with alpha (which could easily be avoided with
|
||||
* "ush acopy = (alpha);") */
|
||||
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
}
|
||||
|
||||
|
||||
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
|
||||
* block size corresponds roughly to a download
|
||||
* speed 10% faster than theoretical 33.6K maximum
|
||||
* (assuming 8 data bits, 1 stop bit and no other
|
||||
* overhead) */
|
||||
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
|
||||
* block size corresponds roughly to a download
|
||||
* speed 10% faster than theoretical 33.6K maximum
|
||||
* (assuming 8 data bits, 1 stop bit and no other
|
||||
* overhead) */
|
||||
|
||||
/* local prototypes */
|
||||
static void rpng2_win_init(void);
|
||||
@@ -116,7 +121,7 @@ LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM);
|
||||
static char titlebar[1024], *window_name = titlebar;
|
||||
static char *progname = PROGNAME;
|
||||
static char *appname = LONGNAME;
|
||||
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
|
||||
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
|
||||
static char *filename;
|
||||
static FILE *infile;
|
||||
|
||||
@@ -125,7 +130,7 @@ static mainprog_info rpng2_info;
|
||||
static uch inbuf[INBUFSIZE];
|
||||
static int incount;
|
||||
|
||||
static int pat = 6; /* must be less than num_bgpat */
|
||||
static int pat = 6; /* must be less than num_bgpat */
|
||||
static int bg_image = 0;
|
||||
static int bgscale = 16;
|
||||
static ulg bg_rowbytes;
|
||||
@@ -134,22 +139,22 @@ static uch *bg_data;
|
||||
static struct rgb_color {
|
||||
uch r, g, b;
|
||||
} rgb[] = {
|
||||
{ 0, 0, 0}, /* 0: black */
|
||||
{255, 255, 255}, /* 1: white */
|
||||
{173, 132, 57}, /* 2: tan */
|
||||
{ 64, 132, 0}, /* 3: medium green */
|
||||
{189, 117, 1}, /* 4: gold */
|
||||
{253, 249, 1}, /* 5: yellow */
|
||||
{ 0, 0, 255}, /* 6: blue */
|
||||
{ 0, 0, 120}, /* 7: medium blue */
|
||||
{255, 0, 255}, /* 8: magenta */
|
||||
{ 64, 0, 64}, /* 9: dark magenta */
|
||||
{255, 0, 0}, /* 10: red */
|
||||
{ 64, 0, 0}, /* 11: dark red */
|
||||
{255, 127, 0}, /* 12: orange */
|
||||
{192, 96, 0}, /* 13: darker orange */
|
||||
{ 24, 60, 0}, /* 14: dark green-yellow */
|
||||
{ 85, 125, 200} /* 15: ice blue */
|
||||
{ 0, 0, 0}, /* 0: black */
|
||||
{255, 255, 255}, /* 1: white */
|
||||
{173, 132, 57}, /* 2: tan */
|
||||
{ 64, 132, 0}, /* 3: medium green */
|
||||
{189, 117, 1}, /* 4: gold */
|
||||
{253, 249, 1}, /* 5: yellow */
|
||||
{ 0, 0, 255}, /* 6: blue */
|
||||
{ 0, 0, 120}, /* 7: medium blue */
|
||||
{255, 0, 255}, /* 8: magenta */
|
||||
{ 64, 0, 64}, /* 9: dark magenta */
|
||||
{255, 0, 0}, /* 10: red */
|
||||
{ 64, 0, 0}, /* 11: dark red */
|
||||
{255, 127, 0}, /* 12: orange */
|
||||
{192, 96, 0}, /* 13: darker orange */
|
||||
{ 24, 60, 0}, /* 14: dark green-yellow */
|
||||
{ 85, 125, 200} /* 15: ice blue */
|
||||
};
|
||||
/* not used for now, but should be for error-checking:
|
||||
static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
|
||||
@@ -174,21 +179,21 @@ static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
|
||||
*/
|
||||
static struct background_pattern {
|
||||
ush type;
|
||||
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
|
||||
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
|
||||
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
|
||||
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
|
||||
} bg[] = {
|
||||
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
|
||||
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
|
||||
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
|
||||
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
|
||||
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
|
||||
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
|
||||
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
|
||||
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
|
||||
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
|
||||
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
|
||||
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
|
||||
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
|
||||
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
|
||||
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
|
||||
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
|
||||
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
|
||||
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
|
||||
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
|
||||
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
|
||||
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
|
||||
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
|
||||
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
|
||||
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
|
||||
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
|
||||
{2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
|
||||
{2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
|
||||
{2, 16, 256, 100, 250}, /* radial: very tight spiral */
|
||||
@@ -212,16 +217,17 @@ static int global_showmode;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
{
|
||||
char *args[1024]; /* arbitrary limit, but should suffice */
|
||||
char *p, *q, *bgstr = NULL, **argv = args;
|
||||
char *args[1024]; /* arbitrary limit, but should suffice */
|
||||
char **argv = args;
|
||||
char *p, *q, *bgstr = NULL;
|
||||
int argc = 0;
|
||||
int rc, alen, flen;
|
||||
int error = 0;
|
||||
int timing = FALSE;
|
||||
int have_bg = FALSE;
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
double LUT_exponent; /* just the lookup table */
|
||||
double CRT_exponent = 2.2; /* just the monitor */
|
||||
double default_display_exponent; /* whole display system */
|
||||
MSG msg;
|
||||
|
||||
|
||||
@@ -235,6 +241,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
memset(&rpng2_info, 0, sizeof(mainprog_info));
|
||||
|
||||
|
||||
/* Next reenable console output, which normally goes to the bit bucket
|
||||
* for windowed apps. Closing the console window will terminate the
|
||||
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
|
||||
* incantation. */
|
||||
|
||||
AllocConsole();
|
||||
freopen("CONOUT$", "a", stderr);
|
||||
freopen("CONOUT$", "a", stdout);
|
||||
|
||||
|
||||
/* Set the default value for our display-system exponent, i.e., the
|
||||
* product of the CRT exponent and the exponent corresponding to
|
||||
* the frame-buffer's lookup table (LUT), if any. This is not an
|
||||
@@ -267,7 +283,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
LUT_exponent = 1.8 / 2.61;
|
||||
/*
|
||||
if (some_mac_function_that_returns_gamma(&mac_gamma))
|
||||
LUT_exponent = mac_gamma / 2.61;
|
||||
LUT_exponent = mac_gamma / 2.61;
|
||||
*/
|
||||
#else
|
||||
LUT_exponent = 1.0; /* assume no LUT: most PCs */
|
||||
@@ -316,34 +332,52 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
/* Now parse the command line for options and the PNG filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-gamma")) {
|
||||
if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
rpng2_info.display_exponent = atof(*argv);
|
||||
if (rpng2_info.display_exponent <= 0.0)
|
||||
++error;
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
have_bg = TRUE;
|
||||
bg_image = FALSE;
|
||||
rpng2_info.display_exponent = atof(*argv);
|
||||
if (rpng2_info.display_exponent <= 0.0)
|
||||
++error;
|
||||
}
|
||||
} else if (!strcmp(*argv, "-bgpat")) {
|
||||
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
pat = atoi(*argv) - 1;
|
||||
if (pat < 0 || pat >= num_bgpat)
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
have_bg = TRUE;
|
||||
bg_image = FALSE;
|
||||
}
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgpat", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
bg_image = TRUE;
|
||||
have_bg = FALSE;
|
||||
pat = atoi(*argv) - 1;
|
||||
if (pat < 0 || pat >= num_bgpat)
|
||||
++error;
|
||||
else {
|
||||
bg_image = TRUE;
|
||||
have_bg = FALSE;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(*argv, "-timing")) {
|
||||
} else if (!strncmp(*argv, "-timing", 2)) {
|
||||
timing = TRUE;
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
} else if (!strncmp(*argv, "-nommxfilters", 7)) {
|
||||
rpng2_info.nommxfilters = TRUE;
|
||||
} else if (!strncmp(*argv, "-nommxcombine", 7)) {
|
||||
rpng2_info.nommxcombine = TRUE;
|
||||
} else if (!strncmp(*argv, "-nommxinterlace", 7)) {
|
||||
rpng2_info.nommxinterlace = TRUE;
|
||||
} else if (!strcmp(*argv, "-nommx")) {
|
||||
rpng2_info.nommxfilters = TRUE;
|
||||
rpng2_info.nommxcombine = TRUE;
|
||||
rpng2_info.nommxinterlace = TRUE;
|
||||
#endif
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
filename = *argv;
|
||||
@@ -387,26 +421,51 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
fclose(infile);
|
||||
}
|
||||
|
||||
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
int ch;
|
||||
|
||||
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
||||
readpng2_version_info();
|
||||
fprintf(stderr, "\n"
|
||||
"Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]"
|
||||
" file.png\n\n"
|
||||
"Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n"
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
" %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n"
|
||||
#endif
|
||||
" %*s file.png\n\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7f00'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images; overrides -bgpat\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images; overrides -bgpat option\n"
|
||||
" pat \tdesired background pattern number (1-%d); used with\n"
|
||||
"\t\t transparent images; overrides -bgcolor\n"
|
||||
"\t\t transparent images; overrides -bgcolor option\n"
|
||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||
"\t\t download of image (~36 Kbps)\n"
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
" -nommx*\tdisable optimized MMX routines for decoding row filters,\n"
|
||||
"\t\t combining rows, and expanding interlacing, respectively\n"
|
||||
#endif
|
||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||
"\n", PROGNAME, " ", default_display_exponent, num_bgpat);
|
||||
"Press Q or Esc to quit this usage screen.\n"
|
||||
"\n", PROGNAME,
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
strlen(PROGNAME), " ",
|
||||
#endif
|
||||
strlen(PROGNAME), " ", default_display_exponent, num_bgpat);
|
||||
do
|
||||
ch = _getch();
|
||||
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
||||
exit(1);
|
||||
} else {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
fprintf(stderr,
|
||||
"\n [console window: closing this window will terminate %s]\n\n",
|
||||
PROGNAME);
|
||||
}
|
||||
|
||||
|
||||
@@ -560,7 +619,7 @@ static int rpng2_win_create_window()
|
||||
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
|
||||
wimage_rowbytes*rpng2_info.height)))
|
||||
{
|
||||
return 4; /* fail */
|
||||
return 4; /* fail */
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -655,7 +714,7 @@ static int rpng2_win_create_window()
|
||||
TextOut(hdc, ((x < 0)? 0 : x), ((y < 0)? 0 : y), msg, len);
|
||||
ReleaseDC(global_hwnd, hdc);
|
||||
|
||||
rpng2_win_load_bg_image(); /* resets bg_image if fails */
|
||||
rpng2_win_load_bg_image(); /* resets bg_image if fails */
|
||||
}
|
||||
|
||||
if (!bg_image) {
|
||||
@@ -753,7 +812,7 @@ static int rpng2_win_load_bg_image()
|
||||
even_odd = even_odd_vert ^ even_odd_horiz;
|
||||
invert_column =
|
||||
(even_odd_horiz && (bg[pat].type & 0x10));
|
||||
if (even_odd == 0) { /* gradient #1 */
|
||||
if (even_odd == 0) { /* gradient #1 */
|
||||
if (invert_column) {
|
||||
*dest++ = r1_inv;
|
||||
*dest++ = g1_inv;
|
||||
@@ -763,16 +822,16 @@ static int rpng2_win_load_bg_image()
|
||||
*dest++ = g1;
|
||||
*dest++ = b1;
|
||||
}
|
||||
} else { /* gradient #2 */
|
||||
} else { /* gradient #2 */
|
||||
if ((invert_column && invert_gradient2) ||
|
||||
(!invert_column && !invert_gradient2))
|
||||
{
|
||||
*dest++ = r2; /* not inverted or */
|
||||
*dest++ = g2; /* doubly inverted */
|
||||
*dest++ = r2; /* not inverted or */
|
||||
*dest++ = g2; /* doubly inverted */
|
||||
*dest++ = b2;
|
||||
} else {
|
||||
*dest++ = r2_inv;
|
||||
*dest++ = g2_inv; /* singly inverted */
|
||||
*dest++ = g2_inv; /* singly inverted */
|
||||
*dest++ = b2_inv;
|
||||
}
|
||||
}
|
||||
@@ -786,8 +845,8 @@ static int rpng2_win_load_bg_image()
|
||||
|
||||
} else if ((bg[pat].type & 0x07) == 1) {
|
||||
|
||||
hmax = (bgscale-1)/2; /* half the max weight of a color */
|
||||
max = 2*hmax; /* the max weight of a color */
|
||||
hmax = (bgscale-1)/2; /* half the max weight of a color */
|
||||
max = 2*hmax; /* the max weight of a color */
|
||||
|
||||
r1 = rgb[bg[pat].rgb1_max].r;
|
||||
g1 = rgb[bg[pat].rgb1_max].g;
|
||||
@@ -908,7 +967,7 @@ static int rpng2_win_load_bg_image()
|
||||
g1 = *src++;
|
||||
b1 = *src++;
|
||||
*dest++ = b1;
|
||||
*dest++ = g1; /* note reverse order */
|
||||
*dest++ = g1; /* note reverse order */
|
||||
*dest++ = r1;
|
||||
}
|
||||
}
|
||||
@@ -962,7 +1021,7 @@ static void rpng2_win_display_row(ulg row)
|
||||
g = *src++;
|
||||
b = *src++;
|
||||
*dest++ = b;
|
||||
*dest++ = g; /* note reverse order */
|
||||
*dest++ = g; /* note reverse order */
|
||||
*dest++ = r;
|
||||
}
|
||||
} else /* if (rpng2_info.channels == 4) */ {
|
||||
@@ -1028,7 +1087,9 @@ static void rpng2_win_finish_display()
|
||||
* that the image is done */
|
||||
|
||||
rpng2_info.done = TRUE;
|
||||
printf("Done. Press Q, Esc or mouse button 1 to quit.\n");
|
||||
printf(
|
||||
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
@@ -1084,15 +1145,15 @@ LRESULT CALLBACK rpng2_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
|
||||
|
||||
/* wait for the user to tell us when to quit */
|
||||
case WM_CHAR:
|
||||
switch (wP) { /* only need one, so ignore repeat count */
|
||||
switch (wP) { /* only need one, so ignore repeat count */
|
||||
case 'q':
|
||||
case 'Q':
|
||||
case 0x1B: /* Esc key */
|
||||
case 0x1B: /* Esc key */
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_LBUTTONDOWN: /* another way of quitting */
|
||||
case WM_LBUTTONDOWN: /* another way of quitting */
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
rpng2 - progressive-model PNG display program rpng2-x.c
|
||||
rpng2 - progressive-model PNG display program rpng2-x.c
|
||||
|
||||
This program decodes and displays PNG files progressively, as if it were
|
||||
a web browser (though the front end is only set up to read from files).
|
||||
It supports gamma correction, user-specified background colors, and user-
|
||||
specified background patterns (for transparent images). This version is
|
||||
for the X Window System (tested under Unix, but may work under VMS or OS/2
|
||||
with a little tweaking). Thanks to Adam Costello and Pieter S. van der
|
||||
Meulen for the "diamond" and "radial waves" patterns, respectively.
|
||||
for the X Window System (tested by the author under Unix and by Martin
|
||||
Zinser under OpenVMS; may work under OS/2 with a little tweaking).
|
||||
|
||||
Thanks to Adam Costello and Pieter S. van der Meulen for the "diamond"
|
||||
and "radial waves" patterns, respectively.
|
||||
|
||||
to do:
|
||||
- 8-bit support
|
||||
@@ -17,7 +19,17 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Changelog:
|
||||
- 1.01: initial public release
|
||||
- 1.02: modified to allow abbreviated options; fixed char/uchar mismatch
|
||||
- 1.10: added support for non-default visuals; fixed X pixel-conversion
|
||||
- 1.11: added -usleep option for demos; fixed command-line parsing bug
|
||||
- 1.12: added -pause option for demos and testing
|
||||
- 1.20: added runtime MMX-enabling/disabling and new -mmx* options
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -44,21 +56,21 @@
|
||||
|
||||
#define PROGNAME "rpng2-x"
|
||||
#define LONGNAME "Progressive PNG Viewer for X"
|
||||
#define VERSION "1.01 of 31 March 1999"
|
||||
#define VERSION "1.20 of 29 January 2001"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
|
||||
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
|
||||
#include <time.h>
|
||||
#include <math.h> /* only for PvdM background code */
|
||||
#include <math.h> /* only for PvdM background code */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/keysym.h> /* defines XK_* macros */
|
||||
#include <X11/keysym.h> /* defines XK_* macros */
|
||||
|
||||
#ifdef VMS
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* all for PvdM background code: */
|
||||
@@ -79,9 +91,9 @@
|
||||
#define rgb2_max bg_bsat
|
||||
#define rgb2_min bg_brot
|
||||
|
||||
/* #define DEBUG */ /* this enables the Trace() macros */
|
||||
/* #define DEBUG */ /* this enables the Trace() macros */
|
||||
|
||||
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
|
||||
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
|
||||
|
||||
|
||||
/* could just include png.h, but this macro is the only thing we need
|
||||
@@ -89,18 +101,18 @@
|
||||
* only happen with alpha (which could easily be avoided with
|
||||
* "ush acopy = (alpha);") */
|
||||
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
#define alpha_composite(composite, fg, alpha, bg) { \
|
||||
ush temp = ((ush)(fg)*(ush)(alpha) + \
|
||||
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
|
||||
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
|
||||
}
|
||||
|
||||
|
||||
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
|
||||
* block size corresponds roughly to a download
|
||||
* speed 10% faster than theoretical 33.6K maximum
|
||||
* (assuming 8 data bits, 1 stop bit and no other
|
||||
* overhead) */
|
||||
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
|
||||
* block size corresponds roughly to a download
|
||||
* speed 10% faster than theoretical 33.6K maximum
|
||||
* (assuming 8 data bits, 1 stop bit and no other
|
||||
* overhead) */
|
||||
|
||||
/* local prototypes */
|
||||
static void rpng2_x_init(void);
|
||||
@@ -123,31 +135,35 @@ static mainprog_info rpng2_info;
|
||||
static uch inbuf[INBUFSIZE];
|
||||
static int incount;
|
||||
|
||||
static int pat = 6; /* must be less than num_bgpat */
|
||||
static int pat = 6; /* must be less than num_bgpat */
|
||||
static int bg_image = 0;
|
||||
static int bgscale = 16;
|
||||
static ulg bg_rowbytes;
|
||||
static uch *bg_data;
|
||||
|
||||
int pause_after_pass = FALSE;
|
||||
int demo_timing = FALSE;
|
||||
ulg usleep_duration = 0L;
|
||||
|
||||
static struct rgb_color {
|
||||
uch r, g, b;
|
||||
} rgb[] = {
|
||||
{ 0, 0, 0}, /* 0: black */
|
||||
{255, 255, 255}, /* 1: white */
|
||||
{173, 132, 57}, /* 2: tan */
|
||||
{ 64, 132, 0}, /* 3: medium green */
|
||||
{189, 117, 1}, /* 4: gold */
|
||||
{253, 249, 1}, /* 5: yellow */
|
||||
{ 0, 0, 255}, /* 6: blue */
|
||||
{ 0, 0, 120}, /* 7: medium blue */
|
||||
{255, 0, 255}, /* 8: magenta */
|
||||
{ 64, 0, 64}, /* 9: dark magenta */
|
||||
{255, 0, 0}, /* 10: red */
|
||||
{ 64, 0, 0}, /* 11: dark red */
|
||||
{255, 127, 0}, /* 12: orange */
|
||||
{192, 96, 0}, /* 13: darker orange */
|
||||
{ 24, 60, 0}, /* 14: dark green-yellow */
|
||||
{ 85, 125, 200} /* 15: ice blue */
|
||||
{ 0, 0, 0}, /* 0: black */
|
||||
{255, 255, 255}, /* 1: white */
|
||||
{173, 132, 57}, /* 2: tan */
|
||||
{ 64, 132, 0}, /* 3: medium green */
|
||||
{189, 117, 1}, /* 4: gold */
|
||||
{253, 249, 1}, /* 5: yellow */
|
||||
{ 0, 0, 255}, /* 6: blue */
|
||||
{ 0, 0, 120}, /* 7: medium blue */
|
||||
{255, 0, 255}, /* 8: magenta */
|
||||
{ 64, 0, 64}, /* 9: dark magenta */
|
||||
{255, 0, 0}, /* 10: red */
|
||||
{ 64, 0, 0}, /* 11: dark red */
|
||||
{255, 127, 0}, /* 12: orange */
|
||||
{192, 96, 0}, /* 13: darker orange */
|
||||
{ 24, 60, 0}, /* 14: dark green-yellow */
|
||||
{ 85, 125, 200} /* 15: ice blue */
|
||||
};
|
||||
/* not used for now, but should be for error-checking:
|
||||
static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
|
||||
@@ -172,21 +188,21 @@ static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
|
||||
*/
|
||||
static struct background_pattern {
|
||||
ush type;
|
||||
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
|
||||
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
|
||||
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
|
||||
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
|
||||
} bg[] = {
|
||||
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
|
||||
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
|
||||
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
|
||||
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
|
||||
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
|
||||
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
|
||||
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
|
||||
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
|
||||
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
|
||||
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
|
||||
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
|
||||
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
|
||||
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
|
||||
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
|
||||
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
|
||||
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
|
||||
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
|
||||
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
|
||||
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
|
||||
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
|
||||
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
|
||||
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
|
||||
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
|
||||
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
|
||||
{2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
|
||||
{2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
|
||||
{2, 16, 256, 100, 250}, /* radial: very tight spiral */
|
||||
@@ -201,12 +217,14 @@ static XImage *ximage;
|
||||
static Display *display;
|
||||
static int depth;
|
||||
static Visual *visual;
|
||||
static int RPixelShift, GPixelShift, BPixelShift;
|
||||
static ulg RedMask, GreenMask, BlueMask;
|
||||
static XVisualInfo *visual_list;
|
||||
static int RShift, GShift, BShift;
|
||||
static ulg RMask, GMask, BMask;
|
||||
static Window window;
|
||||
static GC gc;
|
||||
static Colormap colormap;
|
||||
|
||||
static int have_nondefault_visual = FALSE;
|
||||
static int have_colormap = FALSE;
|
||||
static int have_window = FALSE;
|
||||
|
||||
@@ -294,38 +312,66 @@ int main(int argc, char **argv)
|
||||
/* Now parse the command line for options and the PNG filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-display")) {
|
||||
if (!strncmp(*argv, "-display", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
displayname = *argv;
|
||||
} else if (!strcmp(*argv, "-gamma")) {
|
||||
else
|
||||
displayname = *argv;
|
||||
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
rpng2_info.display_exponent = atof(*argv);
|
||||
if (rpng2_info.display_exponent <= 0.0)
|
||||
++error;
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
have_bg = TRUE;
|
||||
bg_image = FALSE;
|
||||
rpng2_info.display_exponent = atof(*argv);
|
||||
if (rpng2_info.display_exponent <= 0.0)
|
||||
++error;
|
||||
}
|
||||
} else if (!strcmp(*argv, "-bgpat")) {
|
||||
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
pat = atoi(*argv) - 1;
|
||||
if (pat < 0 || pat >= num_bgpat)
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
have_bg = TRUE;
|
||||
bg_image = FALSE;
|
||||
}
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgpat", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
bg_image = TRUE;
|
||||
have_bg = FALSE;
|
||||
pat = atoi(*argv) - 1;
|
||||
if (pat < 0 || pat >= num_bgpat)
|
||||
++error;
|
||||
else {
|
||||
bg_image = TRUE;
|
||||
have_bg = FALSE;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(*argv, "-timing")) {
|
||||
} else if (!strncmp(*argv, "-usleep", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
usleep_duration = (ulg)atol(*argv);
|
||||
demo_timing = TRUE;
|
||||
}
|
||||
} else if (!strncmp(*argv, "-pause", 2)) {
|
||||
pause_after_pass = TRUE;
|
||||
} else if (!strncmp(*argv, "-timing", 2)) {
|
||||
timing = TRUE;
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
} else if (!strncmp(*argv, "-nommxfilters", 7)) {
|
||||
rpng2_info.nommxfilters = TRUE;
|
||||
} else if (!strncmp(*argv, "-nommxcombine", 7)) {
|
||||
rpng2_info.nommxcombine = TRUE;
|
||||
} else if (!strncmp(*argv, "-nommxinterlace", 7)) {
|
||||
rpng2_info.nommxinterlace = TRUE;
|
||||
} else if (!strcmp(*argv, "-nommx")) {
|
||||
rpng2_info.nommxfilters = TRUE;
|
||||
rpng2_info.nommxcombine = TRUE;
|
||||
rpng2_info.nommxinterlace = TRUE;
|
||||
#endif
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
filename = *argv;
|
||||
@@ -377,27 +423,44 @@ int main(int argc, char **argv)
|
||||
fclose(infile);
|
||||
}
|
||||
|
||||
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
||||
readpng2_version_info();
|
||||
fprintf(stderr, "\n"
|
||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
|
||||
" %*s [-timing] file.png\n\n"
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
" %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n"
|
||||
#endif
|
||||
" %*s [-usleep dur | -timing] [-pause] file.png\n\n"
|
||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7f00'' for orange: same as HTML colors);\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images; overrides -bgpat\n"
|
||||
" pat \tdesired background pattern number (1-%d); used with\n"
|
||||
"\t\t transparent images; overrides -bgcolor\n"
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
" -nommx*\tdisable optimized MMX routines for decoding row filters,\n"
|
||||
"\t\t combining rows, and expanding interlacing, respectively\n"
|
||||
#endif
|
||||
" dur \tduration in microseconds to wait after displaying each\n"
|
||||
"\t\t row (for demo purposes)\n"
|
||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||
"\t\t download of image (~36 Kbps)\n"
|
||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||
"\n", PROGNAME, strlen(PROGNAME), " ", default_display_exponent,
|
||||
num_bgpat);
|
||||
" -pause\tpauses after displaying each pass until key pressed\n"
|
||||
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
||||
"is displayed) to quit.\n"
|
||||
"\n", PROGNAME,
|
||||
#if (defined(__i386__) || defined(_M_IX86))
|
||||
strlen(PROGNAME), " ",
|
||||
#endif
|
||||
strlen(PROGNAME), " ", default_display_exponent, num_bgpat);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -489,7 +552,7 @@ int main(int argc, char **argv)
|
||||
* in turn is called by libpng after all of the pre-IDAT chunks have been
|
||||
* read and processed--i.e., we now have enough info to finish initializing */
|
||||
|
||||
static void rpng2_x_init()
|
||||
static void rpng2_x_init(void)
|
||||
{
|
||||
ulg i;
|
||||
ulg rowbytes = rpng2_info.rowbytes;
|
||||
@@ -531,12 +594,14 @@ static void rpng2_x_init()
|
||||
|
||||
|
||||
|
||||
static int rpng2_x_create_window()
|
||||
static int rpng2_x_create_window(void)
|
||||
{
|
||||
ulg bg_red = rpng2_info.bg_red;
|
||||
ulg bg_green = rpng2_info.bg_green;
|
||||
ulg bg_blue = rpng2_info.bg_blue;
|
||||
ulg bg_pixel = 0L;
|
||||
ulg attrmask;
|
||||
int need_colormap = FALSE;
|
||||
int screen, pad;
|
||||
uch *xdata;
|
||||
Window root;
|
||||
@@ -556,39 +621,70 @@ static int rpng2_x_create_window()
|
||||
depth = DisplayPlanes(display, screen);
|
||||
root = RootWindow(display, screen);
|
||||
|
||||
/* GRR: add 8-bit support */
|
||||
if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) {
|
||||
fprintf(stderr,
|
||||
"screen depth %d not supported (only 16-, 24- or 32-bit TrueColor)\n",
|
||||
depth);
|
||||
return 2;
|
||||
#ifdef DEBUG
|
||||
XSynchronize(display, True);
|
||||
#endif
|
||||
|
||||
if (depth != 16 && depth != 24 && depth != 32) {
|
||||
int visuals_matched = 0;
|
||||
|
||||
Trace((stderr, "default depth is %d: checking other visuals\n",
|
||||
depth))
|
||||
|
||||
/* 24-bit first */
|
||||
visual_info.screen = screen;
|
||||
visual_info.depth = 24;
|
||||
visual_list = XGetVisualInfo(display,
|
||||
VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched);
|
||||
if (visuals_matched == 0) {
|
||||
/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */
|
||||
fprintf(stderr, "default screen depth %d not supported, and no"
|
||||
" 24-bit visuals found\n", depth);
|
||||
return 2;
|
||||
}
|
||||
Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n",
|
||||
visuals_matched))
|
||||
visual = visual_list[0].visual;
|
||||
depth = visual_list[0].depth;
|
||||
/*
|
||||
colormap_size = visual_list[0].colormap_size;
|
||||
visual_class = visual->class;
|
||||
visualID = XVisualIDFromVisual(visual);
|
||||
*/
|
||||
have_nondefault_visual = TRUE;
|
||||
need_colormap = TRUE;
|
||||
} else {
|
||||
XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info);
|
||||
visual = visual_info.visual;
|
||||
}
|
||||
|
||||
XMatchVisualInfo(display, screen, depth,
|
||||
(depth == 8)? PseudoColor : TrueColor, &visual_info);
|
||||
visual = visual_info.visual;
|
||||
|
||||
RedMask = visual->red_mask;
|
||||
GreenMask = visual->green_mask;
|
||||
BlueMask = visual->blue_mask;
|
||||
RMask = visual->red_mask;
|
||||
GMask = visual->green_mask;
|
||||
BMask = visual->blue_mask;
|
||||
|
||||
/* GRR: add/check 8-bit support */
|
||||
if (depth == 8) {
|
||||
if (depth == 8 || need_colormap) {
|
||||
colormap = XCreateColormap(display, root, visual, AllocNone);
|
||||
if (!colormap) {
|
||||
fprintf(stderr, "XCreateColormap() failed\n");
|
||||
return 2;
|
||||
}
|
||||
have_colormap = TRUE;
|
||||
bg_image = FALSE; /* gradient just wastes palette entries */
|
||||
} else if (depth == 16) {
|
||||
RPixelShift = 15 - rpng2_x_msb(RedMask); /* these are right-shifts */
|
||||
GPixelShift = 15 - rpng2_x_msb(GreenMask);
|
||||
BPixelShift = 15 - rpng2_x_msb(BlueMask);
|
||||
} else /* if (depth > 16) */ {
|
||||
RPixelShift = rpng2_x_msb(RedMask) - 7; /* these are left-shifts */
|
||||
GPixelShift = rpng2_x_msb(GreenMask) - 7;
|
||||
BPixelShift = rpng2_x_msb(BlueMask) - 7;
|
||||
if (depth == 8)
|
||||
bg_image = FALSE; /* gradient just wastes palette entries */
|
||||
}
|
||||
if (depth == 15 || depth == 16) {
|
||||
RShift = 15 - rpng2_x_msb(RMask); /* these are right-shifts */
|
||||
GShift = 15 - rpng2_x_msb(GMask);
|
||||
BShift = 15 - rpng2_x_msb(BMask);
|
||||
} else if (depth > 16) {
|
||||
RShift = rpng2_x_msb(RMask) - 7; /* these are left-shifts */
|
||||
GShift = rpng2_x_msb(GMask) - 7;
|
||||
BShift = rpng2_x_msb(BMask) - 7;
|
||||
}
|
||||
if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) {
|
||||
fprintf(stderr, "rpng2 internal logic error: negative X shift(s)!\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -597,10 +693,16 @@ static int rpng2_x_create_window()
|
||||
|
||||
attr.backing_store = Always;
|
||||
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask;
|
||||
attrmask = CWBackingStore | CWEventMask;
|
||||
if (have_nondefault_visual) {
|
||||
attr.colormap = colormap;
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 1;
|
||||
attrmask |= CWColormap | CWBackPixel | CWBorderPixel;
|
||||
}
|
||||
|
||||
window = XCreateWindow(display, root, 0, 0, rpng2_info.width,
|
||||
rpng2_info.height, 0, depth, InputOutput, visual,
|
||||
CWBackingStore | CWEventMask, &attr);
|
||||
rpng2_info.height, 0, depth, InputOutput, visual, attrmask, &attr);
|
||||
|
||||
if (window == None) {
|
||||
fprintf(stderr, "XCreateWindow() failed\n");
|
||||
@@ -621,8 +723,9 @@ static int rpng2_x_create_window()
|
||||
if ((size_hints = XAllocSizeHints()) != NULL) {
|
||||
/* window will not be resizable */
|
||||
size_hints->flags = PMinSize | PMaxSize;
|
||||
size_hints->min_width = size_hints->max_width = rpng2_info.width;
|
||||
size_hints->min_height = size_hints->max_height = rpng2_info.height;
|
||||
size_hints->min_width = size_hints->max_width = (int)rpng2_info.width;
|
||||
size_hints->min_height = size_hints->max_height =
|
||||
(int)rpng2_info.height;
|
||||
}
|
||||
|
||||
if ((wm_hints = XAllocWMHints()) != NULL) {
|
||||
@@ -668,7 +771,7 @@ static int rpng2_x_create_window()
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* to avoid testing the bitmap order every pixel (or doubling the size of
|
||||
/* to avoid testing the byte order every pixel (or doubling the size of
|
||||
* the drawing routine with a giant if-test), we arbitrarily set the byte
|
||||
* order to MSBFirst and let Xlib worry about inverting things on little-
|
||||
* endian machines (e.g., Linux/x86, old VAXen, etc.)--this is not the
|
||||
@@ -684,17 +787,17 @@ static int rpng2_x_create_window()
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
if (bg_image)
|
||||
rpng2_x_load_bg_image(); /* resets bg_image if fails */
|
||||
rpng2_x_load_bg_image(); /* resets bg_image if fails */
|
||||
|
||||
if (!bg_image) {
|
||||
if (depth == 24 || depth == 32) {
|
||||
bg_pixel = (bg_red << RPixelShift) |
|
||||
(bg_green << GPixelShift) |
|
||||
(bg_blue << BPixelShift);
|
||||
bg_pixel = (bg_red << RShift) |
|
||||
(bg_green << GShift) |
|
||||
(bg_blue << BShift);
|
||||
} else if (depth == 16) {
|
||||
bg_pixel = (((bg_red << 8) >> RPixelShift) & RedMask) |
|
||||
(((bg_green << 8) >> GPixelShift) & GreenMask) |
|
||||
(((bg_blue << 8) >> BPixelShift) & BlueMask);
|
||||
bg_pixel = (((bg_red << 8) >> RShift) & RMask) |
|
||||
(((bg_green << 8) >> GShift) & GMask) |
|
||||
(((bg_blue << 8) >> BShift) & BMask);
|
||||
} else /* depth == 8 */ {
|
||||
|
||||
/* GRR: add 8-bit support */
|
||||
@@ -723,7 +826,7 @@ static int rpng2_x_create_window()
|
||||
|
||||
|
||||
|
||||
static int rpng2_x_load_bg_image()
|
||||
static int rpng2_x_load_bg_image(void)
|
||||
{
|
||||
uch *src;
|
||||
char *dest;
|
||||
@@ -772,8 +875,8 @@ static int rpng2_x_load_bg_image()
|
||||
int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min;
|
||||
|
||||
for (row = 0; row < rpng2_info.height; ++row) {
|
||||
yidx = row % bgscale;
|
||||
even_odd_vert = (row / bgscale) & 1;
|
||||
yidx = (int)(row % bgscale);
|
||||
even_odd_vert = (int)((row / bgscale) & 1);
|
||||
|
||||
r1 = r1_min + (r1_diff * yidx) / yidx_max;
|
||||
g1 = g1_min + (g1_diff * yidx) / yidx_max;
|
||||
@@ -789,13 +892,13 @@ static int rpng2_x_load_bg_image()
|
||||
g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max;
|
||||
b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max;
|
||||
|
||||
dest = (char *)(bg_data + row*bg_rowbytes);
|
||||
dest = (char *)bg_data + row*bg_rowbytes;
|
||||
for (i = 0; i < rpng2_info.width; ++i) {
|
||||
even_odd_horiz = (i / bgscale) & 1;
|
||||
even_odd_horiz = (int)((i / bgscale) & 1);
|
||||
even_odd = even_odd_vert ^ even_odd_horiz;
|
||||
invert_column =
|
||||
(even_odd_horiz && (bg[pat].type & 0x10));
|
||||
if (even_odd == 0) { /* gradient #1 */
|
||||
if (even_odd == 0) { /* gradient #1 */
|
||||
if (invert_column) {
|
||||
*dest++ = r1_inv;
|
||||
*dest++ = g1_inv;
|
||||
@@ -805,16 +908,16 @@ static int rpng2_x_load_bg_image()
|
||||
*dest++ = g1;
|
||||
*dest++ = b1;
|
||||
}
|
||||
} else { /* gradient #2 */
|
||||
} else { /* gradient #2 */
|
||||
if ((invert_column && invert_gradient2) ||
|
||||
(!invert_column && !invert_gradient2))
|
||||
{
|
||||
*dest++ = r2; /* not inverted or */
|
||||
*dest++ = g2; /* doubly inverted */
|
||||
*dest++ = r2; /* not inverted or */
|
||||
*dest++ = g2; /* doubly inverted */
|
||||
*dest++ = b2;
|
||||
} else {
|
||||
*dest++ = r2_inv;
|
||||
*dest++ = g2_inv; /* singly inverted */
|
||||
*dest++ = g2_inv; /* singly inverted */
|
||||
*dest++ = b2_inv;
|
||||
}
|
||||
}
|
||||
@@ -828,8 +931,8 @@ static int rpng2_x_load_bg_image()
|
||||
|
||||
} else if ((bg[pat].type & 0x07) == 1) {
|
||||
|
||||
hmax = (bgscale-1)/2; /* half the max weight of a color */
|
||||
max = 2*hmax; /* the max weight of a color */
|
||||
hmax = (bgscale-1)/2; /* half the max weight of a color */
|
||||
max = 2*hmax; /* the max weight of a color */
|
||||
|
||||
r1 = rgb[bg[pat].rgb1_max].r;
|
||||
g1 = rgb[bg[pat].rgb1_max].g;
|
||||
@@ -839,12 +942,12 @@ static int rpng2_x_load_bg_image()
|
||||
b2 = rgb[bg[pat].rgb2_max].b;
|
||||
|
||||
for (row = 0; row < rpng2_info.height; ++row) {
|
||||
yidx = row % bgscale;
|
||||
yidx = (int)(row % bgscale);
|
||||
if (yidx > hmax)
|
||||
yidx = bgscale-1 - yidx;
|
||||
dest = (char *)(bg_data + row*bg_rowbytes);
|
||||
dest = (char *)bg_data + row*bg_rowbytes;
|
||||
for (i = 0; i < rpng2_info.width; ++i) {
|
||||
xidx = i % bgscale;
|
||||
xidx = (int)(i % bgscale);
|
||||
if (xidx > hmax)
|
||||
xidx = bgscale-1 - xidx;
|
||||
k = xidx + yidx;
|
||||
@@ -871,8 +974,8 @@ static int rpng2_x_load_bg_image()
|
||||
PROGNAME);
|
||||
fflush(stderr);
|
||||
|
||||
hh = rpng2_info.height / 2;
|
||||
hw = rpng2_info.width / 2;
|
||||
hh = (int)(rpng2_info.height / 2);
|
||||
hw = (int)(rpng2_info.width / 2);
|
||||
|
||||
/* variables for radial waves:
|
||||
* aoffset: number of degrees to rotate hue [CURRENTLY NOT USED]
|
||||
@@ -891,10 +994,10 @@ static int rpng2_x_load_bg_image()
|
||||
maxDist = (double)((hw*hw) + (hh*hh));
|
||||
|
||||
for (row = 0; row < rpng2_info.height; ++row) {
|
||||
y = row - hh;
|
||||
dest = (char *)(bg_data + row*bg_rowbytes);
|
||||
y = (int)(row - hh);
|
||||
dest = (char *)bg_data + row*bg_rowbytes;
|
||||
for (i = 0; i < rpng2_info.width; ++i) {
|
||||
x = i - hw;
|
||||
x = (int)(i - hw);
|
||||
angle = (x == 0)? PI_2 : atan((double)y / (double)x);
|
||||
gray = (double)MAX(ABS(y), ABS(x)) / grayspot;
|
||||
gray = MIN(1.0, gray);
|
||||
@@ -951,14 +1054,15 @@ static int rpng2_x_load_bg_image()
|
||||
red = *src++;
|
||||
green = *src++;
|
||||
blue = *src++;
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -969,18 +1073,15 @@ static int rpng2_x_load_bg_image()
|
||||
src = bg_data + row*bg_rowbytes;
|
||||
dest = ximage->data + row*ximage_rowbytes;
|
||||
for (i = rpng2_info.width; i > 0; --i) {
|
||||
red = ((ush)(*src) << 8);
|
||||
++src;
|
||||
green = ((ush)(*src) << 8);
|
||||
++src;
|
||||
blue = ((ush)(*src) << 8);
|
||||
++src;
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
red = ((ush)(*src) << 8); ++src;
|
||||
green = ((ush)(*src) << 8); ++src;
|
||||
blue = ((ush)(*src) << 8); ++src;
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1011,7 +1112,7 @@ static void rpng2_x_display_row(ulg row)
|
||||
uch r, g, b, a;
|
||||
int ximage_rowbytes = ximage->bytes_per_line;
|
||||
ulg i, pixel;
|
||||
static int rows=0;
|
||||
static int rows=0, prevpass=(-1);
|
||||
static ulg firstrow;
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -1022,8 +1123,28 @@ static void rpng2_x_display_row(ulg row)
|
||||
|
||||
Trace((stderr, "beginning rpng2_x_display_row()\n"))
|
||||
|
||||
if (rpng2_info.pass != prevpass) {
|
||||
if (pause_after_pass && rpng2_info.pass > 0) {
|
||||
XEvent e;
|
||||
KeySym k;
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: end of pass %d of 7; click in image window to continue\n",
|
||||
PROGNAME, prevpass + 1);
|
||||
do
|
||||
XNextEvent(display, &e);
|
||||
while (!(e.type == ButtonPress && e.xbutton.button == Button1)
|
||||
&& !(e.type == KeyPress &&
|
||||
((k = XLookupKeysym(&e.xkey, 0)) == XK_q
|
||||
|| k == XK_Escape) )) ;
|
||||
}
|
||||
fprintf(stderr, "%s: pass %d of 7\r", PROGNAME, rpng2_info.pass + 1);
|
||||
fflush(stderr);
|
||||
prevpass = rpng2_info.pass;
|
||||
}
|
||||
|
||||
if (rows == 0)
|
||||
firstrow = row; /* first row not yet displayed */
|
||||
firstrow = row; /* first row that is not yet displayed */
|
||||
|
||||
++rows; /* count of rows received but not yet displayed */
|
||||
|
||||
@@ -1046,14 +1167,15 @@ static void rpng2_x_display_row(ulg row)
|
||||
red = *src++;
|
||||
green = *src++;
|
||||
blue = *src++;
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
} else /* if (rpng2_info.channels == 4) */ {
|
||||
for (i = rpng2_info.width; i > 0; --i) {
|
||||
@@ -1082,14 +1204,15 @@ static void rpng2_x_display_row(ulg row)
|
||||
alpha_composite(green, g, a, bg_green);
|
||||
alpha_composite(blue, b, a, bg_blue);
|
||||
}
|
||||
pixel = (red << RPixelShift) |
|
||||
(green << GPixelShift) |
|
||||
(blue << BPixelShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst */
|
||||
*dest++ = ((uch *)&pixel)[3];
|
||||
*dest++ = ((uch *)&pixel)[2];
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
pixel = (red << RShift) |
|
||||
(green << GShift) |
|
||||
(blue << BShift);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
/* GRR BUG: this assumes bpp == 32, but may be 24: */
|
||||
*dest++ = (char)((pixel >> 24) & 0xff);
|
||||
*dest++ = (char)((pixel >> 16) & 0xff);
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1108,12 +1231,12 @@ static void rpng2_x_display_row(ulg row)
|
||||
++src;
|
||||
blue = ((ush)(*src) << 8);
|
||||
++src;
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
} else /* if (rpng2_info.channels == 4) */ {
|
||||
for (i = rpng2_info.width; i > 0; --i) {
|
||||
@@ -1145,12 +1268,12 @@ static void rpng2_x_display_row(ulg row)
|
||||
green = ((ush)g << 8);
|
||||
blue = ((ush)b << 8);
|
||||
}
|
||||
pixel = ((red >> RPixelShift) & RedMask) |
|
||||
((green >> GPixelShift) & GreenMask) |
|
||||
((blue >> BPixelShift) & BlueMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst */
|
||||
*dest++ = ((uch *)&pixel)[1];
|
||||
*dest++ = ((uch *)&pixel)[0];
|
||||
pixel = ((red >> RShift) & RMask) |
|
||||
((green >> GShift) & GMask) |
|
||||
((blue >> BShift) & BMask);
|
||||
/* recall that we set ximage->byte_order = MSBFirst above */
|
||||
*dest++ = (char)((pixel >> 8) & 0xff);
|
||||
*dest++ = (char)( pixel & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1162,13 +1285,23 @@ static void rpng2_x_display_row(ulg row)
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Display after every 16 rows or when on last row. (Region may include
|
||||
previously displayed lines due to interlacing--i.e., not contiguous.)
|
||||
Display after every 16 rows or when on one of last two rows. (Region
|
||||
may include previously displayed lines due to interlacing--i.e., not
|
||||
contiguous. Also, second-to-last row is final one in interlaced images
|
||||
with odd number of rows.) For demos, flush (and delay) after every 16th
|
||||
row so "sparse" passes don't go twice as fast.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
if ((rows & 0xf) == 0 || row == rpng2_info.height-1) {
|
||||
XPutImage(display, window, gc, ximage, 0, firstrow, 0, firstrow,
|
||||
rpng2_info.width, row - firstrow + 1);
|
||||
if (demo_timing && (row - firstrow >= 16 || row >= rpng2_info.height-2)) {
|
||||
XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0,
|
||||
(int)firstrow, rpng2_info.width, row - firstrow + 1);
|
||||
XFlush(display);
|
||||
rows = 0;
|
||||
usleep(usleep_duration);
|
||||
} else
|
||||
if (!demo_timing && ((rows & 0xf) == 0 || row >= rpng2_info.height-2)) {
|
||||
XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0,
|
||||
(int)firstrow, rpng2_info.width, row - firstrow + 1);
|
||||
XFlush(display);
|
||||
rows = 0;
|
||||
}
|
||||
@@ -1179,7 +1312,7 @@ static void rpng2_x_display_row(ulg row)
|
||||
|
||||
|
||||
|
||||
static void rpng2_x_finish_display()
|
||||
static void rpng2_x_finish_display(void)
|
||||
{
|
||||
Trace((stderr, "beginning rpng2_x_finish_display()\n"))
|
||||
|
||||
@@ -1188,14 +1321,16 @@ static void rpng2_x_finish_display()
|
||||
* the image is done */
|
||||
|
||||
rpng2_info.done = TRUE;
|
||||
printf("Done. Press Q, Esc or mouse button 1 to quit.\n");
|
||||
printf(
|
||||
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void rpng2_x_cleanup()
|
||||
static void rpng2_x_cleanup(void)
|
||||
{
|
||||
if (bg_image && bg_data) {
|
||||
free(bg_data);
|
||||
@@ -1228,6 +1363,9 @@ static void rpng2_x_cleanup()
|
||||
|
||||
if (have_colormap)
|
||||
XFreeColormap(display, colormap);
|
||||
|
||||
if (have_nondefault_visual)
|
||||
XFree(visual_list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BIN
contrib/gregbook/toucan.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
@@ -19,7 +19,15 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Changelog:
|
||||
- 1.01: initial public release
|
||||
- 1.02: modified to allow abbreviated options
|
||||
- 1.03: removed extraneous character from usage screen; fixed bug in
|
||||
command-line parsing
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -45,7 +53,7 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#define PROGNAME "wpng"
|
||||
#define VERSION "1.01 of 31 March 1999"
|
||||
#define VERSION "1.03 of 19 March 2000"
|
||||
#define APPNAME "Simple PGM/PPM/PAM to PNG Converter"
|
||||
|
||||
#if defined(__MSDOS__) || defined(__OS2__)
|
||||
@@ -57,27 +65,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h> /* for jmpbuf declaration in writepng.h */
|
||||
#include <setjmp.h> /* for jmpbuf declaration in writepng.h */
|
||||
#include <time.h>
|
||||
|
||||
#ifdef DOS_OS2_W32
|
||||
# include <io.h> /* for isatty(), setmode() prototypes */
|
||||
# include <fcntl.h> /* O_BINARY for fdopen() without text translation */
|
||||
# include <io.h> /* for isatty(), setmode() prototypes */
|
||||
# include <fcntl.h> /* O_BINARY for fdopen() without text translation */
|
||||
# ifdef __EMX__
|
||||
# ifndef getch
|
||||
# define getch() _read_kbd(0, 1, 0) /* need getche() */
|
||||
# define getch() _read_kbd(0, 1, 0) /* need getche() */
|
||||
# endif
|
||||
# else /* !__EMX__ */
|
||||
# ifdef __GO32__
|
||||
# include <pc.h>
|
||||
# define getch() getkey() /* GRR: need getche() */
|
||||
# define getch() getkey() /* GRR: need getche() */
|
||||
# else
|
||||
# include <conio.h> /* for getche() console input */
|
||||
# include <conio.h> /* for getche() console input */
|
||||
# endif
|
||||
# endif /* ?__EMX__ */
|
||||
# define FGETS(buf,len,stream) dos_kbd_gets(buf,len)
|
||||
#else
|
||||
# include <unistd.h> /* for isatty() prototype */
|
||||
# include <unistd.h> /* for isatty() prototype */
|
||||
# define FGETS fgets
|
||||
#endif
|
||||
|
||||
@@ -87,7 +95,7 @@
|
||||
text that includes control characters discouraged by the PNG spec; text
|
||||
that includes an escape character (27) must be re-entered regardless */
|
||||
|
||||
#include "writepng.h" /* typedefs, common macros, writepng prototypes */
|
||||
#include "writepng.h" /* typedefs, common macros, writepng prototypes */
|
||||
|
||||
|
||||
|
||||
@@ -112,7 +120,7 @@ int main(int argc, char **argv)
|
||||
FILE *keybd;
|
||||
#endif
|
||||
#ifdef sgi
|
||||
FILE *tmpfile; /* or we could just use keybd, since no overlap */
|
||||
FILE *tmpfile; /* or we could just use keybd, since no overlap */
|
||||
char tmpline[80];
|
||||
#endif
|
||||
char *inname = NULL, outname[256];
|
||||
@@ -204,36 +212,40 @@ int main(int argc, char **argv)
|
||||
/* Now parse the command line for options and the PNM filename. */
|
||||
|
||||
while (*++argv && !error) {
|
||||
if (!strcmp(*argv, "-interlaced")) {
|
||||
if (!strncmp(*argv, "-i", 2)) {
|
||||
wpng_info.interlaced = TRUE;
|
||||
} else if (!strcmp(*argv, "-time")) {
|
||||
} else if (!strncmp(*argv, "-time", 3)) {
|
||||
wpng_info.modtime = time(NULL);
|
||||
wpng_info.have_time = TRUE;
|
||||
} else if (!strcmp(*argv, "-text")) {
|
||||
} else if (!strncmp(*argv, "-text", 3)) {
|
||||
text = TRUE;
|
||||
} else if (!strcmp(*argv, "-gamma")) {
|
||||
} else if (!strncmp(*argv, "-gamma", 2)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
wpng_info.gamma = atof(*argv);
|
||||
if (wpng_info.gamma <= 0.0)
|
||||
++error;
|
||||
else if (wpng_info.gamma > 1.01)
|
||||
fprintf(stderr, PROGNAME
|
||||
" warning: file gammas are usually less than 1.0\n");
|
||||
} else if (!strcmp(*argv, "-bgcolor")) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
unsigned r, g, b; /* this approach quiets compiler warnings */
|
||||
wpng_info.gamma = atof(*argv);
|
||||
if (wpng_info.gamma <= 0.0)
|
||||
++error;
|
||||
else if (wpng_info.gamma > 1.01)
|
||||
fprintf(stderr, PROGNAME
|
||||
" warning: file gammas are usually less than 1.0\n");
|
||||
}
|
||||
} else if (!strncmp(*argv, "-bgcolor", 4)) {
|
||||
if (!*++argv)
|
||||
++error;
|
||||
else {
|
||||
bgstr = *argv;
|
||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||
++error;
|
||||
else {
|
||||
unsigned r, g, b; /* this way quiets compiler warnings */
|
||||
|
||||
sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b);
|
||||
wpng_info.bg_red = (uch)r;
|
||||
wpng_info.bg_green = (uch)g;
|
||||
wpng_info.bg_blue = (uch)b;
|
||||
wpng_info.have_bg = TRUE;
|
||||
sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b);
|
||||
wpng_info.bg_red = (uch)r;
|
||||
wpng_info.bg_green = (uch)g;
|
||||
wpng_info.bg_blue = (uch)b;
|
||||
wpng_info.have_bg = TRUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (**argv != '-') {
|
||||
@@ -269,7 +281,7 @@ int main(int argc, char **argv)
|
||||
": unable to reopen stdout in binary mode\n");
|
||||
fclose(wpng_info.infile);
|
||||
++error;
|
||||
} else
|
||||
} else
|
||||
wpng_info.filter = TRUE;
|
||||
}
|
||||
} else if ((len = strlen(inname)) > 250) {
|
||||
@@ -362,7 +374,7 @@ int main(int argc, char **argv)
|
||||
"\t\t (where LUT = lookup-table exponent and CRT = CRT exponent;\n"
|
||||
"\t\t first varies, second is usually 2.2, all are positive)\n"
|
||||
" bg \tdesired background color for alpha-channel images, in\n"
|
||||
"\t\t 7-character hex RGB format (e.g., ``#ff7f00'' for orange:\n"
|
||||
"\t\t 7-character hex RGB format (e.g., ``#ff7700'' for orange:\n"
|
||||
"\t\t same as HTML colors)\n"
|
||||
" -text\tprompt interactively for text info (tEXt chunks)\n"
|
||||
" -time\tinclude a tIME chunk (last modification time)\n"
|
||||
@@ -419,7 +431,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_TITLE;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_TITLE;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -449,7 +461,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_AUTHOR;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_AUTHOR;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -489,7 +501,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_DESC;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_DESC;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -519,7 +531,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_COPY;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_COPY;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -549,7 +561,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_EMAIL;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_EMAIL;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -579,7 +591,7 @@ int main(int argc, char **argv)
|
||||
wpng_info.have_text &= ~TEXT_URL;
|
||||
valid = FALSE;
|
||||
#else
|
||||
if (p[result] == 27) { /* escape character */
|
||||
if (p[result] == 27) { /* escape character */
|
||||
wpng_info.have_text &= ~TEXT_URL;
|
||||
valid = FALSE;
|
||||
}
|
||||
@@ -743,10 +755,10 @@ static int wpng_isvalid_latin1(uch *p, int len)
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
if (p[i] == 10 || (p[i] > 31 && p[i] < 127) || p[i] > 160)
|
||||
continue; /* character is completely OK */
|
||||
continue; /* character is completely OK */
|
||||
if (result < 0 || (p[result] != 27 && p[i] == 27))
|
||||
result = i; /* mark location of first questionable one */
|
||||
} /* or of first escape character (bad) */
|
||||
result = i; /* mark location of first questionable one */
|
||||
} /* or of first escape character (bad) */
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -755,7 +767,7 @@ static int wpng_isvalid_latin1(uch *p, int len)
|
||||
|
||||
|
||||
|
||||
static void wpng_cleanup()
|
||||
static void wpng_cleanup(void)
|
||||
{
|
||||
if (wpng_info.outfile) {
|
||||
fclose(wpng_info.outfile);
|
||||
@@ -791,11 +803,11 @@ static char *dos_kbd_gets(char *buf, int len)
|
||||
buf[count++] = ch = getche();
|
||||
} while (ch != '\r' && count < len-1);
|
||||
|
||||
buf[count--] = '\0'; /* terminate string */
|
||||
if (buf[count] == '\r') /* Enter key makes CR, so change to newline */
|
||||
buf[count--] = '\0'; /* terminate string */
|
||||
if (buf[count] == '\r') /* Enter key makes CR, so change to newline */
|
||||
buf[count] = '\n';
|
||||
|
||||
fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */
|
||||
fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */
|
||||
fflush(stderr);
|
||||
|
||||
return buf;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -30,10 +30,10 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
#include <stdlib.h> /* for exit() prototype */
|
||||
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
||||
|
||||
|
||||
/* local prototype */
|
||||
@@ -42,13 +42,13 @@ static void writepng_error_handler(png_structp png_ptr, png_const_charp msg);
|
||||
|
||||
|
||||
|
||||
void writepng_version_info()
|
||||
void writepng_version_info(void)
|
||||
{
|
||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
|
||||
ZLIB_VERSION, zlib_version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-1999 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
|
||||
22
contrib/msvctest/README.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
Microsoft Developer Studio Build File, Format Version 6.00 for
|
||||
msvctest
|
||||
|
||||
Assumes that libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng
|
||||
Assumes that zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib
|
||||
|
||||
To build:
|
||||
|
||||
1) On the main menu Select "Build|Set Active configuration".
|
||||
Choose the configuration that corresponds to the library you want to test.
|
||||
This library must have been built using the libpng MS project located in
|
||||
the "mscv" subdirectory.
|
||||
|
||||
2) Select "Build|Clean"
|
||||
|
||||
3) Select "Build|Rebuild All"
|
||||
|
||||
4) The test results should appear in the "Build" pane of the Output Window.
|
||||
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Methodex Computer Systems Inc.
|
||||
247
contrib/msvctest/msvctest.dsp
Normal file
@@ -0,0 +1,247 @@
|
||||
# Microsoft Developer Studio Project File - Name="msvctest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=msvctest - Win32 Debug DLL
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "msvctest.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "msvctest.mak" CFG="msvctest - Win32 Debug DLL"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "msvctest - Win32 DLL" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "msvctest - Win32 Debug DLL" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "msvctest - Win32 ASM DLL" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "msvctest - Win32 Debug ASM DLL" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "msvctest - Win32 LIB" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "msvctest - Win32 Debug LIB" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "msvctest - Win32 DLL"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "dll"
|
||||
# PROP BASE Intermediate_Dir "dll"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "dll"
|
||||
# PROP Intermediate_Dir "dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll\libpng2.lib /nologo /subsystem:console /machine:I386
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\dll
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=[Run Test]
|
||||
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll;..\..\projects\msvc\win32\zlib\dll; $(outdir)\msvctest.exe ..\..\pngtest.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "msvctest - Win32 Debug DLL"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "dll_dbg"
|
||||
# PROP BASE Intermediate_Dir "dll_dbg"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "dll_dbg"
|
||||
# PROP Intermediate_Dir "dll_dbg"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbg\libpng2d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\dll_dbg
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=[Run Test]
|
||||
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbg;..\..\projects\msvc\win32\zlib\dll_dbg; $(outdir)\msvctest.exe ..\..\pngtest.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "msvctest - Win32 ASM DLL"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "dll_asm"
|
||||
# PROP BASE Intermediate_Dir "dll_asm"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "dll_asm"
|
||||
# PROP Intermediate_Dir "dll_asm"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_asm\libpng2a.lib /nologo /subsystem:console /machine:I386
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\dll_asm
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=[Run Test]
|
||||
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_asm;..\..\projects\msvc\win32\zlib\dll_asm; $(outdir)\msvctest.exe ..\..\pngtest.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "msvctest - Win32 Debug ASM DLL"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "dll_dbga"
|
||||
# PROP BASE Intermediate_Dir "dll_dbga"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "dll_dbga"
|
||||
# PROP Intermediate_Dir "dll_dbga"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbga\libpng2b.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\dll_dbga
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=[Run Test]
|
||||
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbga;..\..\projects\msvc\win32\zlib\dll_dbga; $(outdir)\msvctest.exe ..\..\pngtest.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "msvctest - Win32 LIB"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "lib"
|
||||
# PROP BASE Intermediate_Dir "lib"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "lib"
|
||||
# PROP Intermediate_Dir "lib"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
|
||||
# ADD CPP /nologo /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 ..\..\projects\msvc\win32\libpng\lib\libpng.lib /nologo /subsystem:console /machine:I386
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\lib
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=[Run Test]
|
||||
PostBuild_Cmds=$(outdir)\msvctest.exe ..\..\pngtest.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "msvctest - Win32 Debug LIB"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "lib_dbg"
|
||||
# PROP BASE Intermediate_Dir "lib_dbg"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "lib_dbg"
|
||||
# PROP Intermediate_Dir "lib_dbg"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 ..\..\projects\msvc\win32\libpng\lib_dbg\libpng.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\lib_dbg
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=[Run Test]
|
||||
PostBuild_Cmds=$(outdir)\msvctest.exe ..\..\pngtest.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "msvctest - Win32 DLL"
|
||||
# Name "msvctest - Win32 Debug DLL"
|
||||
# Name "msvctest - Win32 ASM DLL"
|
||||
# Name "msvctest - Win32 Debug ASM DLL"
|
||||
# Name "msvctest - Win32 LIB"
|
||||
# Name "msvctest - Win32 Debug LIB"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngtest.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\README.txt
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
contrib/msvctest/msvctest.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "msvctest"=.\msvctest.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PngMinus
|
||||
PngMinus
|
||||
--------
|
||||
(copyright Willem van Schaik, 1999)
|
||||
|
||||
@@ -19,7 +19,7 @@ Some history
|
||||
Soon after the creation of PNG in 1995, the need was felt for a set of
|
||||
pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I
|
||||
(Willem van Schaik) started such a project. Luckily we discovered this
|
||||
and merged the two together into pnmtopng.tar.gz, which is available
|
||||
and merged the two together into pnmtopng.tar.gz, which is available
|
||||
from a/o ftp://swrinde.nde.swri.edu/pub/png/.
|
||||
|
||||
These two utilities have many, many options and make use of most of the
|
||||
|
||||
@@ -39,15 +39,15 @@ $ write sys$output "Compiling PNG contrib programs ..."
|
||||
$ write sys$output "Building pnm2png..."
|
||||
$ CALL MAKE pnm2png.OBJ "cc ''CCOPT' pnm2png" -
|
||||
pnm2png.c
|
||||
$ call make pnm2png.exe -
|
||||
"LINK pnm2png,lib.opt/opt" -
|
||||
$ call make pnm2png.exe -
|
||||
"LINK pnm2png,lib.opt/opt" -
|
||||
pnm2png.obj
|
||||
$ write sys$output "Building png2pnm..."
|
||||
$ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" -
|
||||
png2pnm.c
|
||||
$ call make pnm2png.exe -
|
||||
"LINK pnm2png,lib.opt/opt" -
|
||||
pnm2png.obj
|
||||
$ call make png2pnm.exe -
|
||||
"LINK png2pnm,lib.opt/opt" -
|
||||
png2pnm.obj
|
||||
$ exit
|
||||
$!
|
||||
$!
|
||||
|
||||
@@ -42,6 +42,11 @@
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#endif
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
@@ -183,7 +188,7 @@ void usage()
|
||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
|
||||
{
|
||||
png_struct *png_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_byte buf[8];
|
||||
png_byte *png_pixels = NULL;
|
||||
png_byte **row_pointers = NULL;
|
||||
@@ -199,6 +204,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
||||
int row, col;
|
||||
int ret;
|
||||
int i;
|
||||
long dep_16;
|
||||
|
||||
/* read and check signature in PNG file */
|
||||
ret = fread (buf, 1, 8, png_file);
|
||||
@@ -217,13 +223,13 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
||||
return FALSE; /* out of memory */
|
||||
|
||||
info_ptr = png_create_info_struct (png_ptr);
|
||||
if (!info_ptr)
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, NULL, NULL);
|
||||
return FALSE; /* out of memory */
|
||||
}
|
||||
|
||||
if (setjmp (png_ptr->jmpbuf))
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
return FALSE;
|
||||
@@ -237,7 +243,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
||||
png_read_info (png_ptr, info_ptr);
|
||||
|
||||
/* get size and bit-depth of the PNG-image */
|
||||
png_get_IHDR (png_ptr, info_ptr,
|
||||
png_get_IHDR (png_ptr, info_ptr,
|
||||
&width, &height, &bit_depth, &color_type,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
@@ -294,7 +300,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
channels = 4;
|
||||
else
|
||||
channels = 0; /* should never happen */
|
||||
channels = 0; /* should never happen */
|
||||
alpha_present = (channels - 1) % 2;
|
||||
|
||||
/* check if alpha is expected to be present in file */
|
||||
@@ -313,7 +319,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
free (png_pixels);
|
||||
@@ -374,8 +380,10 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
||||
if (raw)
|
||||
fputc ((int) *pix_ptr++ , pnm_file);
|
||||
else
|
||||
if (bit_depth == 16)
|
||||
fprintf (pnm_file, "%ld ", ((long) *pix_ptr++ << 8) + (long) *pix_ptr++);
|
||||
if (bit_depth == 16){
|
||||
dep_16 = (long) *pix_ptr++;
|
||||
fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++));
|
||||
}
|
||||
else
|
||||
fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
|
||||
}
|
||||
@@ -392,8 +400,10 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
||||
if (raw)
|
||||
fputc ((int) *pix_ptr++ , alpha_file);
|
||||
else
|
||||
if (bit_depth == 16)
|
||||
fprintf (alpha_file, "%ld ", ((long) *pix_ptr++ << 8) + (long) *pix_ptr++);
|
||||
if (bit_depth == 16){
|
||||
dep_16 = (long) *pix_ptr++;
|
||||
fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
|
||||
}
|
||||
else
|
||||
fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#endif
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
@@ -64,9 +69,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (argi = 1; argi < argc; argi++)
|
||||
{
|
||||
if (argv[argi][0] == '-')
|
||||
if (argv[argi][0] == '-')
|
||||
{
|
||||
switch (argv[argi][1])
|
||||
switch (argv[argi][1])
|
||||
{
|
||||
case 'i':
|
||||
interlace = TRUE;
|
||||
@@ -77,7 +82,8 @@ int main(int argc, char *argv[])
|
||||
if ((fp_al = fopen (argv[argi], "rb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: alpha-channel file %s does not exist\n", argv[argi]);
|
||||
fprintf (stderr, "Error: alpha-channel file %s does not exist\n",
|
||||
argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
@@ -385,7 +391,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
}
|
||||
|
||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||
if (setjmp (png_ptr->jmpbuf))
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
return FALSE;
|
||||
@@ -405,7 +411,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
/* if needed we will allocate memory for an new array of row-pointers */
|
||||
if (row_pointers == (unsigned char**) NULL)
|
||||
{
|
||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
return FALSE;
|
||||
@@ -418,13 +424,13 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
/* write out the entire image data in one call */
|
||||
png_write_image (png_ptr, row_pointers);
|
||||
|
||||
|
||||
/* write the additional chuncks to the PNG file (not really needed) */
|
||||
png_write_end (png_ptr, info_ptr);
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
|
||||
|
||||
if (row_pointers != (unsigned char**) NULL)
|
||||
free (row_pointers);
|
||||
if (png_pixels != (unsigned char*) NULL)
|
||||
@@ -511,8 +517,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
for (i = 0; i < depth; i++)
|
||||
mask = (mask << 1) | 0x01;
|
||||
|
||||
get_token (pnm_file, token);
|
||||
sscanf (token, "%lu", &ret_value);
|
||||
get_token (pnm_file, (char *) token);
|
||||
sscanf ((const char *) token, "%lu", &ret_value);
|
||||
|
||||
ret_value &= mask;
|
||||
|
||||
|
||||
439
contrib/visupng/PngFile.c
Normal file
@@ -0,0 +1,439 @@
|
||||
//-------------------------------------
|
||||
// PNGFILE.C -- Image File Functions
|
||||
//-------------------------------------
|
||||
|
||||
// Copyright 2000, Willem van Schaik. For conditions of distribution and
|
||||
// use, see the copyright/license/disclaimer notice in png.h
|
||||
|
||||
#include <windows.h>
|
||||
#include <commdlg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "png.h"
|
||||
#include "pngfile.h"
|
||||
#include "cexcept.h"
|
||||
|
||||
define_exception_type(const char *);
|
||||
extern struct exception_context the_exception_context[1];
|
||||
struct exception_context the_exception_context[1];
|
||||
png_const_charp msg;
|
||||
|
||||
static OPENFILENAME ofn;
|
||||
|
||||
static png_structp png_ptr = NULL;
|
||||
static png_infop info_ptr = NULL;
|
||||
|
||||
|
||||
// cexcept interface
|
||||
|
||||
static void
|
||||
png_cexcept_error(png_structp png_ptr, png_const_charp msg)
|
||||
{
|
||||
if(png_ptr)
|
||||
;
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
fprintf(stderr, "libpng error: %s\n", msg);
|
||||
#endif
|
||||
{
|
||||
Throw msg;
|
||||
}
|
||||
}
|
||||
|
||||
// Windows open-file functions
|
||||
|
||||
void PngFileInitialize (HWND hwnd)
|
||||
{
|
||||
static TCHAR szFilter[] = TEXT ("PNG Files (*.PNG)\0*.png\0")
|
||||
TEXT ("All Files (*.*)\0*.*\0\0");
|
||||
|
||||
ofn.lStructSize = sizeof (OPENFILENAME);
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.hInstance = NULL;
|
||||
ofn.lpstrFilter = szFilter;
|
||||
ofn.lpstrCustomFilter = NULL;
|
||||
ofn.nMaxCustFilter = 0;
|
||||
ofn.nFilterIndex = 0;
|
||||
ofn.lpstrFile = NULL; // Set in Open and Close functions
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrFileTitle = NULL; // Set in Open and Close functions
|
||||
ofn.nMaxFileTitle = MAX_PATH;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.lpstrTitle = NULL;
|
||||
ofn.Flags = 0; // Set in Open and Close functions
|
||||
ofn.nFileOffset = 0;
|
||||
ofn.nFileExtension = 0;
|
||||
ofn.lpstrDefExt = TEXT ("png");
|
||||
ofn.lCustData = 0;
|
||||
ofn.lpfnHook = NULL;
|
||||
ofn.lpTemplateName = NULL;
|
||||
}
|
||||
|
||||
BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
|
||||
{
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.lpstrFile = pstrFileName;
|
||||
ofn.lpstrFileTitle = pstrTitleName;
|
||||
ofn.Flags = OFN_HIDEREADONLY;
|
||||
|
||||
return GetOpenFileName (&ofn);
|
||||
}
|
||||
|
||||
BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
|
||||
{
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.lpstrFile = pstrFileName;
|
||||
ofn.lpstrFileTitle = pstrTitleName;
|
||||
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
||||
|
||||
return GetSaveFileName (&ofn);
|
||||
}
|
||||
|
||||
// PNG image handler functions
|
||||
|
||||
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor)
|
||||
{
|
||||
static FILE *pfFile;
|
||||
png_byte pbSig[8];
|
||||
int iBitDepth;
|
||||
int iColorType;
|
||||
double dGamma;
|
||||
png_color_16 *pBackground;
|
||||
png_uint_32 ulChannels;
|
||||
png_uint_32 ulRowBytes;
|
||||
png_byte *pbImageData = *ppbImageData;
|
||||
static png_byte **ppbRowPointers = NULL;
|
||||
int i;
|
||||
|
||||
// open the PNG input file
|
||||
|
||||
if (!pstrFileName)
|
||||
{
|
||||
*ppbImageData = pbImageData = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!(pfFile = fopen(pstrFileName, "rb")))
|
||||
{
|
||||
*ppbImageData = pbImageData = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// first check the eight byte PNG signature
|
||||
|
||||
fread(pbSig, 1, 8, pfFile);
|
||||
if (!png_check_sig(pbSig, 8))
|
||||
{
|
||||
*ppbImageData = pbImageData = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// create the two png(-info) structures
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
*ppbImageData = pbImageData = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||
*ppbImageData = pbImageData = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Try
|
||||
{
|
||||
|
||||
// initialize the png structure
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
png_init_io(png_ptr, pfFile);
|
||||
#else
|
||||
png_set_read_fn(png_ptr, (png_voidp)pfFile, png_read_data);
|
||||
#endif
|
||||
|
||||
png_set_sig_bytes(png_ptr, 8);
|
||||
|
||||
// read all PNG info up to image data
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
// get width, height, bit-depth and color-type
|
||||
|
||||
png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth,
|
||||
&iColorType, NULL, NULL, NULL);
|
||||
|
||||
// expand images of all color-type and bit-depth to 3x8 bit RGB images
|
||||
// let the library process things like alpha, transparency, background
|
||||
|
||||
if (iBitDepth == 16)
|
||||
png_set_strip_16(png_ptr);
|
||||
if (iColorType == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_expand(png_ptr);
|
||||
if (iBitDepth < 8)
|
||||
png_set_expand(png_ptr);
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||
png_set_expand(png_ptr);
|
||||
if (iColorType == PNG_COLOR_TYPE_GRAY ||
|
||||
iColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
// set the background color to draw transparent and alpha images over.
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
|
||||
{
|
||||
png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
pBkgColor->red = (byte) pBackground->red;
|
||||
pBkgColor->green = (byte) pBackground->green;
|
||||
pBkgColor->blue = (byte) pBackground->blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
pBkgColor = NULL;
|
||||
}
|
||||
|
||||
// if required set gamma conversion
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &dGamma))
|
||||
png_set_gamma(png_ptr, (double) 2.2, dGamma);
|
||||
|
||||
// after the transformations have been registered update info_ptr data
|
||||
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
// get again width, height and the new bit-depth and color-type
|
||||
|
||||
png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth,
|
||||
&iColorType, NULL, NULL, NULL);
|
||||
|
||||
|
||||
// row_bytes is the width x number of channels
|
||||
|
||||
ulRowBytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
ulChannels = png_get_channels(png_ptr, info_ptr);
|
||||
|
||||
*piChannels = ulChannels;
|
||||
|
||||
// now we can allocate memory to store the image
|
||||
|
||||
if (pbImageData)
|
||||
{
|
||||
free (pbImageData);
|
||||
pbImageData = NULL;
|
||||
}
|
||||
if ((pbImageData = (png_byte *) malloc(ulRowBytes * (*piHeight)
|
||||
* sizeof(png_byte))) == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Visual PNG: out of memory");
|
||||
}
|
||||
*ppbImageData = pbImageData;
|
||||
|
||||
// and allocate memory for an array of row-pointers
|
||||
|
||||
if ((ppbRowPointers = (png_bytepp) malloc((*piHeight)
|
||||
* sizeof(png_bytep))) == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Visual PNG: out of memory");
|
||||
}
|
||||
|
||||
// set the individual row-pointers to point at the correct offsets
|
||||
|
||||
for (i = 0; i < (*piHeight); i++)
|
||||
ppbRowPointers[i] = pbImageData + i * ulRowBytes;
|
||||
|
||||
// now we can go ahead and just read the whole image
|
||||
|
||||
png_read_image(png_ptr, ppbRowPointers);
|
||||
|
||||
// read the additional chunks in the PNG file (not really needed)
|
||||
|
||||
png_read_end(png_ptr, NULL);
|
||||
|
||||
// and we're done
|
||||
|
||||
free (ppbRowPointers);
|
||||
ppbRowPointers = NULL;
|
||||
|
||||
// yepp, done
|
||||
}
|
||||
|
||||
Catch (msg)
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
|
||||
*ppbImageData = pbImageData = NULL;
|
||||
|
||||
if(ppbRowPointers)
|
||||
free (ppbRowPointers);
|
||||
|
||||
fclose(pfFile);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fclose (pfFile);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
int iWidth, int iHeight, png_color bkgColor)
|
||||
{
|
||||
const int ciBitDepth = 8;
|
||||
const int ciChannels = 3;
|
||||
|
||||
static FILE *pfFile;
|
||||
png_uint_32 ulRowBytes;
|
||||
static png_byte **ppbRowPointers = NULL;
|
||||
int i;
|
||||
|
||||
// open the PNG output file
|
||||
|
||||
if (!pstrFileName)
|
||||
return FALSE;
|
||||
|
||||
if (!(pfFile = fopen(pstrFileName, "wb")))
|
||||
return FALSE;
|
||||
|
||||
// prepare the standard PNG structures
|
||||
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
fclose(pfFile);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr) {
|
||||
fclose(pfFile);
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Try
|
||||
{
|
||||
// initialize the png structure
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
png_init_io(png_ptr, pfFile);
|
||||
#else
|
||||
png_set_write_fn(png_ptr, (png_voidp)pfFile, png_write_data, png_flush);
|
||||
#endif
|
||||
|
||||
// we're going to write a very simple 3x8 bit RGB image
|
||||
|
||||
png_set_IHDR(png_ptr, info_ptr, iWidth, iHeight, ciBitDepth,
|
||||
PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
|
||||
PNG_FILTER_TYPE_BASE);
|
||||
|
||||
// write the file header information
|
||||
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
// swap the BGR pixels in the DiData structure to RGB
|
||||
|
||||
png_set_bgr(png_ptr);
|
||||
|
||||
// row_bytes is the width x number of channels
|
||||
|
||||
ulRowBytes = iWidth * ciChannels;
|
||||
|
||||
// we can allocate memory for an array of row-pointers
|
||||
|
||||
if ((ppbRowPointers = (png_bytepp) malloc(iHeight * sizeof(png_bytep))) == NULL)
|
||||
Throw "Visualpng: Out of memory";
|
||||
|
||||
// set the individual row-pointers to point at the correct offsets
|
||||
|
||||
for (i = 0; i < iHeight; i++)
|
||||
ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2);
|
||||
|
||||
// write out the entire image data in one call
|
||||
|
||||
png_write_image (png_ptr, ppbRowPointers);
|
||||
|
||||
// write the additional chunks to the PNG file (not really needed)
|
||||
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
|
||||
// and we're done
|
||||
|
||||
free (ppbRowPointers);
|
||||
ppbRowPointers = NULL;
|
||||
|
||||
// clean up after the write, and free any memory allocated
|
||||
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
// yepp, done
|
||||
}
|
||||
|
||||
Catch (msg)
|
||||
{
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
if(ppbRowPointers)
|
||||
free (ppbRowPointers);
|
||||
|
||||
fclose(pfFile);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fclose (pfFile);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef PNG_NO_STDIO
|
||||
|
||||
static void
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
check = (png_size_t)fread(data, (png_size_t)1, length,
|
||||
(FILE *)png_ptr->io_ptr);
|
||||
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
|
||||
check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr));
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
png_flush(png_structp png_ptr)
|
||||
{
|
||||
FILE *io_ptr;
|
||||
io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr));
|
||||
if (io_ptr != NULL)
|
||||
fflush(io_ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//-----------------
|
||||
// end of source
|
||||
//-----------------
|
||||
27
contrib/visupng/PngFile.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------
|
||||
// PNGFILE.H -- Header File for pngfile.c
|
||||
//------------------------------------------
|
||||
|
||||
// Copyright 2000, Willem van Schaik. For conditions of distribution and
|
||||
// use, see the copyright/license/disclaimer notice in png.h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
void PngFileInitialize (HWND hwnd) ;
|
||||
BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
|
||||
BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
|
||||
|
||||
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor);
|
||||
BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
int iWidth, int iHeight, png_color BkgColor);
|
||||
|
||||
#if defined(PNG_NO_STDIO)
|
||||
static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void png_flush(png_structp png_ptr);
|
||||
#endif
|
||||
|
||||
58
contrib/visupng/README.txt
Normal file
@@ -0,0 +1,58 @@
|
||||
Microsoft Developer Studio Build File, Format Version 6.00 for VisualPng
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Copyright 2000, Willem van Schaik. For conditions of distribution and
|
||||
use, see the copyright/license/disclaimer notice in png.h
|
||||
|
||||
As a PNG .dll demo VisualPng is finished. More features would only hinder
|
||||
the program's objective. However, further extensions (like support for other
|
||||
graphics formats) are in development. To get these, or for pre-compiled
|
||||
binaries, go to "http://www.schaik.com/png/visualpng.html".
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Assumes that
|
||||
|
||||
libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng
|
||||
zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib
|
||||
libpng header files are in ..\..\..\libpng
|
||||
zlib header files are in ..\..\..\zlib
|
||||
the pngsuite images are in ..\pngsuite
|
||||
|
||||
To build:
|
||||
|
||||
1) On the main menu Select "Build|Set Active configuration".
|
||||
Choose the configuration that corresponds to the library you want to test.
|
||||
This library must have been built using the libpng MS project located in
|
||||
the "..\..\mscv" subdirectory.
|
||||
|
||||
2) Select "Build|Clean"
|
||||
|
||||
3) Select "Build|Rebuild All"
|
||||
|
||||
4) After compiling and linking VisualPng will be started to view an image
|
||||
from the PngSuite directory. Press Ctrl-N (and Ctrl-V) for other images.
|
||||
|
||||
|
||||
To install:
|
||||
|
||||
When distributing VisualPng (or a further development) the following options
|
||||
are available:
|
||||
|
||||
1) Build the program with the configuration "Win32 LIB" and you only need to
|
||||
include the executable from the ./lib directory in your distribution.
|
||||
|
||||
2) Build the program with the configuration "Win32 DLL" and you need to put
|
||||
in your distribution the executable from the ./dll directory and the dll's
|
||||
libpng1.dll, zlib.dll and msvcrt.dll. These need to be in the user's PATH.
|
||||
|
||||
|
||||
Willem van Schaik
|
||||
Calgary, June 6th 2000
|
||||
|
||||
P.S. VisualPng was written based on preliminary work of:
|
||||
|
||||
- Simon-Pierre Cadieux
|
||||
- Glenn Randers-Pehrson
|
||||
- Greg Roelofs
|
||||
|
||||
961
contrib/visupng/VisualPng.c
Normal file
@@ -0,0 +1,961 @@
|
||||
//------------------------------------
|
||||
// VisualPng.C -- Shows a PNG image
|
||||
//------------------------------------
|
||||
|
||||
// Copyright 2000, Willem van Schaik. For conditions of distribution and
|
||||
// use, see the copyright/license/disclaimer notice in png.h
|
||||
|
||||
// switches
|
||||
|
||||
// defines
|
||||
|
||||
#define PROGNAME "VisualPng"
|
||||
#define LONGNAME "Win32 Viewer for PNG-files"
|
||||
#define VERSION "1.0 of 2000 June 07"
|
||||
|
||||
// constants
|
||||
|
||||
#define MARGIN 8
|
||||
|
||||
// standard includes
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
// application includes
|
||||
|
||||
#include "png.h"
|
||||
#include "pngfile.h"
|
||||
#include "resource.h"
|
||||
|
||||
// macros
|
||||
|
||||
// function prototypes
|
||||
|
||||
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
|
||||
BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ;
|
||||
|
||||
BOOL CenterAbout (HWND hwndChild, HWND hwndParent);
|
||||
|
||||
BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
int *pFileIndex);
|
||||
|
||||
BOOL SearchPngList (TCHAR *pFileList, int FileCount, int *pFileIndex,
|
||||
PTSTR pstrPrevName, PTSTR pstrNextName);
|
||||
|
||||
BOOL LoadImageFile(HWND hwnd, PTSTR pstrPathName,
|
||||
png_byte **ppbImage, int *pxImgSize, int *pyImgSize, int *piChannels,
|
||||
png_color *pBkgColor);
|
||||
|
||||
BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
|
||||
BYTE **ppDiData, int cxWinSize, int cyWinSize,
|
||||
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
|
||||
BOOL bStretched);
|
||||
|
||||
BOOL InitBitmap (
|
||||
BYTE *pDiData, int cxWinSize, int cyWinSize);
|
||||
|
||||
BOOL FillBitmap (
|
||||
BYTE *pDiData, int cxWinSize, int cyWinSize,
|
||||
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
|
||||
BOOL bStretched);
|
||||
|
||||
// a few global variables
|
||||
|
||||
static char *szProgName = PROGNAME;
|
||||
static char *szAppName = LONGNAME;
|
||||
static char *szIconName = PROGNAME;
|
||||
static char szCmdFileName [MAX_PATH];
|
||||
|
||||
// MAIN routine
|
||||
|
||||
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
PSTR szCmdLine, int iCmdShow)
|
||||
{
|
||||
HACCEL hAccel;
|
||||
HWND hwnd;
|
||||
MSG msg;
|
||||
WNDCLASS wndclass;
|
||||
int ixBorders, iyBorders;
|
||||
|
||||
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wndclass.lpfnWndProc = WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = hInstance;
|
||||
wndclass.hIcon = LoadIcon (hInstance, szIconName) ;
|
||||
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wndclass.hbrBackground = NULL; // (HBRUSH) GetStockObject (GRAY_BRUSH);
|
||||
wndclass.lpszMenuName = szProgName;
|
||||
wndclass.lpszClassName = szProgName;
|
||||
|
||||
if (!RegisterClass (&wndclass))
|
||||
{
|
||||
MessageBox (NULL, TEXT ("Error: this program requires Windows NT!"),
|
||||
szProgName, MB_ICONERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if filename given on commandline, store it
|
||||
if ((szCmdLine != NULL) && (*szCmdLine != '\0'))
|
||||
if (szCmdLine[0] == '"')
|
||||
strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2);
|
||||
else
|
||||
strcpy (szCmdFileName, szCmdLine);
|
||||
else
|
||||
strcpy (szCmdFileName, "");
|
||||
|
||||
// calculate size of window-borders
|
||||
ixBorders = 2 * (GetSystemMetrics (SM_CXBORDER) +
|
||||
GetSystemMetrics (SM_CXDLGFRAME));
|
||||
iyBorders = 2 * (GetSystemMetrics (SM_CYBORDER) +
|
||||
GetSystemMetrics (SM_CYDLGFRAME)) +
|
||||
GetSystemMetrics (SM_CYCAPTION) +
|
||||
GetSystemMetrics (SM_CYMENUSIZE) +
|
||||
1; /* WvS: don't ask me why? */
|
||||
|
||||
hwnd = CreateWindow (szProgName, szAppName,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
512 + 2 * MARGIN + ixBorders, 384 + 2 * MARGIN + iyBorders,
|
||||
// CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL, NULL, hInstance, NULL);
|
||||
|
||||
ShowWindow (hwnd, iCmdShow);
|
||||
UpdateWindow (hwnd);
|
||||
|
||||
hAccel = LoadAccelerators (hInstance, szProgName);
|
||||
|
||||
while (GetMessage (&msg, NULL, 0, 0))
|
||||
{
|
||||
if (!TranslateAccelerator (hwnd, hAccel, &msg))
|
||||
{
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
}
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
static HINSTANCE hInstance ;
|
||||
static HDC hdc;
|
||||
static PAINTSTRUCT ps;
|
||||
static HMENU hMenu;
|
||||
|
||||
static BITMAPFILEHEADER *pbmfh;
|
||||
static BITMAPINFOHEADER *pbmih;
|
||||
static BYTE *pbImage;
|
||||
static int cxWinSize, cyWinSize;
|
||||
static int cxImgSize, cyImgSize;
|
||||
static int cImgChannels;
|
||||
static png_color bkgColor = {127, 127, 127};
|
||||
|
||||
static BOOL bStretched = TRUE;
|
||||
|
||||
static BYTE *pDib = NULL;
|
||||
static BYTE *pDiData = NULL;
|
||||
|
||||
static TCHAR szImgPathName [MAX_PATH];
|
||||
static TCHAR szTitleName [MAX_PATH];
|
||||
|
||||
static TCHAR *pPngFileList = NULL;
|
||||
static int iPngFileCount;
|
||||
static int iPngFileIndex;
|
||||
|
||||
BOOL bOk;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
|
||||
PngFileInitialize (hwnd);
|
||||
|
||||
strcpy (szImgPathName, "");
|
||||
|
||||
// in case we process file given on command-line
|
||||
|
||||
if (szCmdFileName[0] != '\0')
|
||||
{
|
||||
strcpy (szImgPathName, szCmdFileName);
|
||||
|
||||
// read the other png-files in the directory for later
|
||||
// next/previous commands
|
||||
|
||||
BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount,
|
||||
&iPngFileIndex);
|
||||
|
||||
// load the image from file
|
||||
|
||||
if (!LoadImageFile (hwnd, szImgPathName,
|
||||
&pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
|
||||
return 0;
|
||||
|
||||
// invalidate the client area for later update
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case WM_SIZE:
|
||||
cxWinSize = LOWORD (lParam);
|
||||
cyWinSize = HIWORD (lParam);
|
||||
|
||||
// invalidate the client area for later update
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
|
||||
return 0;
|
||||
|
||||
case WM_INITMENUPOPUP:
|
||||
hMenu = GetMenu (hwnd);
|
||||
|
||||
if (pbImage)
|
||||
EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_GRAYED);
|
||||
|
||||
return 0;
|
||||
|
||||
case WM_COMMAND:
|
||||
hMenu = GetMenu (hwnd);
|
||||
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDM_FILE_OPEN:
|
||||
|
||||
// show the File Open dialog box
|
||||
|
||||
if (!PngFileOpenDlg (hwnd, szImgPathName, szTitleName))
|
||||
return 0;
|
||||
|
||||
// read the other png-files in the directory for later
|
||||
// next/previous commands
|
||||
|
||||
BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount,
|
||||
&iPngFileIndex);
|
||||
|
||||
// load the image from file
|
||||
|
||||
if (!LoadImageFile (hwnd, szImgPathName,
|
||||
&pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
|
||||
return 0;
|
||||
|
||||
// invalidate the client area for later update
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
|
||||
return 0;
|
||||
|
||||
case IDM_FILE_SAVE:
|
||||
|
||||
// show the File Save dialog box
|
||||
|
||||
if (!PngFileSaveDlg (hwnd, szImgPathName, szTitleName))
|
||||
return 0;
|
||||
|
||||
// save the PNG to a disk file
|
||||
|
||||
SetCursor (LoadCursor (NULL, IDC_WAIT));
|
||||
ShowCursor (TRUE);
|
||||
|
||||
bOk = PngSaveImage (szImgPathName, pDiData, cxWinSize, cyWinSize,
|
||||
bkgColor);
|
||||
|
||||
ShowCursor (FALSE);
|
||||
SetCursor (LoadCursor (NULL, IDC_ARROW));
|
||||
|
||||
if (!bOk)
|
||||
MessageBox (hwnd, TEXT ("Error in saving the PNG image"),
|
||||
szProgName, MB_ICONEXCLAMATION | MB_OK);
|
||||
return 0;
|
||||
|
||||
case IDM_FILE_NEXT:
|
||||
|
||||
// read next entry in the directory
|
||||
|
||||
if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex,
|
||||
NULL, szImgPathName))
|
||||
{
|
||||
if (strcmp (szImgPathName, "") == 0)
|
||||
return 0;
|
||||
|
||||
// load the image from file
|
||||
|
||||
if (!LoadImageFile (hwnd, szImgPathName, &pbImage,
|
||||
&cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
|
||||
return 0;
|
||||
|
||||
// invalidate the client area for later update
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case IDM_FILE_PREVIOUS:
|
||||
|
||||
// read previous entry in the directory
|
||||
|
||||
if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex,
|
||||
szImgPathName, NULL))
|
||||
{
|
||||
|
||||
if (strcmp (szImgPathName, "") == 0)
|
||||
return 0;
|
||||
|
||||
// load the image from file
|
||||
|
||||
if (!LoadImageFile (hwnd, szImgPathName, &pbImage, &cxImgSize,
|
||||
&cyImgSize, &cImgChannels, &bkgColor))
|
||||
return 0;
|
||||
|
||||
// invalidate the client area for later update
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case IDM_FILE_EXIT:
|
||||
|
||||
// more cleanup needed...
|
||||
|
||||
// free image buffer
|
||||
|
||||
if (pDib != NULL)
|
||||
{
|
||||
free (pDib);
|
||||
pDib = NULL;
|
||||
}
|
||||
|
||||
// free file-list
|
||||
|
||||
if (pPngFileList != NULL)
|
||||
{
|
||||
free (pPngFileList);
|
||||
pPngFileList = NULL;
|
||||
}
|
||||
|
||||
// let's go ...
|
||||
|
||||
exit (0);
|
||||
|
||||
return 0;
|
||||
|
||||
case IDM_OPTIONS_STRETCH:
|
||||
bStretched = !bStretched;
|
||||
if (bStretched)
|
||||
CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_CHECKED);
|
||||
else
|
||||
CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_UNCHECKED);
|
||||
|
||||
// invalidate the client area for later update
|
||||
|
||||
InvalidateRect (hwnd, NULL, TRUE);
|
||||
|
||||
// display the PNG into the DIBitmap
|
||||
|
||||
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
|
||||
|
||||
return 0;
|
||||
|
||||
case IDM_HELP_ABOUT:
|
||||
DialogBox (hInstance, TEXT ("AboutBox"), hwnd, AboutDlgProc) ;
|
||||
return 0;
|
||||
|
||||
} // end switch
|
||||
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint (hwnd, &ps);
|
||||
|
||||
if (pDib)
|
||||
SetDIBitsToDevice (hdc, 0, 0, cxWinSize, cyWinSize, 0, 0,
|
||||
0, cyWinSize, pDiData, (BITMAPINFO *) pDib, DIB_RGB_COLORS);
|
||||
|
||||
EndPaint (hwnd, &ps);
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (pbmfh)
|
||||
{
|
||||
free (pbmfh);
|
||||
pbmfh = NULL;
|
||||
}
|
||||
|
||||
PostQuitMessage (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc (hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
ShowWindow (hDlg, SW_HIDE);
|
||||
CenterAbout (hDlg, GetWindow (hDlg, GW_OWNER));
|
||||
ShowWindow (hDlg, SW_SHOW);
|
||||
return TRUE ;
|
||||
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDOK :
|
||||
case IDCANCEL :
|
||||
EndDialog (hDlg, 0) ;
|
||||
return TRUE ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//---------------
|
||||
// CenterAbout
|
||||
//---------------
|
||||
|
||||
BOOL CenterAbout (HWND hwndChild, HWND hwndParent)
|
||||
{
|
||||
RECT rChild, rParent, rWorkArea;
|
||||
int wChild, hChild, wParent, hParent;
|
||||
int xNew, yNew;
|
||||
BOOL bResult;
|
||||
|
||||
// Get the Height and Width of the child window
|
||||
GetWindowRect (hwndChild, &rChild);
|
||||
wChild = rChild.right - rChild.left;
|
||||
hChild = rChild.bottom - rChild.top;
|
||||
|
||||
// Get the Height and Width of the parent window
|
||||
GetWindowRect (hwndParent, &rParent);
|
||||
wParent = rParent.right - rParent.left;
|
||||
hParent = rParent.bottom - rParent.top;
|
||||
|
||||
// Get the limits of the 'workarea'
|
||||
bResult = SystemParametersInfo(
|
||||
SPI_GETWORKAREA, // system parameter to query or set
|
||||
sizeof(RECT),
|
||||
&rWorkArea,
|
||||
0);
|
||||
if (!bResult) {
|
||||
rWorkArea.left = rWorkArea.top = 0;
|
||||
rWorkArea.right = GetSystemMetrics(SM_CXSCREEN);
|
||||
rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||
}
|
||||
|
||||
// Calculate new X position, then adjust for workarea
|
||||
xNew = rParent.left + ((wParent - wChild) /2);
|
||||
if (xNew < rWorkArea.left) {
|
||||
xNew = rWorkArea.left;
|
||||
} else if ((xNew+wChild) > rWorkArea.right) {
|
||||
xNew = rWorkArea.right - wChild;
|
||||
}
|
||||
|
||||
// Calculate new Y position, then adjust for workarea
|
||||
yNew = rParent.top + ((hParent - hChild) /2);
|
||||
if (yNew < rWorkArea.top) {
|
||||
yNew = rWorkArea.top;
|
||||
} else if ((yNew+hChild) > rWorkArea.bottom) {
|
||||
yNew = rWorkArea.bottom - hChild;
|
||||
}
|
||||
|
||||
// Set it, and return
|
||||
return SetWindowPos (hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE |
|
||||
SWP_NOZORDER);
|
||||
}
|
||||
|
||||
//----------------
|
||||
// BuildPngList
|
||||
//----------------
|
||||
|
||||
BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
|
||||
int *pFileIndex)
|
||||
{
|
||||
static TCHAR szImgPathName [MAX_PATH];
|
||||
static TCHAR szImgFileName [MAX_PATH];
|
||||
static TCHAR szImgFindName [MAX_PATH];
|
||||
|
||||
WIN32_FIND_DATA finddata;
|
||||
HANDLE hFind;
|
||||
|
||||
static TCHAR szTmp [MAX_PATH];
|
||||
BOOL bOk;
|
||||
int i, ii;
|
||||
int j, jj;
|
||||
|
||||
// free previous file-list
|
||||
|
||||
if (*ppFileList != NULL)
|
||||
{
|
||||
free (*ppFileList);
|
||||
*ppFileList = NULL;
|
||||
}
|
||||
|
||||
// extract foldername, filename and search-name
|
||||
|
||||
strcpy (szImgPathName, pstrPathName);
|
||||
strcpy (szImgFileName, strrchr (pstrPathName, '\\') + 1);
|
||||
|
||||
strcpy (szImgFindName, szImgPathName);
|
||||
*(strrchr (szImgFindName, '\\') + 1) = '\0';
|
||||
strcat (szImgFindName, "*.png");
|
||||
|
||||
// first cycle: count number of files in directory for memory allocation
|
||||
|
||||
*pFileCount = 0;
|
||||
|
||||
hFind = FindFirstFile(szImgFindName, &finddata);
|
||||
bOk = (hFind != (HANDLE) -1);
|
||||
|
||||
while (bOk)
|
||||
{
|
||||
*pFileCount += 1;
|
||||
bOk = FindNextFile(hFind, &finddata);
|
||||
}
|
||||
FindClose(hFind);
|
||||
|
||||
// allocation memory for file-list
|
||||
|
||||
*ppFileList = (TCHAR *) malloc (*pFileCount * MAX_PATH);
|
||||
|
||||
// second cycle: read directory and store filenames in file-list
|
||||
|
||||
hFind = FindFirstFile(szImgFindName, &finddata);
|
||||
bOk = (hFind != (HANDLE) -1);
|
||||
|
||||
i = 0;
|
||||
ii = 0;
|
||||
while (bOk)
|
||||
{
|
||||
strcpy (*ppFileList + ii, szImgPathName);
|
||||
strcpy (strrchr(*ppFileList + ii, '\\') + 1, finddata.cFileName);
|
||||
|
||||
if (strcmp(pstrPathName, *ppFileList + ii) == 0)
|
||||
*pFileIndex = i;
|
||||
|
||||
ii += MAX_PATH;
|
||||
i++;
|
||||
|
||||
bOk = FindNextFile(hFind, &finddata);
|
||||
}
|
||||
FindClose(hFind);
|
||||
|
||||
// finally we must sort the file-list
|
||||
|
||||
for (i = 0; i < *pFileCount - 1; i++)
|
||||
{
|
||||
ii = i * MAX_PATH;
|
||||
for (j = i+1; j < *pFileCount; j++)
|
||||
{
|
||||
jj = j * MAX_PATH;
|
||||
if (strcmp (*ppFileList + ii, *ppFileList + jj) > 0)
|
||||
{
|
||||
strcpy (szTmp, *ppFileList + jj);
|
||||
strcpy (*ppFileList + jj, *ppFileList + ii);
|
||||
strcpy (*ppFileList + ii, szTmp);
|
||||
|
||||
// check if this was the current image that we moved
|
||||
|
||||
if (*pFileIndex == i)
|
||||
*pFileIndex = j;
|
||||
else
|
||||
if (*pFileIndex == j)
|
||||
*pFileIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//----------------
|
||||
// SearchPngList
|
||||
//----------------
|
||||
|
||||
BOOL SearchPngList (
|
||||
TCHAR *pFileList, int FileCount, int *pFileIndex,
|
||||
PTSTR pstrPrevName, PTSTR pstrNextName)
|
||||
{
|
||||
if (FileCount > 0)
|
||||
{
|
||||
// get previous entry
|
||||
|
||||
if (pstrPrevName != NULL)
|
||||
{
|
||||
if (*pFileIndex > 0)
|
||||
*pFileIndex -= 1;
|
||||
else
|
||||
*pFileIndex = FileCount - 1;
|
||||
|
||||
strcpy (pstrPrevName, pFileList + (*pFileIndex * MAX_PATH));
|
||||
}
|
||||
|
||||
// get next entry
|
||||
|
||||
if (pstrNextName != NULL)
|
||||
{
|
||||
if (*pFileIndex < FileCount - 1)
|
||||
*pFileIndex += 1;
|
||||
else
|
||||
*pFileIndex = 0;
|
||||
|
||||
strcpy (pstrNextName, pFileList + (*pFileIndex * MAX_PATH));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------
|
||||
// LoadImageFile
|
||||
//-----------------
|
||||
|
||||
BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName,
|
||||
png_byte **ppbImage, int *pxImgSize, int *pyImgSize,
|
||||
int *piChannels, png_color *pBkgColor)
|
||||
{
|
||||
static TCHAR szTmp [MAX_PATH];
|
||||
|
||||
// if there's an existing PNG, free the memory
|
||||
|
||||
if (*ppbImage)
|
||||
{
|
||||
free (*ppbImage);
|
||||
*ppbImage = NULL;
|
||||
}
|
||||
|
||||
// Load the entire PNG into memory
|
||||
|
||||
SetCursor (LoadCursor (NULL, IDC_WAIT));
|
||||
ShowCursor (TRUE);
|
||||
|
||||
PngLoadImage (pstrPathName, ppbImage, pxImgSize, pyImgSize, piChannels,
|
||||
pBkgColor);
|
||||
|
||||
ShowCursor (FALSE);
|
||||
SetCursor (LoadCursor (NULL, IDC_ARROW));
|
||||
|
||||
if (*ppbImage != NULL)
|
||||
{
|
||||
sprintf (szTmp, "VisualPng - %s", strrchr(pstrPathName, '\\') + 1);
|
||||
SetWindowText (hwnd, szTmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox (hwnd, TEXT ("Error in loading the PNG image"),
|
||||
szProgName, MB_ICONEXCLAMATION | MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//----------------
|
||||
// DisplayImage
|
||||
//----------------
|
||||
|
||||
BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
|
||||
BYTE **ppDiData, int cxWinSize, int cyWinSize,
|
||||
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
|
||||
BOOL bStretched)
|
||||
{
|
||||
BYTE *pDib = *ppDib;
|
||||
BYTE *pDiData = *ppDiData;
|
||||
// BITMAPFILEHEADER *pbmfh;
|
||||
BITMAPINFOHEADER *pbmih;
|
||||
WORD wDIRowBytes;
|
||||
png_color bkgBlack = {0, 0, 0};
|
||||
png_color bkgGray = {127, 127, 127};
|
||||
png_color bkgWhite = {255, 255, 255};
|
||||
|
||||
// allocate memory for the Device Independant bitmap
|
||||
|
||||
wDIRowBytes = (WORD) ((3 * cxWinSize + 3L) >> 2) << 2;
|
||||
|
||||
if (pDib)
|
||||
{
|
||||
free (pDib);
|
||||
pDib = NULL;
|
||||
}
|
||||
|
||||
if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) +
|
||||
wDIRowBytes * cyWinSize)))
|
||||
{
|
||||
MessageBox (hwnd, TEXT ("Error in displaying the PNG image"),
|
||||
szProgName, MB_ICONEXCLAMATION | MB_OK);
|
||||
*ppDib = pDib = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
*ppDib = pDib;
|
||||
memset (pDib, 0, sizeof(BITMAPINFOHEADER));
|
||||
|
||||
// initialize the dib-structure
|
||||
|
||||
pbmih = (BITMAPINFOHEADER *) pDib;
|
||||
pbmih->biSize = sizeof(BITMAPINFOHEADER);
|
||||
pbmih->biWidth = cxWinSize;
|
||||
pbmih->biHeight = -((long) cyWinSize);
|
||||
pbmih->biPlanes = 1;
|
||||
pbmih->biBitCount = 24;
|
||||
pbmih->biCompression = 0;
|
||||
pDiData = pDib + sizeof(BITMAPINFOHEADER);
|
||||
*ppDiData = pDiData;
|
||||
|
||||
// first fill bitmap with gray and image border
|
||||
|
||||
InitBitmap (pDiData, cxWinSize, cyWinSize);
|
||||
|
||||
// then fill bitmap with image
|
||||
|
||||
if (pbImage)
|
||||
{
|
||||
FillBitmap (
|
||||
pDiData, cxWinSize, cyWinSize,
|
||||
pbImage, cxImgSize, cyImgSize, cImgChannels,
|
||||
bStretched);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//--------------
|
||||
// InitBitmap
|
||||
//--------------
|
||||
|
||||
BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize)
|
||||
{
|
||||
BYTE *dst;
|
||||
int x, y, col;
|
||||
|
||||
// initialize the background with gray
|
||||
|
||||
dst = pDiData;
|
||||
for (y = 0; y < cyWinSize; y++)
|
||||
{
|
||||
col = 0;
|
||||
for (x = 0; x < cxWinSize; x++)
|
||||
{
|
||||
// fill with GRAY
|
||||
*dst++ = 127;
|
||||
*dst++ = 127;
|
||||
*dst++ = 127;
|
||||
col += 3;
|
||||
}
|
||||
// rows start on 4 byte boundaries
|
||||
while ((col % 4) != 0)
|
||||
{
|
||||
dst++;
|
||||
col++;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//--------------
|
||||
// FillBitmap
|
||||
//--------------
|
||||
|
||||
BOOL FillBitmap (
|
||||
BYTE *pDiData, int cxWinSize, int cyWinSize,
|
||||
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
|
||||
BOOL bStretched)
|
||||
{
|
||||
BYTE *pStretchedImage;
|
||||
BYTE *pImg;
|
||||
BYTE *src, *dst;
|
||||
BYTE r, g, b, a;
|
||||
const int cDIChannels = 3;
|
||||
WORD wImgRowBytes;
|
||||
WORD wDIRowBytes;
|
||||
int cxNewSize, cyNewSize;
|
||||
int cxImgPos, cyImgPos;
|
||||
int xImg, yImg;
|
||||
int xWin, yWin;
|
||||
int xOld, yOld;
|
||||
int xNew, yNew;
|
||||
|
||||
if (bStretched)
|
||||
{
|
||||
cxNewSize = cxWinSize - 2 * MARGIN;
|
||||
cyNewSize = cyWinSize - 2 * MARGIN;
|
||||
|
||||
// stretch the image to it's window determined size
|
||||
|
||||
// the following two are the same, but the first has side-effects
|
||||
// because of rounding
|
||||
// if ((cyNewSize / cxNewSize) > (cyImgSize / cxImgSize))
|
||||
if ((cyNewSize * cxImgSize) > (cyImgSize * cxNewSize))
|
||||
{
|
||||
cyNewSize = cxNewSize * cyImgSize / cxImgSize;
|
||||
cxImgPos = MARGIN;
|
||||
cyImgPos = (cyWinSize - cyNewSize) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
cxNewSize = cyNewSize * cxImgSize / cyImgSize;
|
||||
cyImgPos = MARGIN;
|
||||
cxImgPos = (cxWinSize - cxNewSize) / 2;
|
||||
}
|
||||
|
||||
pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize);
|
||||
pImg = pStretchedImage;
|
||||
|
||||
for (yNew = 0; yNew < cyNewSize; yNew++)
|
||||
{
|
||||
yOld = yNew * cyImgSize / cyNewSize;
|
||||
for (xNew = 0; xNew < cxNewSize; xNew++)
|
||||
{
|
||||
xOld = xNew * cxImgSize / cxNewSize;
|
||||
|
||||
r = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 0);
|
||||
g = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 1);
|
||||
b = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 2);
|
||||
*pImg++ = r;
|
||||
*pImg++ = g;
|
||||
*pImg++ = b;
|
||||
if (cImgChannels == 4)
|
||||
{
|
||||
a = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld)
|
||||
+ 3);
|
||||
*pImg++ = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calculate row-bytes
|
||||
|
||||
wImgRowBytes = cImgChannels * cxNewSize;
|
||||
wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2;
|
||||
|
||||
// copy image to screen
|
||||
|
||||
for (yImg = 0, yWin = cyImgPos; yImg < cyNewSize; yImg++, yWin++)
|
||||
{
|
||||
if (yWin >= cyWinSize - cyImgPos)
|
||||
break;
|
||||
src = pStretchedImage + yImg * wImgRowBytes;
|
||||
dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels;
|
||||
|
||||
for (xImg = 0, xWin = cxImgPos; xImg < cxNewSize; xImg++, xWin++)
|
||||
{
|
||||
if (xWin >= cxWinSize - cxImgPos)
|
||||
break;
|
||||
r = *src++;
|
||||
g = *src++;
|
||||
b = *src++;
|
||||
*dst++ = b; /* note the reverse order */
|
||||
*dst++ = g;
|
||||
*dst++ = r;
|
||||
if (cImgChannels == 4)
|
||||
{
|
||||
a = *src++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// free memory
|
||||
|
||||
if (pStretchedImage != NULL)
|
||||
{
|
||||
free (pStretchedImage);
|
||||
pStretchedImage = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// process the image not-stretched
|
||||
|
||||
else
|
||||
{
|
||||
// calculate the central position
|
||||
|
||||
cxImgPos = (cxWinSize - cxImgSize) / 2;
|
||||
cyImgPos = (cyWinSize - cyImgSize) / 2;
|
||||
|
||||
// check for image larger than window
|
||||
|
||||
if (cxImgPos < MARGIN)
|
||||
cxImgPos = MARGIN;
|
||||
if (cyImgPos < MARGIN)
|
||||
cyImgPos = MARGIN;
|
||||
|
||||
// calculate both row-bytes
|
||||
|
||||
wImgRowBytes = cImgChannels * cxImgSize;
|
||||
wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2;
|
||||
|
||||
// copy image to screen
|
||||
|
||||
for (yImg = 0, yWin = cyImgPos; yImg < cyImgSize; yImg++, yWin++)
|
||||
{
|
||||
if (yWin >= cyWinSize - MARGIN)
|
||||
break;
|
||||
src = pbImage + yImg * wImgRowBytes;
|
||||
dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels;
|
||||
|
||||
for (xImg = 0, xWin = cxImgPos; xImg < cxImgSize; xImg++, xWin++)
|
||||
{
|
||||
if (xWin >= cxWinSize - MARGIN)
|
||||
break;
|
||||
r = *src++;
|
||||
g = *src++;
|
||||
b = *src++;
|
||||
*dst++ = b; /* note the reverse order */
|
||||
*dst++ = g;
|
||||
*dst++ = r;
|
||||
if (cImgChannels == 4)
|
||||
{
|
||||
a = *src++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------
|
||||
// end of source
|
||||
//-----------------
|
||||
223
contrib/visupng/VisualPng.dsp
Normal file
@@ -0,0 +1,223 @@
|
||||
# Microsoft Developer Studio Project File - Name="VisualPng" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
|
||||
# Copyright 2000, Willem van Schaik. For conditions of distribution and
|
||||
# use, see the copyright/license/disclaimer notice in png.h
|
||||
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=VisualPng - Win32 Debug LIB
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "VisualPng.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "VisualPng.mak" CFG="VisualPng - Win32 Debug LIB"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "VisualPng - Win32 DLL" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "VisualPng - Win32 Debug DLL" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "VisualPng - Win32 LIB" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "VisualPng - Win32 Debug LIB" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "VisualPng - Win32 DLL"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "VisualPng___Win32_DLL"
|
||||
# PROP BASE Intermediate_Dir "VisualPng___Win32_DLL"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "dll"
|
||||
# PROP Intermediate_Dir "dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /I "libpng" /I "zlib" /D "PNG_USE_DLL" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 libpng2.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"libpng" /libpath:"zlib"
|
||||
# ADD LINK32 libpng2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\dll
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll;..\..\projects\msvc\win32\zlib\dll; $(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "VisualPng - Win32 Debug DLL"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "VisualPng___Win32_Debug_DLL"
|
||||
# PROP BASE Intermediate_Dir "VisualPng___Win32_Debug_DLL"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "dll_dbg"
|
||||
# PROP Intermediate_Dir "dll_dbg"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "libpng" /I "zlib" /D "PNG_USE_DLL" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 libpng2.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"libpng" /libpath:"zlib"
|
||||
# SUBTRACT BASE LINK32 /nodefaultlib
|
||||
# ADD LINK32 libpng2d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\dll_dbg
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbg;..\..\projects\msvc\win32\zlib\dll_dbg; $(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "VisualPng - Win32 LIB"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "VisualPng___Win32_LIB"
|
||||
# PROP BASE Intermediate_Dir "VisualPng___Win32_LIB"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "lib"
|
||||
# PROP Intermediate_Dir "lib"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
|
||||
# SUBTRACT BASE CPP /YX
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 libpng2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
|
||||
# ADD LINK32 libpng.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\lib"
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\lib
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "VisualPng - Win32 Debug LIB"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "VisualPng___Win32_Debug_LIB"
|
||||
# PROP BASE Intermediate_Dir "VisualPng___Win32_Debug_LIB"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "lib_dbg"
|
||||
# PROP Intermediate_Dir "lib_dbg"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 libpng2d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
|
||||
# SUBTRACT BASE LINK32 /nodefaultlib
|
||||
# ADD LINK32 libpng.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\lib_dbg"
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
# Begin Special Build Tool
|
||||
OutDir=.\lib_dbg
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "VisualPng - Win32 DLL"
|
||||
# Name "VisualPng - Win32 Debug DLL"
|
||||
# Name "VisualPng - Win32 LIB"
|
||||
# Name "VisualPng - Win32 Debug LIB"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PngFile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\VisualPng.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cexcept.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PngFile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\VisualPng.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\VisualPng.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
contrib/visupng/VisualPng.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "VisualPng"=.\VisualPng.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
contrib/visupng/VisualPng.ico
Normal file
|
After Width: | Height: | Size: 766 B |
BIN
contrib/visupng/VisualPng.png
Normal file
|
After Width: | Height: | Size: 208 B |
152
contrib/visupng/VisualPng.rc
Normal file
@@ -0,0 +1,152 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
VISUALPNG MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Open Image...\tCtrl+O", IDM_FILE_OPEN
|
||||
MENUITEM "Save &As...", IDM_FILE_SAVE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Next Image\tCtrl+N", IDM_FILE_NEXT
|
||||
MENUITEM "Pre&vious Image\tCtrl+V", IDM_FILE_PREVIOUS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit\tAlt+X", IDM_FILE_EXIT
|
||||
END
|
||||
POPUP "&Options"
|
||||
BEGIN
|
||||
MENUITEM "&Stretch", IDM_OPTIONS_STRETCH, CHECKED
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About", IDM_HELP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
VISUALPNG ACCELERATORS DISCARDABLE
|
||||
BEGIN
|
||||
"N", IDM_FILE_NEXT, VIRTKEY, CONTROL, NOINVERT
|
||||
"O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
|
||||
"P", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT
|
||||
"V", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT
|
||||
"X", IDM_FILE_EXIT, VIRTKEY, ALT, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
VISUALPNG ICON DISCARDABLE "VisualPng.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
ABOUTBOX DIALOG DISCARDABLE 0, 0, 186, 94
|
||||
STYLE DS_MODALFRAME | WS_POPUP
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,68,67,50,14
|
||||
CTEXT "VisualPng 1.0 - June 2000",IDC_STATIC,49,14,88,8
|
||||
LTEXT "a PNG image viewer",IDC_STATIC,60,30,66,8
|
||||
LTEXT "(c) Willem van Schaik, 2000",IDC_STATIC,48,52,90,8
|
||||
LTEXT "to demonstrate the use of libpng in Visual C",
|
||||
IDC_STATIC,25,38,136,8
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
"ABOUTBOX", DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 87
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
244
contrib/visupng/cexcept.h
Normal file
@@ -0,0 +1,244 @@
|
||||
/*===
|
||||
cexcept.h 1.0.0 (2000-Jun-21-Wed)
|
||||
Adam M. Costello <amc@cs.berkeley.edu>
|
||||
|
||||
An interface for exception-handling in ANSI C, developed jointly with
|
||||
Cosmin Truta <cosmin@cs.toronto.edu>.
|
||||
|
||||
Copyright (c) 2000 Adam M. Costello and Cosmin Truta. Everyone
|
||||
is hereby granted permission to do whatever they like with this
|
||||
file, provided that if they modify it they take reasonable steps to
|
||||
avoid confusing or misleading people about the authors, version,
|
||||
and terms of use of the derived file. The copyright holders make
|
||||
no guarantees about the correctness of this file, and are not
|
||||
responsible for any damage resulting from its use.
|
||||
|
||||
If this interface is used by multiple .c files, they shouldn't include
|
||||
this header file directly. Instead, create a wrapper header file that
|
||||
includes this header file and then invokes the define_exception_type
|
||||
macro (see below), and let your .c files include that header file.
|
||||
|
||||
The interface consists of one type, one well-known name, and six macros.
|
||||
|
||||
|
||||
define_exception_type(type_name);
|
||||
|
||||
This macro is used like an external declaration. It specifies
|
||||
the type of object that gets copied from the exception thrower to
|
||||
the exception catcher. The type_name can be any type that can be
|
||||
assigned to, that is, a non-constant arithmetic type, struct, union,
|
||||
or pointer. Examples:
|
||||
|
||||
define_exception_type(int);
|
||||
|
||||
enum exception { out_of_memory, bad_arguments, disk_full };
|
||||
define_exception_type(enum exception);
|
||||
|
||||
struct exception { int code; const char *msg; };
|
||||
define_exception_type(struct exception);
|
||||
|
||||
|
||||
struct exception_context;
|
||||
|
||||
This type may be used after the define_exception_type() macro has
|
||||
been invoked. A struct exception_context must be known to both
|
||||
the thrower and the catcher. It is expected that there be one
|
||||
context for each thread that uses exceptions. It would certainly
|
||||
be dangerous for multiple threads to access the same context.
|
||||
One thread can use multiple contexts, but that is likely to be
|
||||
confusing and not typically useful. The application can allocate
|
||||
this structure in any way it pleases--automatic, static, or dynamic.
|
||||
The application programmer should pretend not to know the structure
|
||||
members, which are subject to change.
|
||||
|
||||
|
||||
struct exception_context *the_exception_context;
|
||||
|
||||
The Try/Catch and Throw statements (described below) implicitly
|
||||
refer to a context, using the name the_exception_context. It is
|
||||
the application's responsibility to make sure that this name yields
|
||||
the address of a mutable (non-constant) struct exception_context
|
||||
wherever those statements are used. Subject to that constraint, the
|
||||
application may declare a variable of this name anywhere it likes
|
||||
(inside a function, in a parameter list, or externally), and may
|
||||
use whatever storage class specifiers (static, extern, etc) or type
|
||||
qualifiers (const, volatile) it likes. Examples:
|
||||
|
||||
static struct exception_context
|
||||
* const the_exception_context = &foo;
|
||||
|
||||
{ struct exception_context *the_exception_context = bar; ... }
|
||||
|
||||
int blah(struct exception_context *the_exception_context, ...);
|
||||
|
||||
extern struct exception_context the_exception_context[1];
|
||||
|
||||
The last example illustrates a trick that avoids creating a pointer
|
||||
object separate from the structure object.
|
||||
|
||||
The name could even be a macro, for example:
|
||||
|
||||
struct exception_context ec_array[numthreads];
|
||||
#define the_exception_context (ec_array + thread_id)
|
||||
|
||||
Be aware that the_exception_context is used several times by the
|
||||
Try/Catch/Throw macros, so it shouldn't be expensive or have side
|
||||
effects. The expansion must be a drop-in replacement for an
|
||||
identifier, so it's safest to put parentheses around it.
|
||||
|
||||
|
||||
void init_exception_context(struct exception_context *ec);
|
||||
|
||||
For context structures allocated statically (by an external
|
||||
definition or using the "static" keyword), the implicit
|
||||
initialization to all zeros is sufficient, but contexts allocated
|
||||
by other means must be initialized using this macro before they
|
||||
are used by a Try/Catch statement. It does no harm to initialize
|
||||
a context more than once (by using this macro on a statically
|
||||
allocated context, or using this macro twice on the same context),
|
||||
but a context must not be re-initialized after it has been used by a
|
||||
Try/Catch statement.
|
||||
|
||||
|
||||
Try statement
|
||||
Catch (expression) statement
|
||||
|
||||
The Try/Catch/Throw macros are capitalized in order to avoid
|
||||
confusion with the C++ keywords, which have subtly different
|
||||
semantics.
|
||||
|
||||
A Try/Catch statement has a syntax similar to an if/else
|
||||
statement, except that the parenthesized expression goes after
|
||||
the second keyword rather than the first. As with if/else,
|
||||
there are two clauses, each of which may be a simple statement
|
||||
ending with a semicolon or a brace-enclosed compound statement.
|
||||
But whereas the else clause is optional, the Catch clause is
|
||||
required. The expression must be a modifiable lvalue (something
|
||||
capable of being assigned to) of the exact same type passed to
|
||||
define_exception_type().
|
||||
|
||||
If a Throw that uses the same exception context as the Try/Catch is
|
||||
executed within the Try clause (typically within a function called
|
||||
by the Try clause), and the exception is not caught by a nested
|
||||
Try/Catch statement, then a copy of the exception will be assigned
|
||||
to the expression, and control will jump to the Catch clause. If no
|
||||
such Throw is executed, then the assignment is not performed, and
|
||||
the Catch clause is not executed.
|
||||
|
||||
Regardless of whether an exception is caught, the expression is
|
||||
always evaluated exactly once, which is significant if it has side
|
||||
effects, for example:
|
||||
|
||||
Try foo();
|
||||
Catch (p[++i].e) { ... }
|
||||
|
||||
IMPORTANT: Jumping into or out of a Try clause (for example via
|
||||
return, break, continue, goto, longjmp) is forbidden--the compiler
|
||||
will not complain, but bad things will happen at run-time. Jumping
|
||||
into or out of a Catch clause is okay, and so is jumping around
|
||||
inside a Try clause. In many cases where one is tempted to return
|
||||
from a Try clause, it will suffice to use Throw, and then return
|
||||
from the Catch clause. Another option is to set a flag variable and
|
||||
use goto to jump to the end of the Try clause, then check the flag
|
||||
after the Try/Catch statement.
|
||||
|
||||
IMPORTANT: The values of any non-volatile automatic variables
|
||||
changed within the Try clause are undefined after an exception is
|
||||
caught. Therefore, variables modified inside the Try block whose
|
||||
values are needed later outside the Try block must either use static
|
||||
storage or be declared with the "volatile" type qualifier.
|
||||
|
||||
|
||||
Throw expression;
|
||||
|
||||
A Throw statement is very much like a return statement, except that
|
||||
the expression is required. Whereas return jumps back to the place
|
||||
where the current function was called, Throw jumps back to the Catch
|
||||
clause of the innermost enclosing Try clause. The expression must
|
||||
be compatible with the type passed to define_exception_type(). The
|
||||
exception must be caught, otherwise the program may crash.
|
||||
|
||||
Slight limitation: If the expression is a comma-expression it must
|
||||
be enclosed in parentheses.
|
||||
|
||||
|
||||
Try statement
|
||||
Catch_anonymous statement
|
||||
|
||||
When the value of the exception is not needed, a Try/Catch statement
|
||||
can use Catch_anonymous instead of Catch (expression).
|
||||
|
||||
|
||||
Everything below this point is for the benefit of the compiler. The
|
||||
application programmer should pretend not to know any of it, because it
|
||||
is subject to change.
|
||||
|
||||
===*/
|
||||
|
||||
|
||||
#ifndef CEXCEPT_H
|
||||
#define CEXCEPT_H
|
||||
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define define_exception_type(etype) \
|
||||
struct exception__state { \
|
||||
etype *exception; \
|
||||
jmp_buf env; \
|
||||
}
|
||||
|
||||
struct exception_context { \
|
||||
struct exception__state *last; \
|
||||
int caught; \
|
||||
};
|
||||
|
||||
#define init_exception_context(ec) ((void)((ec)->last = 0))
|
||||
|
||||
#define Catch(e) exception__catch(&(e))
|
||||
#define Catch_anonymous exception__catch(0)
|
||||
|
||||
#define Try \
|
||||
{ \
|
||||
struct exception__state *exception__p, exception__s; \
|
||||
int exception__i; \
|
||||
exception__p = the_exception_context->last; \
|
||||
the_exception_context->last = &exception__s; \
|
||||
for (exception__i = 0; ; exception__i = 1) \
|
||||
if (exception__i) { \
|
||||
if (setjmp(exception__s.env) == 0) { \
|
||||
if (&exception__s)
|
||||
|
||||
#define exception__catch(e_addr) \
|
||||
else { } \
|
||||
the_exception_context->caught = 0; \
|
||||
} \
|
||||
else the_exception_context->caught = 1; \
|
||||
the_exception_context->last = exception__p; \
|
||||
break; \
|
||||
} \
|
||||
else exception__s.exception = e_addr; \
|
||||
} \
|
||||
if (!the_exception_context->caught) { } \
|
||||
else
|
||||
|
||||
/* Try ends with if(), and Catch begins and ends with else. This */
|
||||
/* ensures that the Try/Catch syntax is really the same as the */
|
||||
/* if/else syntax. */
|
||||
/* */
|
||||
/* We use &exception__s instead of 1 to appease compilers that */
|
||||
/* warn about constant expressions inside if(). Most compilers */
|
||||
/* should still recognize that &exception__s is never zero and avoid */
|
||||
/* generating test code. */
|
||||
/* */
|
||||
/* We use the variable exception__i to start the loop at the bottom, */
|
||||
/* rather than jump into the loop using a switch statement, to */
|
||||
/* appease compilers that warn about jumping into loops. */
|
||||
|
||||
#define Throw \
|
||||
for (;; longjmp(the_exception_context->last->env, 1)) \
|
||||
if (the_exception_context->last->exception) \
|
||||
*the_exception_context->last->exception =
|
||||
|
||||
|
||||
#endif /* CEXCEPT_H */
|
||||
23
contrib/visupng/resource.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by VisualPng.rc
|
||||
//
|
||||
#define IDM_FILE_OPEN 40001
|
||||
#define IDM_FILE_SAVE 40002
|
||||
#define IDM_FILE_NEXT 40003
|
||||
#define IDM_FILE_PREVIOUS 40004
|
||||
#define IDM_FILE_EXIT 40005
|
||||
#define IDM_OPTIONS_BACKGROUND 40006
|
||||
#define IDM_OPTIONS_STRETCH 40007
|
||||
#define IDM_HELP_ABOUT 40008
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 113
|
||||
#define _APS_NEXT_COMMAND_VALUE 40009
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
156
example.c
@@ -6,17 +6,28 @@
|
||||
/* This is an example of how to use libpng to read and write PNG files.
|
||||
* The file libpng.txt is much more verbose then this. If you have not
|
||||
* read it, do so first. This was designed to be a starting point of an
|
||||
* implementation. This is not officially part of libpng, and therefore
|
||||
* does not require a copyright notice.
|
||||
* implementation. This is not officially part of libpng, is hereby placed
|
||||
* in the public domain, and therefore does not require a copyright notice.
|
||||
*
|
||||
* This file does not currently compile, because it is missing certain
|
||||
* parts, like allocating memory to hold an image. You will have to
|
||||
* supply these parts to get it to compile. For an example of a minimal
|
||||
* working PNG reader/writer, see pngtest.c, included in this distribution.
|
||||
* working PNG reader/writer, see pngtest.c, included in this distribution;
|
||||
* see also the programs in the contrib directory.
|
||||
*/
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* The png_jmpbuf() macro, used in error handling, became available in
|
||||
* libpng version 1.0.6. If you want to be able to run your code with older
|
||||
* versions of libpng, you must define the macro yourself (but only if it
|
||||
* is not already defined by libpng!).
|
||||
*/
|
||||
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#endif
|
||||
|
||||
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
|
||||
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
|
||||
*
|
||||
@@ -43,7 +54,7 @@ int check_if_png(char *file_name, FILE **fp)
|
||||
char buf[PNG_BYTES_TO_CHECK];
|
||||
|
||||
/* Open the prospective PNG file. */
|
||||
if ((*fp = fopen(file_name, "rb")) != NULL);
|
||||
if ((*fp = fopen(file_name, "rb")) == NULL)
|
||||
return 0;
|
||||
|
||||
/* Read in some of the signature bytes */
|
||||
@@ -73,7 +84,7 @@ void read_png(char *file_name) /* We need to open the file */
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(file_name, "rb")) == NULL)
|
||||
return;
|
||||
return (ERROR);
|
||||
#else no_open_file /* prototype 2 */
|
||||
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
{
|
||||
@@ -95,7 +106,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
if (png_ptr == NULL)
|
||||
{
|
||||
fclose(fp);
|
||||
return;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* Allocate/initialize the memory for image information. REQUIRED. */
|
||||
@@ -104,20 +115,21 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
{
|
||||
fclose(fp);
|
||||
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
|
||||
return;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* Set error handling if you are using the setjmp/longjmp method (this is
|
||||
* the normal method of doing things with libpng). REQUIRED unless you
|
||||
* set up your own error handlers in the png_create_read_struct() earlier.
|
||||
*/
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
/* Free all of the memory associated with the png_ptr and info_ptr */
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
fclose(fp);
|
||||
/* If we get here, we had a problem reading the file */
|
||||
return;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* One of the following I/O initialization methods is REQUIRED */
|
||||
@@ -136,6 +148,19 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
/* If we have already read some of the signature */
|
||||
png_set_sig_bytes(png_ptr, sig_read);
|
||||
|
||||
#ifdef hilevel
|
||||
/*
|
||||
* If you have enough memory to read in the entire image at once,
|
||||
* and you need to specify only transforms that can be controlled
|
||||
* with one of the PNG_TRANSFORM_* bits (this presently excludes
|
||||
* dithering, filling, setting background, and doing gamma
|
||||
* adjustment), then you can read the entire image (including
|
||||
* pixels) into the info structure with this call:
|
||||
*/
|
||||
png_read_png(png_ptr, info_ptr, png_transforms, NULL);
|
||||
#else
|
||||
/* OK, you're doing it the hard way, with the lower-level functions */
|
||||
|
||||
/* The call to png_read_info() gives us all of the information from the
|
||||
* PNG file before the first IDAT (image data chunk). REQUIRED
|
||||
*/
|
||||
@@ -218,7 +243,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||
}
|
||||
|
||||
/* Tell libpng to handle the gamma conversion for you. The second call
|
||||
/* Tell libpng to handle the gamma conversion for you. The final call
|
||||
* is a good guess for PC generated images, but it should be configurable
|
||||
* by the user at run time by the user. It is strongly suggested that
|
||||
* your application support gamma correction.
|
||||
@@ -227,7 +252,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
int intent;
|
||||
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &intent))
|
||||
png_set_sRGB(png_ptr, info_ptr, intent);
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||
else
|
||||
{
|
||||
double image_gamma;
|
||||
@@ -242,7 +267,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
*/
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
png_uint_32 num_palette;
|
||||
int num_palette;
|
||||
png_colorp palette;
|
||||
|
||||
/* This reduces the image to the application supplied palette */
|
||||
@@ -257,7 +282,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
/* This reduces the image to the palette supplied in the file */
|
||||
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
|
||||
{
|
||||
png_color16p histogram;
|
||||
png_uint_16p histogram;
|
||||
|
||||
png_get_hIST(png_ptr, info_ptr, &histogram);
|
||||
|
||||
@@ -266,7 +291,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
}
|
||||
}
|
||||
|
||||
/* invert monocrome files to have 0 as white and 1 as black */
|
||||
/* invert monochrome files to have 0 as white and 1 as black */
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
/* If you want to shift the pixel values from the range [0,255] or
|
||||
@@ -275,14 +300,15 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
*/
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
|
||||
{
|
||||
png_color8p sig_bit;
|
||||
png_color_8p sig_bit;
|
||||
|
||||
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
|
||||
png_set_shift(png_ptr, sig_bit);
|
||||
}
|
||||
|
||||
/* flip the RGB pixels to BGR (or RGBA to BGRA) */
|
||||
png_set_bgr(png_ptr);
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
png_set_bgr(png_ptr);
|
||||
|
||||
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
||||
png_set_swap_alpha(png_ptr);
|
||||
@@ -312,7 +338,8 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
row_pointers[row] = malloc(png_get_rowbytes(png_ptr, info_ptr));
|
||||
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 */
|
||||
@@ -350,6 +377,9 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
|
||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
#endif hilevel
|
||||
|
||||
/* At this point you have read the entire image */
|
||||
|
||||
/* clean up after the read, and free any memory allocated - REQUIRED */
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
@@ -358,7 +388,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
fclose(fp);
|
||||
|
||||
/* that's it */
|
||||
return;
|
||||
return (OK);
|
||||
}
|
||||
|
||||
/* progressively read a file */
|
||||
@@ -378,7 +408,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
if (*png_ptr == NULL)
|
||||
{
|
||||
*info_ptr = NULL;
|
||||
return ERROR;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
*info_ptr = png_create_info_struct(png_ptr);
|
||||
@@ -386,13 +416,13 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
if (*info_ptr == NULL)
|
||||
{
|
||||
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
|
||||
return ERROR;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (setjmp((*png_ptr)->jmpbuf))
|
||||
if (setjmp(png_jmpbuf((*png_ptr))))
|
||||
{
|
||||
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
|
||||
return ERROR;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* This one's new. You will need to provide all three
|
||||
@@ -410,18 +440,18 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
|
||||
info_callback, row_callback, end_callback);
|
||||
|
||||
return OK;
|
||||
return (OK);
|
||||
}
|
||||
|
||||
int
|
||||
process_data(png_structp *png_ptr, png_infop *info_ptr,
|
||||
png_bytep buffer, png_uint_32 length)
|
||||
{
|
||||
if (setjmp((*png_ptr)->jmpbuf))
|
||||
if (setjmp(png_jmpbuf((*png_ptr))))
|
||||
{
|
||||
/* Free the png_ptr and info_ptr memory on error */
|
||||
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
|
||||
return ERROR;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* This one's new also. Simply give it chunks of data as
|
||||
@@ -435,7 +465,7 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
|
||||
* callback, if you aren't already displaying them there.
|
||||
*/
|
||||
png_process_data(*png_ptr, *info_ptr, buffer, length);
|
||||
return OK;
|
||||
return (OK);
|
||||
}
|
||||
|
||||
info_callback(png_structp png_ptr, png_infop info)
|
||||
@@ -465,7 +495,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
* png_progressive_combine_row() passing in the row and the
|
||||
* old row. You can call this function for NULL rows (it will
|
||||
* just return) and for non-interlaced images (it just does the
|
||||
* memcpy for you) if it will make the code easier. Thus, you
|
||||
* png_memcpy for you) if it will make the code easier. Thus, you
|
||||
* can just do this for all cases:
|
||||
*/
|
||||
|
||||
@@ -499,11 +529,12 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
FILE *fp;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_colorp palette;
|
||||
|
||||
/* open the file */
|
||||
fp = fopen(file_name, "wb");
|
||||
if (fp == NULL)
|
||||
return;
|
||||
return (ERROR);
|
||||
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
@@ -517,7 +548,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
if (png_ptr == NULL)
|
||||
{
|
||||
fclose(fp);
|
||||
return;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* Allocate/initialize the image information data. REQUIRED */
|
||||
@@ -526,18 +557,18 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
{
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
return;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* Set error handling. REQUIRED if you aren't supplying your own
|
||||
* error hadnling functions in the png_create_write_struct() call.
|
||||
* error handling functions in the png_create_write_struct() call.
|
||||
*/
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
/* If we get here, we had a problem reading the file */
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
return;
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* One of the following I/O initialization functions is REQUIRED */
|
||||
@@ -552,6 +583,15 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
#endif no_streams /* only use one initialization method */
|
||||
|
||||
#ifdef hilevel
|
||||
/* This is the easy way. Use it if you already have all the
|
||||
* image info living info in the structure. You could "|" many
|
||||
* PNG_TRANSFORM flags into the png_transforms integer here.
|
||||
*/
|
||||
png_write_png(png_ptr, info_ptr, png_transforms, NULL);
|
||||
#else
|
||||
/* This is the hard way */
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
@@ -564,9 +604,13 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* set the palette if there is one. REQUIRED for indexed-color images */
|
||||
palette = (png_colorp)png_malloc(png_ptr, 256 * sizeof (png_color));
|
||||
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
|
||||
* sizeof (png_color));
|
||||
/* ... set palette colors ... */
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, 256);
|
||||
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
|
||||
the palette that you malloced. Wait until you are about to destroy
|
||||
the png structure. */
|
||||
|
||||
/* optional significant bit chunk */
|
||||
/* if we are dealing with a grayscale image then */
|
||||
@@ -595,10 +639,15 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
text_ptr[2].key = "Description";
|
||||
text_ptr[2].text = "<long text>";
|
||||
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
text_ptr[0].lang = NULL;
|
||||
text_ptr[1].lang = NULL;
|
||||
text_ptr[2].lang = NULL;
|
||||
#endif
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 3);
|
||||
|
||||
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
|
||||
/* note that if sRGB is present the cHRM chunk must be ignored
|
||||
/* note that if sRGB is present the gAMA and cHRM chunks must be ignored
|
||||
* on read and must be written in accordance with the sRGB profile */
|
||||
|
||||
/* Write the file header information. REQUIRED */
|
||||
@@ -610,6 +659,9 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
||||
* write_my_chunk();
|
||||
* png_write_info(png_ptr, info_ptr);
|
||||
*
|
||||
* However, given the level of known- and unknown-chunk support in 1.1.0
|
||||
* and up, this should no longer be necessary.
|
||||
*/
|
||||
|
||||
/* Once we write out the header, the compression type on the text
|
||||
@@ -622,7 +674,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* all optional. Only call them if you want them.
|
||||
*/
|
||||
|
||||
/* invert monocrome pixels */
|
||||
/* invert monochrome pixels */
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
/* Shift the pixels up to a legal bit depth and fill in
|
||||
@@ -661,10 +713,10 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* use the first method if you aren't handling interlacing yourself.
|
||||
*/
|
||||
png_uint_32 k, height, width;
|
||||
png_byte image[height][width];
|
||||
png_byte image[height][width*bytes_per_pixel];
|
||||
png_bytep row_pointers[height];
|
||||
for (k = 0; k < height; k++)
|
||||
row_pointers[k] = image + k*width;
|
||||
row_pointers[k] = image + k*width*bytes_per_pixel;
|
||||
|
||||
/* One of the following output methods is REQUIRED */
|
||||
#ifdef entire /* write out the entire image data in one call */
|
||||
@@ -690,25 +742,37 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
#endif no_entire /* use only one output method */
|
||||
|
||||
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
|
||||
* as well.
|
||||
* as well. Shouldn't be necessary in 1.1.0 and up as all the public
|
||||
* chunks are supported and you can use png_set_unknown_chunks() to
|
||||
* register unknown chunks into the info structure to be written out.
|
||||
*/
|
||||
|
||||
/* It is REQUIRED to call this to finish writing the rest of the file */
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
#endif hilevel
|
||||
|
||||
/* if you malloced the palette, free it here */
|
||||
free(info_ptr->palette);
|
||||
/* If you png_malloced a palette, free it here (don't free info_ptr->palette,
|
||||
as recommended in versions 1.0.5m and earlier of this example; if
|
||||
libpng mallocs info_ptr->palette, libpng will free it). If you
|
||||
allocated it with malloc() instead of png_malloc(), use free() instead
|
||||
of png_free(). */
|
||||
png_free(png_ptr, palette);
|
||||
palette=NULL;
|
||||
|
||||
/* if you allocated any text comments, free them here */
|
||||
/* 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;
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
/* close the file */
|
||||
fclose(fp);
|
||||
|
||||
/* that's it */
|
||||
return;
|
||||
return (OK);
|
||||
}
|
||||
|
||||
#endif /* if 0 */
|
||||
|
||||
1197
libpng.txt
58
libpngpf.3
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 November 29, 1999
|
||||
.TH LIBPNGPF 3 "May 14, 2001"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29, 1999
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include <png.h>\fP
|
||||
@@ -55,6 +55,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -187,6 +191,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -211,6 +219,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -231,6 +247,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -359,10 +383,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_read_init (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -399,6 +419,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
|
||||
|
||||
\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP
|
||||
@@ -417,11 +441,15 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
@@ -437,6 +465,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext)\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -457,6 +489,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -465,6 +505,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
8
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "November 29, 1999"
|
||||
.TH PNG 5 "May 14, 2001"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
@@ -20,10 +20,12 @@ platforms.
|
||||
.SH "SEE ALSO"
|
||||
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
|
||||
.LP
|
||||
PNG 1.1 specification, January 1999:
|
||||
PNG 1.2 specification, July 1999:
|
||||
.IP
|
||||
.br
|
||||
http://www.cdrom.com/pub/png
|
||||
http://www.libpng.org/pub/png
|
||||
.br
|
||||
or ftp://ftp.uu.net/graphics/png/documents
|
||||
.LP
|
||||
PNG 1.0 specification, October 1996:
|
||||
.IP
|
||||
|
||||
516
png.c
@@ -1,29 +1,31 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng version 1.0.5d - November 29, 1999
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
*
|
||||
* libpng version 1.0.12beta1 - May 14, 2001
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#define PNG_NO_EXTERN
|
||||
#include "png.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef version_1_0_12beta1 Your_png_h_is_not_version_1_0_12beta1;
|
||||
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
* string defined in png.h. */
|
||||
|
||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||
char png_libpng_ver[12] = "1.0.5d";
|
||||
const char png_libpng_ver[18] = "1.0.12beta1";
|
||||
|
||||
/* png_sig was changed to a function in version 1.0.5c */
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
/* Invoke global declarations for constant strings for known chunk types */
|
||||
PNG_IHDR;
|
||||
PNG_IDAT;
|
||||
@@ -33,10 +35,14 @@ PNG_bKGD;
|
||||
PNG_cHRM;
|
||||
PNG_gAMA;
|
||||
PNG_hIST;
|
||||
PNG_iCCP;
|
||||
PNG_iTXt;
|
||||
PNG_oFFs;
|
||||
PNG_pCAL;
|
||||
PNG_sCAL;
|
||||
PNG_pHYs;
|
||||
PNG_sBIT;
|
||||
PNG_sPLT;
|
||||
PNG_sRGB;
|
||||
PNG_tEXt;
|
||||
PNG_tIME;
|
||||
@@ -46,32 +52,33 @@ PNG_zTXt;
|
||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* start of interlace block */
|
||||
int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* offset to next interlace block */
|
||||
int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* start of interlace block in the y direction */
|
||||
int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* offset to next interlace block in the y direction */
|
||||
int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
/* Width of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
||||
*/
|
||||
/* width of interlace block (used in assembler routines only) */
|
||||
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
||||
#endif
|
||||
|
||||
/* Height of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
*/
|
||||
|
||||
/* Mask to determine which pixels are valid in a pass */
|
||||
int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
|
||||
/* Mask to determine which pixels to overwrite while displaying */
|
||||
int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
const int FARDATA png_pass_dsp_mask[]
|
||||
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -81,7 +88,7 @@ int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
* or write any of the magic bytes before it starts on the IHDR.
|
||||
*/
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||
{
|
||||
png_debug(1, "in png_set_sig_bytes\n");
|
||||
@@ -99,7 +106,7 @@ png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||
* respectively, to be less than, to match, or be greater than the correct
|
||||
* PNG signature (this is the same behaviour as strcmp, memcmp, etc).
|
||||
*/
|
||||
int
|
||||
int PNGAPI
|
||||
png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
{
|
||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
@@ -121,19 +128,20 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
* to check a partial signature. This function might be removed in the
|
||||
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
|
||||
*/
|
||||
int
|
||||
int PNGAPI
|
||||
png_check_sig(png_bytep sig, int num)
|
||||
{
|
||||
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
|
||||
}
|
||||
|
||||
/* Function to allocate memory for zlib. */
|
||||
voidpf
|
||||
/* Function to allocate memory for zlib and clear it to 0. */
|
||||
voidpf /* PRIVATE */
|
||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
{
|
||||
png_uint_32 num_bytes = (png_uint_32)items * size;
|
||||
png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
|
||||
|
||||
#ifndef PNG_NO_ZALLOC_ZERO
|
||||
if (num_bytes > (png_uint_32)0x8000L)
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)0x8000L);
|
||||
@@ -144,11 +152,12 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)num_bytes);
|
||||
}
|
||||
#endif
|
||||
return ((voidpf)ptr);
|
||||
}
|
||||
|
||||
/* function to free memory for zlib */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_zfree(voidpf png_ptr, voidpf ptr)
|
||||
{
|
||||
png_free((png_structp)png_ptr, (png_voidp)ptr);
|
||||
@@ -157,7 +166,7 @@ png_zfree(voidpf png_ptr, voidpf ptr)
|
||||
/* Reset the CRC variable to 32 bits of 1's. Care must be taken
|
||||
* in case CRC is > 32 bits to leave the top bits 0.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_reset_crc(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->crc = crc32(0, Z_NULL, 0);
|
||||
@@ -168,7 +177,7 @@ png_reset_crc(png_structp png_ptr)
|
||||
* also check that this data will actually be used before going to the
|
||||
* trouble of calculating it.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||
{
|
||||
int need_crc = 1;
|
||||
@@ -195,7 +204,7 @@ png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||
* and png_info_init() so that applications that want to use a shared
|
||||
* libpng don't have to be recompiled if png_info changes size.
|
||||
*/
|
||||
png_infop
|
||||
png_infop PNGAPI
|
||||
png_create_info_struct(png_structp png_ptr)
|
||||
{
|
||||
png_infop info_ptr;
|
||||
@@ -204,12 +213,12 @@ png_create_info_struct(png_structp png_ptr)
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
|
||||
png_ptr->malloc_fn)) != NULL)
|
||||
png_ptr->malloc_fn, png_ptr->mem_ptr)) != NULL)
|
||||
#else
|
||||
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
|
||||
#endif
|
||||
{
|
||||
png_info_init(info_ptr);
|
||||
png_info_init_3(&info_ptr, sizeof(png_info));
|
||||
}
|
||||
|
||||
return (info_ptr);
|
||||
@@ -220,7 +229,7 @@ png_create_info_struct(png_structp png_ptr)
|
||||
* png_destroy_write_struct() to free an info struct, but this may be
|
||||
* useful for some applications.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||
{
|
||||
png_infop info_ptr = NULL;
|
||||
@@ -234,7 +243,8 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||
png_info_destroy(png_ptr, info_ptr);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn);
|
||||
png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn,
|
||||
png_ptr->mem_ptr);
|
||||
#else
|
||||
png_destroy_struct((png_voidp)info_ptr);
|
||||
#endif
|
||||
@@ -246,62 +256,314 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||
* and applications using it are urged to use png_create_info_struct()
|
||||
* instead.
|
||||
*/
|
||||
void
|
||||
#undef png_info_init
|
||||
void PNGAPI
|
||||
png_info_init(png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_info_init\n");
|
||||
/* We only come here via pre-1.0.12-compiled applications */
|
||||
png_info_init_3(&info_ptr, 0);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
|
||||
{
|
||||
png_infop info_ptr = *ptr_ptr;
|
||||
|
||||
png_debug(1, "in png_info_init_3\n");
|
||||
|
||||
if(sizeof(png_info) > png_info_struct_size)
|
||||
{
|
||||
png_destroy_struct(info_ptr);
|
||||
info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
|
||||
*ptr_ptr = info_ptr;
|
||||
}
|
||||
|
||||
/* set everything to 0 */
|
||||
png_memset(info_ptr, 0, sizeof (png_info));
|
||||
}
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
void PNGAPI
|
||||
png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
||||
int freer, png_uint_32 mask)
|
||||
{
|
||||
png_debug(1, "in png_data_freer\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
if(freer == PNG_DESTROY_WILL_FREE_DATA)
|
||||
info_ptr->free_me |= mask;
|
||||
else if(freer == PNG_USER_WILL_FREE_DATA)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Unknown freer parameter in png_data_freer.");
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
|
||||
int num)
|
||||
{
|
||||
png_debug(1, "in png_free_data\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
/* free text item num or (if num == -1) all text items */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_TEXT)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if (info_ptr->text && info_ptr->text[num].key)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->text[num].key);
|
||||
info_ptr->text[num].key = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info_ptr->num_text; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
info_ptr->text = NULL;
|
||||
info_ptr->num_text=0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED)
|
||||
/* free any tRNS entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->trans);
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
info_ptr->trans = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sCAL_SUPPORTED)
|
||||
/* free any sCAL entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_SCAL)
|
||||
#endif
|
||||
{
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->scal_s_width);
|
||||
png_free(png_ptr, info_ptr->scal_s_height);
|
||||
info_ptr->scal_s_width = NULL;
|
||||
info_ptr->scal_s_height = NULL;
|
||||
#endif
|
||||
info_ptr->valid &= ~PNG_INFO_sCAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pCAL_SUPPORTED)
|
||||
/* free any pCAL entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_PCAL)
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_purpose);
|
||||
png_free(png_ptr, info_ptr->pcal_units);
|
||||
info_ptr->pcal_purpose = NULL;
|
||||
info_ptr->pcal_units = NULL;
|
||||
if (info_ptr->pcal_params != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_params[i]);
|
||||
info_ptr->pcal_params[i]=NULL;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->pcal_params);
|
||||
info_ptr->pcal_params = NULL;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_pCAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
/* free any iCCP entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_ICCP)
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->iccp_name);
|
||||
png_free(png_ptr, info_ptr->iccp_profile);
|
||||
info_ptr->iccp_name = NULL;
|
||||
info_ptr->iccp_profile = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_iCCP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sPLT_SUPPORTED)
|
||||
/* free a given sPLT entry, or (if num == -1) all sPLT entries */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_SPLT)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if(info_ptr->splt_palettes)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].name);
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].entries);
|
||||
info_ptr->splt_palettes[num].name = NULL;
|
||||
info_ptr->splt_palettes[num].entries = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(info_ptr->splt_palettes_num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes = NULL;
|
||||
info_ptr->splt_palettes_num = 0;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_sPLT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_UNKN)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if(info_ptr->unknown_chunks)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->unknown_chunks[num].data);
|
||||
info_ptr->unknown_chunks[num].data = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
if(info_ptr->unknown_chunks_num)
|
||||
{
|
||||
for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
|
||||
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks = NULL;
|
||||
info_ptr->unknown_chunks_num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
/* free any hIST entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->hist);
|
||||
info_ptr->hist = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_hIST;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* free any PLTE entry that was internally allocated */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
|
||||
#endif
|
||||
{
|
||||
png_zfree(png_ptr, info_ptr->palette);
|
||||
info_ptr->palette = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_PLTE;
|
||||
info_ptr->num_palette = 0;
|
||||
}
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
/* free any image bits attached to the info structure */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_ROWS)
|
||||
#endif
|
||||
{
|
||||
if(info_ptr->row_pointers)
|
||||
{
|
||||
int row;
|
||||
for (row = 0; row < (int)info_ptr->height; row++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->row_pointers[row]);
|
||||
info_ptr->row_pointers[row]=NULL;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->row_pointers);
|
||||
info_ptr->row_pointers=NULL;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_IDAT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if(num == -1)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This is an internal routine to free any memory that the info struct is
|
||||
* pointing to before re-using it or freeing the struct itself. Recall
|
||||
* that png_free() checks for NULL pointers for us.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_debug(1, "in png_info_destroy\n");
|
||||
if (info_ptr->text != NULL)
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info_ptr->num_text; i++)
|
||||
{
|
||||
if(info_ptr->text[i].key != NULL)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->text[i].key);
|
||||
info_ptr->text[i].key = NULL;
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
info_ptr->text = NULL;
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->pcal_purpose);
|
||||
png_free(png_ptr, info_ptr->pcal_units);
|
||||
if (info_ptr->pcal_params != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_params[i]);
|
||||
info_ptr->pcal_params[i]=NULL;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->pcal_params);
|
||||
info_ptr->pcal_params = NULL;
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
png_ptr->num_chunk_list=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_info_init(info_ptr);
|
||||
png_info_init_3(&info_ptr, sizeof(png_info));
|
||||
}
|
||||
|
||||
/* This function returns a pointer to the io_ptr associated with the user
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy() or png_read_destroy() are called.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_io_ptr(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr->io_ptr);
|
||||
@@ -310,10 +572,12 @@ png_get_io_ptr(png_structp png_ptr)
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
/* Initialize the default input/output functions for the PNG file. If you
|
||||
* use your own read or write routines, you can call either png_set_read_fn()
|
||||
* or png_set_write_fn() instead of png_init_io().
|
||||
* or png_set_write_fn() instead of png_init_io(). If you have defined
|
||||
* PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
|
||||
* necessarily available.
|
||||
*/
|
||||
void
|
||||
png_init_io(png_structp png_ptr, FILE *fp)
|
||||
void PNGAPI
|
||||
png_init_io(png_structp png_ptr, png_FILE_p fp)
|
||||
{
|
||||
png_debug(1, "in png_init_io\n");
|
||||
png_ptr->io_ptr = (png_voidp)fp;
|
||||
@@ -324,7 +588,7 @@ png_init_io(png_structp png_ptr, FILE *fp)
|
||||
/* Convert the supplied time into an RFC 1123 string suitable for use in
|
||||
* a "Creation Time" or other text-based time string.
|
||||
*/
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
{
|
||||
static PNG_CONST char short_months[12][4] =
|
||||
@@ -337,45 +601,56 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
sizeof(char)));
|
||||
}
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
{
|
||||
wchar_t time_buf[29];
|
||||
wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29,
|
||||
NULL, NULL);
|
||||
}
|
||||
#else
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
char near_time_buf[29];
|
||||
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
png_memcpy(png_ptr->time_buffer, near_time_buf,
|
||||
29*sizeof(char));
|
||||
29*sizeof(char));
|
||||
}
|
||||
#else
|
||||
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
#endif
|
||||
#endif /* _WIN32_WCE */
|
||||
return ((png_charp)png_ptr->time_buffer);
|
||||
}
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
|
||||
#if 0
|
||||
/* Signature string for a PNG file. */
|
||||
png_bytep
|
||||
png_sig_bytes(png_structp png_ptr)
|
||||
png_bytep PNGAPI
|
||||
png_sig_bytes(void)
|
||||
{
|
||||
const png_byte png_sig_numbers[9] = {137, 80, 78, 71, 13, 10, 26, 10, 0};
|
||||
if (png_ptr == NULL) /* silence compiler warning */
|
||||
return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
|
||||
return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
|
||||
return ((png_bytep)"\211\120\116\107\015\012\032\012");
|
||||
}
|
||||
#endif
|
||||
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_get_copyright(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
||||
return ("\n libpng version 1.0.5d - November 29, 1999\n\
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
|
||||
return ((png_charp) "\n libpng version 1.0.12beta1 - May 14, 2001\n\
|
||||
Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\
|
||||
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
|
||||
return ("");
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
||||
return ((png_charp) "");
|
||||
}
|
||||
|
||||
/* The following return the library version as a short string in the
|
||||
@@ -384,38 +659,71 @@ png_get_copyright(png_structp png_ptr)
|
||||
* in png.h.
|
||||
*/
|
||||
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_get_libpng_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
||||
return("1.0.5d");
|
||||
return("1.0.5d");
|
||||
return((png_charp) "1.0.12beta1");
|
||||
return((png_charp) "1.0.12beta1");
|
||||
}
|
||||
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_get_header_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.h files used when building libpng */
|
||||
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
||||
return(PNG_LIBPNG_VER_STRING);
|
||||
return(PNG_LIBPNG_VER_STRING);
|
||||
return((png_charp) PNG_LIBPNG_VER_STRING);
|
||||
return((png_charp) PNG_LIBPNG_VER_STRING);
|
||||
}
|
||||
|
||||
png_charp
|
||||
png_charp PNGAPI
|
||||
png_get_header_version(png_structp png_ptr)
|
||||
{
|
||||
/* Returns longer string containing both version and date */
|
||||
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
||||
return(PNG_HEADER_VERSION_STRING);
|
||||
return(PNG_HEADER_VERSION_STRING);
|
||||
return((png_charp) PNG_HEADER_VERSION_STRING);
|
||||
return((png_charp) PNG_HEADER_VERSION_STRING);
|
||||
}
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
void
|
||||
png_check_version
|
||||
(version_1_0_5d png_h_is_not_version_1_0_5d)
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int /* PRIVATE */
|
||||
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
||||
{
|
||||
if(png_h_is_not_version_1_0_5d == NULL)
|
||||
return;
|
||||
/* check chunk_name and return "keep" value if it's on the list, else 0 */
|
||||
int i;
|
||||
png_bytep p;
|
||||
if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0)
|
||||
return 0;
|
||||
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
|
||||
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
|
||||
if (!png_memcmp(chunk_name, p, 4))
|
||||
return ((int)*(p+4));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function, added to libpng-1.0.6g, is untested. */
|
||||
int PNGAPI
|
||||
png_reset_zstream(png_structp png_ptr)
|
||||
{
|
||||
return (inflateReset(&png_ptr->zstream));
|
||||
}
|
||||
|
||||
/* This function was added to libpng-1.0.7 */
|
||||
png_uint_32 PNGAPI
|
||||
png_access_version_number(void)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
return((png_uint_32) 10012L);
|
||||
}
|
||||
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
#if !defined(PNG_USE_PNGGCCRD) && \
|
||||
!(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD))
|
||||
int PNGAPI
|
||||
png_mmx_support(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
29
pngasmrd.h
@@ -1,32 +1,11 @@
|
||||
/* pngasmrd.h - assembler version of utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2001 Glenn Randers-Pehrson
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||
|
||||
/* Set this in the makefile for VC++ on Pentium, not in pngconf.h */
|
||||
#ifdef PNG_USE_PNGVCRD
|
||||
/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
|
||||
* MMX will be detected at run time and used if present.
|
||||
/* This file is obsolete in libpng-1.0.9 and later; its contents now appear
|
||||
* at the end of pngconf.h.
|
||||
*/
|
||||
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
#define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
||||
#define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
||||
#endif
|
||||
|
||||
/* Set this in the makefile for gcc on Pentium, not in pngconf.h */
|
||||
#ifdef PNG_USE_PNGGCCRD
|
||||
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c
|
||||
* (not available in libpng 1.0.5d).
|
||||
* MMX will be detected at run time and used if present.
|
||||
*/
|
||||
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
#define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
||||
#define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
BIN
pngbar.jpg
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
pngbar.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
180
pngerror.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file provides a location for all error handling. Users who
|
||||
* need special error handling are expected to write replacement functions
|
||||
@@ -16,9 +16,11 @@
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
static void png_default_error PNGARG((png_structp png_ptr,
|
||||
static void /* PRIVATE */
|
||||
png_default_error PNGARG((png_structp png_ptr,
|
||||
png_const_charp message));
|
||||
static void png_default_warning PNGARG((png_structp png_ptr,
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_const_charp message));
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
@@ -26,9 +28,41 @@ static void png_default_warning PNGARG((png_structp png_ptr,
|
||||
* you should supply a replacement error function and use png_set_error_fn()
|
||||
* to replace the error function at run-time.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
char msg[16];
|
||||
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
{
|
||||
int offset = 0;
|
||||
if (*message == '#')
|
||||
{
|
||||
for (offset=1; offset<15; offset++)
|
||||
if (*(message+offset) == ' ')
|
||||
break;
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<offset-1; i++)
|
||||
msg[i]=message[i+1];
|
||||
msg[i]='\0';
|
||||
message=msg;
|
||||
}
|
||||
else
|
||||
message+=offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
msg[0]='0';
|
||||
msg[1]='\0';
|
||||
message=msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, message);
|
||||
|
||||
@@ -42,13 +76,25 @@ png_error(png_structp png_ptr, png_const_charp message)
|
||||
* you should supply a replacement warning function and use
|
||||
* png_set_error_fn() to replace the warning function at run-time.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
int offset = 0;
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
#endif
|
||||
{
|
||||
if (*message == '#')
|
||||
{
|
||||
for (offset=1; offset<15; offset++)
|
||||
if (*(message+offset) == ' ')
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (png_ptr->warning_fn != NULL)
|
||||
(*(png_ptr->warning_fn))(png_ptr, message);
|
||||
(*(png_ptr->warning_fn))(png_ptr, (png_const_charp)(message+offset));
|
||||
else
|
||||
png_default_warning(png_ptr, message);
|
||||
png_default_warning(png_ptr, (png_const_charp)(message+offset));
|
||||
}
|
||||
|
||||
/* These utilities are used internally to build an error message that relates
|
||||
@@ -59,29 +105,35 @@ png_warning(png_structp png_ptr, png_const_charp message)
|
||||
*/
|
||||
#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||
static PNG_CONST char png_digit[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
|
||||
'F' };
|
||||
|
||||
static void
|
||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message)
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
message)
|
||||
{
|
||||
int iout = 0, iin = 0;
|
||||
|
||||
while (iin < 4) {
|
||||
while (iin < 4)
|
||||
{
|
||||
int c = png_ptr->chunk_name[iin++];
|
||||
if (isnonalpha(c)) {
|
||||
if (isnonalpha(c))
|
||||
{
|
||||
buffer[iout++] = '[';
|
||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||
buffer[iout++] = png_digit[c & 0xf];
|
||||
buffer[iout++] = png_digit[c & 0x0f];
|
||||
buffer[iout++] = ']';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[iout++] = (png_byte)c;
|
||||
}
|
||||
}
|
||||
|
||||
if (message == NULL)
|
||||
buffer[iout] = 0;
|
||||
else {
|
||||
else
|
||||
{
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
png_memcpy(buffer+iout, message, 64);
|
||||
@@ -89,18 +141,18 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_chunk_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
char msg[16+64];
|
||||
char msg[18+64];
|
||||
png_format_buffer(png_ptr, msg, message);
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_chunk_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
char msg[16+64];
|
||||
char msg[18+64];
|
||||
png_format_buffer(png_ptr, msg, message);
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
@@ -110,21 +162,51 @@ png_chunk_warning(png_structp png_ptr, png_const_charp message)
|
||||
* function is used by default, or if the program supplies NULL for the
|
||||
* error function pointer in png_set_error_fn().
|
||||
*/
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*message == '#')
|
||||
{
|
||||
int offset;
|
||||
char error_number[16];
|
||||
for (offset=0; offset<15; offset++)
|
||||
{
|
||||
error_number[offset] = *(message+offset+1);
|
||||
if (*(message+offset) == ' ')
|
||||
break;
|
||||
}
|
||||
if((offset > 1) && (offset < 15))
|
||||
{
|
||||
error_number[offset-1]='\0';
|
||||
fprintf(stderr, "libpng error no. %s: %s\n", error_number, message+offset);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "libpng error: %s, offset=%d\n", message,offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
fprintf(stderr, "libpng error: %s\n", message);
|
||||
#else
|
||||
if (message)
|
||||
/* make compiler happy */ ;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
jmp_buf jmpbuf;
|
||||
png_memcpy(jmpbuf,png_ptr->jmpbuf,sizeof(jmp_buf));
|
||||
longjmp(jmpbuf, 1);
|
||||
}
|
||||
#else
|
||||
# else
|
||||
longjmp(png_ptr->jmpbuf, 1);
|
||||
# endif
|
||||
#else
|
||||
if (png_ptr)
|
||||
/* make compiler happy */ ;
|
||||
PNG_ABORT();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -133,13 +215,38 @@ png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
* here if you don't want them to. In the default configuration, png_ptr is
|
||||
* not used, but it is passed in case it may be useful.
|
||||
*/
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
fprintf(stderr, "libpng warning: %s\n", message);
|
||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*message == '#')
|
||||
{
|
||||
int offset;
|
||||
char warning_number[16];
|
||||
for (offset=0; offset<15; offset++)
|
||||
{
|
||||
warning_number[offset]=*(message+offset+1);
|
||||
if (*(message+offset) == ' ')
|
||||
break;
|
||||
}
|
||||
if((offset > 1) && (offset < 15))
|
||||
{
|
||||
warning_number[offset-1]='\0';
|
||||
fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
|
||||
message+offset);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "libpng warning: %s\n", message);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
fprintf(stderr, "libpng warning: %s\n", message);
|
||||
#else
|
||||
if (message)
|
||||
/* appease compiler */ ;
|
||||
#endif
|
||||
if (png_ptr == NULL)
|
||||
if (png_ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -148,7 +255,7 @@ png_default_warning(png_structp png_ptr, png_const_charp message)
|
||||
* return to the calling routine or serious problems will occur. The return
|
||||
* method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
{
|
||||
@@ -162,11 +269,22 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_error_ptr(png_structp png_ptr)
|
||||
{
|
||||
return ((png_voidp)png_ptr->error_ptr);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
void
|
||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
{
|
||||
if(png_ptr != NULL)
|
||||
{
|
||||
png_ptr->flags &=
|
||||
((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
5180
pnggccrd.c
Normal file
487
pngget.c
@@ -1,17 +1,17 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -20,7 +20,7 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||
return(0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -29,9 +29,20 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||
return(0);
|
||||
}
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
png_bytepp PNGAPI
|
||||
png_get_rows(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->row_pointers);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
/* easy access to info, added in libpng-0.99 */
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -41,7 +52,7 @@ png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -51,7 +62,7 @@ png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -61,7 +72,7 @@ png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -71,7 +82,7 @@ png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -81,7 +92,7 @@ png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -91,7 +102,7 @@ png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -101,43 +112,48 @@ png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
else
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->y_pixels_per_unit);
|
||||
}
|
||||
else
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
||||
@@ -145,137 +161,150 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
else
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
float
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float PNGAPI
|
||||
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
|
||||
if (info_ptr->x_pixels_per_unit == 0)
|
||||
return ((float)0.0);
|
||||
else
|
||||
return ((float)info_ptr->y_pixels_per_unit
|
||||
/(float)info_ptr->x_pixels_per_unit);
|
||||
return ((float)((float)info_ptr->y_pixels_per_unit
|
||||
/(float)info_ptr->x_pixels_per_unit));
|
||||
}
|
||||
else
|
||||
#else
|
||||
return (0.0);
|
||||
#endif
|
||||
return ((float)0.0);
|
||||
return ((float)0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_uint_32
|
||||
png_int_32 PNGAPI
|
||||
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
else
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_int_32 PNGAPI
|
||||
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
else
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_int_32 PNGAPI
|
||||
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
else
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_int_32 PNGAPI
|
||||
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
else
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef PNG_INCH_CONVERSIONS
|
||||
png_uint_32
|
||||
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
*.0254 +.5));
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
*.0254 +.5));
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
*.0254 +.5));
|
||||
}
|
||||
|
||||
float
|
||||
float PNGAPI
|
||||
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
|
||||
*.03937/1000000. +.5)
|
||||
*.00003937);
|
||||
}
|
||||
|
||||
float
|
||||
float PNGAPI
|
||||
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
|
||||
*.03937/1000000. +.5)
|
||||
*.00003937);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||
if (res_x != NULL)
|
||||
@@ -292,23 +321,23 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
|
||||
{
|
||||
*unit_type = (int)info_ptr->phys_unit_type;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
if(unit_type == 1)
|
||||
if(*unit_type == 1)
|
||||
{
|
||||
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * 39.37 + .50);
|
||||
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * 39.37 + .50);
|
||||
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
|
||||
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
#endif /* PNG_READ_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS */
|
||||
#endif /* PNG_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
|
||||
|
||||
/* png_get_channels really belongs in here, too, but it's been around longer */
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
png_byte
|
||||
png_byte PNGAPI
|
||||
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -317,7 +346,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_bytep
|
||||
png_bytep PNGAPI
|
||||
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@@ -326,8 +355,8 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_bKGD_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_16p *background)
|
||||
{
|
||||
@@ -342,8 +371,9 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
@@ -372,9 +402,42 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
|
||||
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
|
||||
png_fixed_point *blue_x, png_fixed_point *blue_y)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "cHRM");
|
||||
if (white_x != NULL)
|
||||
*white_x = info_ptr->int_x_white;
|
||||
if (white_y != NULL)
|
||||
*white_y = info_ptr->int_y_white;
|
||||
if (red_x != NULL)
|
||||
*red_x = info_ptr->int_x_red;
|
||||
if (red_y != NULL)
|
||||
*red_y = info_ptr->int_y_red;
|
||||
if (green_x != NULL)
|
||||
*green_x = info_ptr->int_x_green;
|
||||
if (green_y != NULL)
|
||||
*green_y = info_ptr->int_y_green;
|
||||
if (blue_x != NULL)
|
||||
*blue_x = info_ptr->int_x_blue;
|
||||
if (blue_y != NULL)
|
||||
*blue_y = info_ptr->int_y_blue;
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
@@ -387,9 +450,25 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed_point *int_file_gamma)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
&& int_file_gamma != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "gAMA");
|
||||
*int_file_gamma = info_ptr->int_gamma;
|
||||
return (PNG_INFO_gAMA);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_sRGB_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||
@@ -403,8 +482,41 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charpp name, int *compression_type,
|
||||
png_charpp profile, png_uint_32 *proflen)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
||||
&& name != NULL && profile != NULL && proflen != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "iCCP");
|
||||
*name = info_ptr->iccp_name;
|
||||
*profile = info_ptr->iccp_profile;
|
||||
/* compression_type is a dummy so the API won't have to change
|
||||
if we introduce multiple compression types later. */
|
||||
*proflen = (int)info_ptr->iccp_proflen;
|
||||
*compression_type = (int)info_ptr->iccp_compression;
|
||||
return (PNG_INFO_iCCP);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sPLT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
||||
png_sPLT_tpp spalettes)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||
*spalettes = info_ptr->splt_palettes;
|
||||
return ((png_uint_32)info_ptr->splt_palettes_num);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
||||
@@ -418,7 +530,7 @@ png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
||||
}
|
||||
#endif
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
||||
int *color_type, int *interlace_type, int *compression_type,
|
||||
@@ -464,10 +576,10 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *offset_x, png_uint_32 *offset_y, int *unit_type)
|
||||
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
||||
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||
@@ -482,14 +594,14 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_pCAL_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||
png_charp *units, png_charpp *params)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL &&
|
||||
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
|
||||
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
nparams != NULL && units != NULL && params != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pCAL");
|
||||
@@ -506,14 +618,51 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_sCAL_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
int *unit, double *width, double *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_pixel_width;
|
||||
*height = info_ptr->scal_pixel_height;
|
||||
return (PNG_INFO_sCAL);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
int *unit, png_charpp width, png_charpp height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_s_width;
|
||||
*height = info_ptr->scal_s_height;
|
||||
return (PNG_INFO_sCAL);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||
if (res_x != NULL)
|
||||
@@ -536,12 +685,12 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
png_uint_32
|
||||
png_uint_32 PNGAPI
|
||||
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
||||
int *num_palette)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_PLTE &&
|
||||
palette != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
|
||||
&& palette != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "PLTE");
|
||||
*palette = info_ptr->palette;
|
||||
@@ -552,12 +701,12 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_sBIT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sBIT &&
|
||||
sig_bit != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
|
||||
&& sig_bit != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "sBIT");
|
||||
*sig_bit = &(info_ptr->sig_bit);
|
||||
@@ -567,8 +716,8 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||
int *num_text)
|
||||
{
|
||||
@@ -583,16 +732,18 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||
*num_text = info_ptr->num_text;
|
||||
return ((png_uint_32)info_ptr->num_text);
|
||||
}
|
||||
if (num_text != NULL)
|
||||
*num_text = 0;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_tIME_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tIME &&
|
||||
mod_time != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
|
||||
&& mod_time != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "tIME");
|
||||
*mod_time = &(info_ptr->mod_time);
|
||||
@@ -602,13 +753,13 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
png_uint_32
|
||||
#if defined(PNG_tRNS_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep *trans, int *num_trans, png_color_16p *trans_values)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "tRNS");
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
@@ -641,10 +792,126 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_byte
|
||||
png_get_rgb_to_gray_status (png_structp png_ptr)
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
||||
png_unknown_chunkpp unknowns)
|
||||
{
|
||||
return png_ptr->rgb_to_gray_status;
|
||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||
*unknowns = info_ptr->unknown_chunks;
|
||||
return ((png_uint_32)info_ptr->unknown_chunks_num);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_byte PNGAPI
|
||||
png_get_rgb_to_gray_status (png_structp png_ptr)
|
||||
{
|
||||
return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_USER_CHUNKS_SUPPORTED)
|
||||
png_voidp PNGAPI
|
||||
png_get_user_chunk_ptr(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr? png_ptr->user_chunk_ptr : NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_compression_buffer_size(png_structp png_ptr)
|
||||
{
|
||||
return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||
/* this function was added to libpng 1.2.0 and should exist by default*/
|
||||
png_uint_32 PNGAPI
|
||||
png_get_asm_flags (png_structp png_ptr)
|
||||
{
|
||||
return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
|
||||
}
|
||||
|
||||
/* this function was added to libpng 1.2.0 and should exist by default */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_asm_flagmask (int flag_select)
|
||||
{
|
||||
png_uint_32 settable_asm_flags = 0;
|
||||
|
||||
if (flag_select & PNG_SELECT_READ)
|
||||
settable_asm_flags |=
|
||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
|
||||
/* no non-MMX flags yet */
|
||||
|
||||
#if 0
|
||||
/* GRR: no write-flags yet, either, but someday... */
|
||||
if (flag_select & PNG_SELECT_WRITE)
|
||||
settable_asm_flags |=
|
||||
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
|
||||
#endif /* 0 */
|
||||
|
||||
return settable_asm_flags; /* _theoretically_ settable capabilities only */
|
||||
}
|
||||
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||
|
||||
|
||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
||||
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_mmx_flagmask (int flag_select, int *compilerID)
|
||||
{
|
||||
png_uint_32 settable_mmx_flags = 0;
|
||||
|
||||
if (flag_select & PNG_SELECT_READ)
|
||||
settable_mmx_flags |=
|
||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
|
||||
#if 0
|
||||
/* GRR: no MMX write support yet, but someday... */
|
||||
if (flag_select & PNG_SELECT_WRITE)
|
||||
settable_mmx_flags |=
|
||||
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
|
||||
#endif /* 0 */
|
||||
|
||||
if (compilerID != NULL) {
|
||||
#ifdef PNG_USE_PNGVCRD
|
||||
*compilerID = 1; /* MSVC */
|
||||
#else
|
||||
#ifdef PNG_USE_PNGGCCRD
|
||||
*compilerID = 2; /* gcc/gas */
|
||||
#else
|
||||
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
return settable_mmx_flags; /* _theoretically_ settable capabilities only */
|
||||
}
|
||||
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
png_byte PNGAPI
|
||||
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
|
||||
{
|
||||
return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
|
||||
}
|
||||
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
|
||||
{
|
||||
return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
|
||||
}
|
||||
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||
|
||||
110
pngmem.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users who
|
||||
* need special memory handling are expected to supply replacement
|
||||
@@ -23,16 +23,16 @@
|
||||
|
||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||
by a single call to calloc() if this is thought to improve performance. */
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct(int type)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL));
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
||||
png_voidp
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
@@ -48,9 +48,18 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(malloc_fn != NULL)
|
||||
{
|
||||
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL)
|
||||
if (mem_ptr != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
||||
}
|
||||
else
|
||||
struct_ptr = (*(malloc_fn))(NULL, size);
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
return (struct_ptr);
|
||||
return (struct_ptr);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
||||
@@ -62,16 +71,17 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL);
|
||||
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
#endif
|
||||
if (struct_ptr != NULL)
|
||||
@@ -81,6 +91,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
@@ -108,7 +119,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
* result, we would be truncating potentially larger memory requests
|
||||
* (which should cause a fatal error) and introducing major problems.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
@@ -119,12 +130,17 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(png_ptr->malloc_fn != NULL)
|
||||
return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
||||
{
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of memory!");
|
||||
return (ret);
|
||||
}
|
||||
else
|
||||
return png_malloc_default(png_ptr, size);
|
||||
}
|
||||
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
@@ -224,7 +240,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
/* free a pointer allocated by png_malloc(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
@@ -239,7 +255,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||
else png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
@@ -277,18 +293,18 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably.*/
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct(int type)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL));
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably.*/
|
||||
png_voidp
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
@@ -304,7 +320,16 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(malloc_fn != NULL)
|
||||
{
|
||||
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL)
|
||||
if (mem_ptr != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
||||
}
|
||||
else
|
||||
struct_ptr = (*(malloc_fn))(NULL, size);
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
return (struct_ptr);
|
||||
}
|
||||
@@ -328,16 +353,17 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL);
|
||||
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if (struct_ptr != NULL)
|
||||
@@ -347,6 +373,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
@@ -370,22 +397,25 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
|
||||
need to allocate exactly 64K, so whatever you call here must
|
||||
have the ability to do that. */
|
||||
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
png_voidp ret;
|
||||
#endif
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return ((png_voidp)NULL);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(png_ptr->malloc_fn != NULL)
|
||||
return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
||||
{
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of Memory!");
|
||||
return (ret);
|
||||
}
|
||||
else
|
||||
return (png_malloc_default(png_ptr, size));
|
||||
}
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
@@ -407,16 +437,14 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
#endif
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||
without taking any action. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
@@ -430,7 +458,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||
}
|
||||
else png_free_default(png_ptr, ptr);
|
||||
}
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
@@ -451,7 +479,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
|
||||
png_uint_32 length)
|
||||
{
|
||||
@@ -464,7 +492,7 @@ png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
|
||||
return(png_memcpy (s1, s2, size));
|
||||
}
|
||||
|
||||
png_voidp
|
||||
png_voidp /* PRIVATE */
|
||||
png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
||||
png_uint_32 length)
|
||||
{
|
||||
@@ -482,7 +510,7 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
||||
/* This function is called when the application wants to use another method
|
||||
* of allocating and freeing memory.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
@@ -495,7 +523,7 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_mem_ptr(png_structp png_ptr)
|
||||
{
|
||||
return ((png_voidp)png_ptr->mem_ptr);
|
||||
|
||||
BIN
pngnow.png
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
442
pngpread.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -13,7 +13,18 @@
|
||||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
|
||||
void
|
||||
/* push model modes */
|
||||
#define PNG_READ_SIG_MODE 0
|
||||
#define PNG_READ_CHUNK_MODE 1
|
||||
#define PNG_READ_IDAT_MODE 2
|
||||
#define PNG_SKIP_MODE 3
|
||||
#define PNG_READ_tEXt_MODE 4
|
||||
#define PNG_READ_zTXt_MODE 5
|
||||
#define PNG_READ_DONE_MODE 6
|
||||
#define PNG_READ_iTXt_MODE 7
|
||||
#define PNG_ERROR_MODE 8
|
||||
|
||||
void PNGAPI
|
||||
png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep buffer, png_size_t buffer_size)
|
||||
{
|
||||
@@ -28,7 +39,7 @@ png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||
/* What we do with the incoming data depends on what we were previously
|
||||
* doing before we ran out of data...
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
switch (png_ptr->process_mode)
|
||||
@@ -61,6 +72,13 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||
png_push_read_zTXt(png_ptr, info_ptr);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
case PNG_READ_iTXt_MODE:
|
||||
{
|
||||
png_push_read_iTXt(png_ptr, info_ptr);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case PNG_SKIP_MODE:
|
||||
{
|
||||
@@ -81,7 +99,7 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||
* checked by the calling application, or because of multiple calls to this
|
||||
* routine.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_size_t num_checked = png_ptr->sig_bytes,
|
||||
@@ -113,7 +131,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -133,6 +151,12 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
PNG_hIST;
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
PNG_iCCP;
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
PNG_iTXt;
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
PNG_oFFs;
|
||||
#endif
|
||||
@@ -145,9 +169,15 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
PNG_sBIT;
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
PNG_sCAL;
|
||||
#endif
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
PNG_sRGB;
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
PNG_sPLT;
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
PNG_tEXt;
|
||||
#endif
|
||||
@@ -287,6 +317,30 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
||||
{
|
||||
@@ -359,6 +413,18 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
|
||||
{
|
||||
@@ -382,6 +448,12 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
||||
{
|
||||
png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
@@ -391,14 +463,14 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_crc_skip(png_structp png_ptr, png_uint_32 skip)
|
||||
{
|
||||
png_ptr->process_mode = PNG_SKIP_MODE;
|
||||
png_ptr->skip_length = skip;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_crc_finish(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->skip_length && png_ptr->save_buffer_size)
|
||||
@@ -446,7 +518,7 @@ png_push_crc_finish(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
{
|
||||
png_bytep ptr;
|
||||
@@ -484,7 +556,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_save_buffer(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->save_buffer_size)
|
||||
@@ -528,7 +600,7 @@ png_push_save_buffer(png_structp png_ptr)
|
||||
png_ptr->buffer_size = 0;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
png_size_t buffer_length)
|
||||
{
|
||||
@@ -538,7 +610,7 @@ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
png_ptr->current_buffer_ptr = png_ptr->current_buffer;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_IDAT(png_structp png_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -628,7 +700,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||
png_size_t buffer_length)
|
||||
{
|
||||
@@ -642,23 +714,26 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||
for(;;)
|
||||
{
|
||||
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
||||
if (ret == Z_STREAM_END)
|
||||
if (ret != Z_OK)
|
||||
{
|
||||
if (png_ptr->zstream.avail_in)
|
||||
png_error(png_ptr, "Extra compressed data");
|
||||
if (!(png_ptr->zstream.avail_out))
|
||||
if (ret == Z_STREAM_END)
|
||||
{
|
||||
png_push_process_row(png_ptr);
|
||||
}
|
||||
if (png_ptr->zstream.avail_in)
|
||||
png_error(png_ptr, "Extra compressed data");
|
||||
if (!(png_ptr->zstream.avail_out))
|
||||
{
|
||||
png_push_process_row(png_ptr);
|
||||
}
|
||||
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
break;
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
break;
|
||||
}
|
||||
else if (ret == Z_BUF_ERROR)
|
||||
break;
|
||||
else
|
||||
png_error(png_ptr, "Decompression Error");
|
||||
}
|
||||
else if (ret == Z_BUF_ERROR)
|
||||
break;
|
||||
else if (ret != Z_OK)
|
||||
png_error(png_ptr, "Decompression Error");
|
||||
if (!(png_ptr->zstream.avail_out))
|
||||
{
|
||||
png_push_process_row(png_ptr);
|
||||
@@ -670,7 +745,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_process_row(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->row_info.color_type = png_ptr->color_type;
|
||||
@@ -697,18 +772,42 @@ png_push_process_row(png_structp png_ptr)
|
||||
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
if (png_ptr->pass < 6)
|
||||
/* 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);
|
||||
*/
|
||||
png_do_read_interlace(png_ptr);
|
||||
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 8 && png_ptr->pass == 0; i++)
|
||||
{
|
||||
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */
|
||||
}
|
||||
if (png_ptr->pass == 2) /* pass 1 might be empty */
|
||||
{
|
||||
for (i = 0; i < 4 && png_ptr->pass == 2; i++)
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
}
|
||||
if (png_ptr->pass == 4 && png_ptr->height <= 4)
|
||||
{
|
||||
for (i = 0; i < 2 && png_ptr->pass == 4; i++)
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
}
|
||||
if (png_ptr->pass == 6 && png_ptr->height <= 4)
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -720,7 +819,7 @@ png_push_process_row(png_structp png_ptr)
|
||||
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
if (png_ptr->pass == 2)
|
||||
if (png_ptr->pass == 2) /* skip top 4 generated rows */
|
||||
{
|
||||
for (i = 0; i < 4 && png_ptr->pass == 2; i++)
|
||||
{
|
||||
@@ -743,6 +842,14 @@ png_push_process_row(png_structp png_ptr)
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
if (png_ptr->pass == 4) /* pass 3 might be empty */
|
||||
{
|
||||
for (i = 0; i < 2 && png_ptr->pass == 4; i++)
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
@@ -753,7 +860,7 @@ png_push_process_row(png_structp png_ptr)
|
||||
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
if (png_ptr->pass == 4)
|
||||
if (png_ptr->pass == 4) /* skip top two generated rows */
|
||||
{
|
||||
for (i = 0; i < 2 && png_ptr->pass == 4; i++)
|
||||
{
|
||||
@@ -776,6 +883,11 @@ png_push_process_row(png_structp png_ptr)
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
if (png_ptr->pass == 6) /* pass 5 might be empty */
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
@@ -786,7 +898,7 @@ png_push_process_row(png_structp png_ptr)
|
||||
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
if (png_ptr->pass == 6)
|
||||
if (png_ptr->pass == 6) /* skip top generated row */
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
@@ -812,35 +924,35 @@ png_push_process_row(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_push_finish_row(png_structp png_ptr)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
|
||||
/* start of interlace block */
|
||||
const int png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* offset to next interlace block */
|
||||
const int png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* start of interlace block in the y direction */
|
||||
const int png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* offset to next interlace block in the y direction */
|
||||
const int png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
/* Width of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
const int png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
||||
const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
||||
*/
|
||||
|
||||
|
||||
/* Height of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
const int png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
png_ptr->row_number++;
|
||||
if (png_ptr->row_number < png_ptr->num_rows)
|
||||
return;
|
||||
@@ -853,6 +965,11 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||
do
|
||||
{
|
||||
png_ptr->pass++;
|
||||
if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
|
||||
(png_ptr->pass == 3 && png_ptr->width < 3) ||
|
||||
(png_ptr->pass == 5 && png_ptr->width < 2))
|
||||
png_ptr->pass++;
|
||||
|
||||
if (png_ptr->pass >= 7)
|
||||
break;
|
||||
|
||||
@@ -877,10 +994,11 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
void
|
||||
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
void /* PRIVATE */
|
||||
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
{
|
||||
png_error(png_ptr, "Out of place tEXt");
|
||||
/* to quiet some compiler warnings */
|
||||
@@ -890,7 +1008,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
png_ptr->skip_length = 0; /* This may not be necessary */
|
||||
|
||||
if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */
|
||||
if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
|
||||
{
|
||||
png_warning(png_ptr, "tEXt chunk too large to fit in memory");
|
||||
png_ptr->skip_length = length - (png_uint_32)65535L;
|
||||
@@ -907,7 +1025,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
||||
png_ptr->process_mode = PNG_READ_tEXt_MODE;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
@@ -953,20 +1071,26 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr->key = key;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
text_ptr->lang = (char *)NULL;
|
||||
text_ptr->lang_key = (char *)NULL;
|
||||
#endif
|
||||
text_ptr->text = text;
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, text_ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
void
|
||||
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
void /* PRIVATE */
|
||||
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
{
|
||||
png_error(png_ptr, "Out of place zTXt");
|
||||
/* to quiet some compiler warnings */
|
||||
@@ -995,7 +1119,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
||||
png_ptr->process_mode = PNG_READ_zTXt_MODE;
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
@@ -1076,8 +1200,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
if (text == NULL)
|
||||
{
|
||||
text = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out +
|
||||
key_size + 1));
|
||||
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
|
||||
+ key_size + 1));
|
||||
png_memcpy(text + key_size, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||
png_memcpy(text, key, key_size);
|
||||
@@ -1132,52 +1256,213 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr->key = key;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
text_ptr->lang = (char *)NULL;
|
||||
text_ptr->lang_key = (char *)NULL;
|
||||
#endif
|
||||
text_ptr->text = text;
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, text_ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
void /* PRIVATE */
|
||||
png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
{
|
||||
png_error(png_ptr, "Out of place iTXt");
|
||||
/* to quiet some compiler warnings */
|
||||
if(info_ptr == NULL) return;
|
||||
}
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
png_ptr->skip_length = 0; /* This may not be necessary */
|
||||
|
||||
if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
|
||||
{
|
||||
png_warning(png_ptr, "iTXt chunk too large to fit in memory");
|
||||
png_ptr->skip_length = length - (png_uint_32)65535L;
|
||||
length = (png_uint_32)65535L;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(length+1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
png_ptr->current_text_left = (png_size_t)length;
|
||||
png_ptr->process_mode = PNG_READ_iTXt_MODE;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
{
|
||||
png_size_t text_size;
|
||||
|
||||
if (png_ptr->buffer_size < png_ptr->current_text_left)
|
||||
text_size = png_ptr->buffer_size;
|
||||
else
|
||||
text_size = png_ptr->current_text_left;
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
|
||||
png_ptr->current_text_left -= text_size;
|
||||
png_ptr->current_text_ptr += text_size;
|
||||
}
|
||||
if (!(png_ptr->current_text_left))
|
||||
{
|
||||
png_textp text_ptr;
|
||||
png_charp key;
|
||||
int comp_flag;
|
||||
png_charp lang;
|
||||
png_charp lang_key;
|
||||
png_charp text;
|
||||
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_crc_finish(png_ptr);
|
||||
|
||||
#if defined(PNG_MAX_MALLOC_64K)
|
||||
if (png_ptr->skip_length)
|
||||
return;
|
||||
#endif
|
||||
|
||||
key = png_ptr->current_text;
|
||||
png_ptr->current_text = 0;
|
||||
|
||||
for (lang = key; *lang; lang++)
|
||||
/* empty loop */ ;
|
||||
|
||||
if (lang != key + png_ptr->current_text_size)
|
||||
lang++;
|
||||
|
||||
comp_flag = *lang++;
|
||||
lang++; /* skip comp_type, always zero */
|
||||
|
||||
for (lang_key = lang; *lang_key; lang_key++)
|
||||
/* empty loop */ ;
|
||||
lang_key++; /* skip NUL separator */
|
||||
|
||||
for (text = lang_key; *text; text++)
|
||||
/* empty loop */ ;
|
||||
|
||||
if (text != key + png_ptr->current_text_size)
|
||||
text++;
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = comp_flag + 2;
|
||||
text_ptr->key = key;
|
||||
text_ptr->lang = lang;
|
||||
text_ptr->lang_key = lang_key;
|
||||
text_ptr->text = text;
|
||||
text_ptr->text_length = 0;
|
||||
text_ptr->itxt_length = png_strlen(text);
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_free(png_ptr, text_ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function is called when we haven't found a handler for this
|
||||
* chunk. In the future we will have code here that can handle
|
||||
* user-defined callback functions for unknown chunks before they are
|
||||
* ignored or cause an error. If there isn't a problem with the
|
||||
* chunk itself (ie a bad chunk name or a critical chunk), the chunk
|
||||
* is (currently) silently ignored.
|
||||
* chunk. If there isn't a problem with the chunk itself (ie a bad chunk
|
||||
* name or a critical chunk), the chunk is (currently) silently ignored.
|
||||
*/
|
||||
void
|
||||
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
void /* PRIVATE */
|
||||
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
png_uint_32 skip=0;
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
{
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
/* to quiet some compiler warnings */
|
||||
if(info_ptr == NULL) return;
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
HANDLE_CHUNK_ALWAYS
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
&& png_ptr->read_user_chunk_fn == NULL
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
|
||||
/* to quiet compiler warnings about unused info_ptr */
|
||||
if (info_ptr == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_crc_skip(png_ptr, length);
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
|
||||
{
|
||||
png_unknown_chunk chunk;
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (length > (png_uint_32)65535L)
|
||||
{
|
||||
png_warning(png_ptr, "unknown chunk too large to fit in memory");
|
||||
skip = length - (png_uint_32)65535L;
|
||||
length = (png_uint_32)65535L;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
|
||||
chunk.data = (png_bytep)png_malloc(png_ptr, length);
|
||||
png_crc_read(png_ptr, chunk.data, length);
|
||||
chunk.size = length;
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
if(png_ptr->read_user_chunk_fn != NULL)
|
||||
{
|
||||
/* callback to user unknown chunk handler */
|
||||
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
|
||||
{
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
HANDLE_CHUNK_ALWAYS)
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
}
|
||||
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
|
||||
png_free(png_ptr, chunk.data);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
skip=length;
|
||||
png_push_crc_skip(png_ptr, skip);
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_have_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr->info_fn != NULL)
|
||||
(*(png_ptr->info_fn))(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_have_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr->end_fn != NULL)
|
||||
(*(png_ptr->end_fn))(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_push_have_row(png_structp png_ptr, png_bytep row)
|
||||
{
|
||||
if (png_ptr->row_fn != NULL)
|
||||
@@ -1185,18 +1470,19 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
|
||||
(int)png_ptr->pass);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_progressive_combine_row (png_structp png_ptr,
|
||||
png_bytep old_row, png_bytep new_row)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
const int FARDATA png_pass_dsp_mask[7] =
|
||||
{0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
#endif
|
||||
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
|
||||
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
||||
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
||||
png_progressive_end_ptr end_fn)
|
||||
@@ -1208,7 +1494,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
||||
png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
|
||||
}
|
||||
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_progressive_ptr(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->io_ptr;
|
||||
|
||||
491
pngread.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "png.h"
|
||||
|
||||
/* Create a PNG structure for reading, and allocate any memory needed. */
|
||||
png_structp
|
||||
png_structp PNGAPI
|
||||
png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
}
|
||||
|
||||
/* Alternate create PNG structure for reading, and allocate any memory needed. */
|
||||
png_structp
|
||||
png_structp PNGAPI
|
||||
png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
|
||||
png_malloc_ptr malloc_fn, png_free_ptr free_fn)
|
||||
@@ -34,19 +34,27 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
png_structp png_ptr;
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
jmp_buf jmpbuf;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_create_read_struct\n");
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
|
||||
(png_malloc_ptr)malloc_fn)) == NULL)
|
||||
(png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL)
|
||||
#else
|
||||
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
|
||||
#endif
|
||||
{
|
||||
return (png_structp)NULL;
|
||||
}
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
#else
|
||||
@@ -54,29 +62,56 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_ptr->zbuf=NULL;
|
||||
png_destroy_struct(png_ptr);
|
||||
return (png_structp)NULL;
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif
|
||||
|
||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||
|
||||
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||
* we must recompile any applications that use any older library version.
|
||||
* For versions after libpng 1.0, we will be compatible, so we need
|
||||
* only check the first digit.
|
||||
*/
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
|
||||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
|
||||
i=0;
|
||||
do
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Incompatible libpng version in application and library");
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
|
||||
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
||||
{
|
||||
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||
* we must recompile any applications that use any older library version.
|
||||
* For versions after libpng 1.0, we will be compatible, so we need
|
||||
* only check the first digit.
|
||||
*/
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
|
||||
(user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
|
||||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Incompatible libpng version in application and library");
|
||||
}
|
||||
|
||||
/* Libpng 1.0.6 was not binary compatible, due to insertion of the
|
||||
info_ptr->free_me member. Libpng-1.0.1 and earlier were not
|
||||
compatible due to insertion of the user transform function. Note
|
||||
to maintainer: this test can be removed from version 1.2.0 and
|
||||
beyond because the previous test would have already rejected it. */
|
||||
|
||||
if (user_png_ver[0] == '1' && user_png_ver[2] == '0' &&
|
||||
(user_png_ver[4] < '2' || user_png_ver[4] == '6') &&
|
||||
user_png_ver[5] == '\0')
|
||||
{
|
||||
png_error(png_ptr,
|
||||
"Application must be recompiled; versions <= 1.0.6 were incompatible");
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
@@ -107,20 +142,83 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
/* Initialize PNG structure for reading, and allocate any memory needed.
|
||||
This interface is deprecated in favour of the png_create_read_struct(),
|
||||
and it will eventually disappear. */
|
||||
void
|
||||
#undef png_read_init
|
||||
void PNGAPI
|
||||
png_read_init(png_structp png_ptr)
|
||||
{
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
/* We only come here via pre-1.0.7-compiled applications */
|
||||
png_read_init_2(png_ptr, "1.0.0", 0, 0);
|
||||
}
|
||||
|
||||
png_debug(1, "in png_read_init\n");
|
||||
#undef png_read_init_2
|
||||
void PNGAPI
|
||||
png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
||||
png_size_t png_struct_size, png_size_t png_info_size)
|
||||
{
|
||||
/* We only come here via pre-1.0.12-compiled applications */
|
||||
if(sizeof(png_struct) > png_struct_size)
|
||||
{
|
||||
png_ptr->error_fn=(png_error_ptr)NULL;
|
||||
png_error(png_ptr,
|
||||
"The png struct allocated by the application for reading is too small.");
|
||||
}
|
||||
if(sizeof(png_info) > png_info_size)
|
||||
{
|
||||
png_ptr->error_fn=(png_error_ptr)NULL;
|
||||
png_error(png_ptr,
|
||||
"The info struct allocated by application for reading is too small.");
|
||||
}
|
||||
png_read_init_3(&png_ptr, user_png_ver, png_struct_size);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
||||
png_size_t png_struct_size)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
#endif
|
||||
|
||||
int i=0;
|
||||
|
||||
png_structp png_ptr=*ptr_ptr;
|
||||
|
||||
do
|
||||
{
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
{
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
#else
|
||||
png_ptr->warning_fn=(png_error_ptr)NULL;
|
||||
png_warning(png_ptr,
|
||||
"Application uses deprecated png_read_init() and should be recompiled.");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
} while (png_libpng_ver[i++]);
|
||||
|
||||
png_debug(1, "in png_read_init_3\n");
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* save jump buffer and error functions */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
if(sizeof(png_struct) > png_struct_size)
|
||||
{
|
||||
png_destroy_struct(png_ptr);
|
||||
*ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
|
||||
png_ptr = *ptr_ptr;
|
||||
}
|
||||
|
||||
/* reset all variables to 0 */
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* restore jump buffer */
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
@@ -153,7 +251,7 @@ png_read_init(png_structp png_ptr)
|
||||
* here. The application can then have access to the signature bytes we
|
||||
* read if it is determined that this isn't a valid PNG file.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_info\n");
|
||||
@@ -175,6 +273,8 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
else
|
||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||
}
|
||||
if (num_checked < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
|
||||
for(;;)
|
||||
@@ -196,6 +296,12 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
PNG_hIST;
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
PNG_iCCP;
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
PNG_iTXt;
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
PNG_oFFs;
|
||||
#endif
|
||||
@@ -208,6 +314,12 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
PNG_sBIT;
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
PNG_sCAL;
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
PNG_sPLT;
|
||||
#endif
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
PNG_sRGB;
|
||||
#endif
|
||||
@@ -233,7 +345,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
|
||||
png_debug2(0, "Reading %s chunk, length=%d.\n", png_ptr->chunk_name,
|
||||
png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
|
||||
length);
|
||||
|
||||
/* This should be a binary subdivision search or a hash for
|
||||
@@ -241,10 +353,29 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
*/
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
||||
{
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
@@ -281,6 +412,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
||||
png_handle_pCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
||||
png_handle_sCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
||||
png_handle_pHYs(png_ptr, info_ptr, length);
|
||||
@@ -293,6 +428,14 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
||||
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
||||
png_handle_iCCP(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
||||
png_handle_sPLT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||
@@ -308,6 +451,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
||||
png_handle_zTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
||||
png_handle_iTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
else
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
@@ -315,13 +462,16 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
/* optional call to update the users info_ptr structure */
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_update_info\n");
|
||||
/* save jump buffer and error functions */
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
png_read_start_row(png_ptr);
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Ignoring extra png_read_update_info() call; row buffer not reallocated");
|
||||
png_read_transform_info(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
@@ -330,7 +480,7 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||
* the user to obtain a gamma-corrected palette, for example.
|
||||
* If the user doesn't call this, we will do it ourselves.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_start_read_image(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_start_read_image\n");
|
||||
@@ -339,7 +489,7 @@ png_start_read_image(png_structp png_ptr)
|
||||
png_read_start_row(png_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -348,7 +498,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
#endif
|
||||
int ret;
|
||||
png_debug2(1, "in png_read_row (row %d, pass %d)\n",
|
||||
png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
|
||||
png_ptr->row_number, png_ptr->pass);
|
||||
/* save jump buffer and error functions */
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
@@ -393,7 +543,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
case 0:
|
||||
if (png_ptr->row_number & 7)
|
||||
if (png_ptr->row_number & 0x07)
|
||||
{
|
||||
if (dsp_row != NULL)
|
||||
png_combine_row(png_ptr, dsp_row,
|
||||
@@ -403,7 +553,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ((png_ptr->row_number & 7) || png_ptr->width < 5)
|
||||
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
|
||||
{
|
||||
if (dsp_row != NULL)
|
||||
png_combine_row(png_ptr, dsp_row,
|
||||
@@ -413,7 +563,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ((png_ptr->row_number & 7) != 4)
|
||||
if ((png_ptr->row_number & 0x07) != 4)
|
||||
{
|
||||
if (dsp_row != NULL && (png_ptr->row_number & 4))
|
||||
png_combine_row(png_ptr, dsp_row,
|
||||
@@ -518,12 +668,22 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
|
||||
if(png_ptr->row_buf[0])
|
||||
png_read_filter_row(png_ptr, &(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||
(int)(png_ptr->row_buf[0]));
|
||||
|
||||
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
|
||||
png_ptr->rowbytes + 1);
|
||||
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
{
|
||||
/* Intrapixel differencing */
|
||||
png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (png_ptr->transformations)
|
||||
png_do_read_transformations(png_ptr);
|
||||
@@ -534,8 +694,11 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
(png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
if (png_ptr->pass < 6)
|
||||
/* 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);
|
||||
*/
|
||||
png_do_read_interlace(png_ptr);
|
||||
|
||||
if (dsp_row != NULL)
|
||||
png_combine_row(png_ptr, dsp_row,
|
||||
@@ -579,10 +742,10 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
* 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 libpng version 1.0.5d.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.12beta1
|
||||
*/
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
png_bytepp display_row, png_uint_32 num_rows)
|
||||
{
|
||||
@@ -628,9 +791,9 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
* 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 libpng version 1.0.5d.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.12beta1
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
{
|
||||
png_uint_32 i,image_height;
|
||||
@@ -668,7 +831,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
@@ -697,6 +860,12 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
PNG_hIST;
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
PNG_iCCP;
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
PNG_iTXt;
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
PNG_oFFs;
|
||||
#endif
|
||||
@@ -709,6 +878,12 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
PNG_sBIT;
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
PNG_sCAL;
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
PNG_sPLT;
|
||||
#endif
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
PNG_sRGB;
|
||||
#endif
|
||||
@@ -736,6 +911,23 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
||||
{
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_error(png_ptr, "Too many IDAT's found");
|
||||
}
|
||||
else
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
}
|
||||
#endif
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
{
|
||||
/* Zero length IDATs are legal after the last IDAT has been
|
||||
@@ -743,13 +935,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
*/
|
||||
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_error(png_ptr, "Too many IDAT's found");
|
||||
else
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_crc_finish(png_ptr, length);
|
||||
}
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
||||
png_handle_bKGD(png_ptr, info_ptr, length);
|
||||
@@ -774,6 +963,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
||||
png_handle_pCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
||||
png_handle_sCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
||||
png_handle_pHYs(png_ptr, info_ptr, length);
|
||||
@@ -786,6 +979,14 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
||||
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
||||
png_handle_iCCP(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
||||
png_handle_sPLT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||
@@ -801,6 +1002,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
||||
png_handle_zTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
||||
png_handle_iTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
else
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
@@ -808,7 +1013,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
}
|
||||
|
||||
/* free all memory used by the read */
|
||||
void
|
||||
void PNGAPI
|
||||
png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
png_infopp end_info_ptr_ptr)
|
||||
{
|
||||
@@ -816,7 +1021,8 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
png_infop info_ptr = NULL, end_info_ptr = NULL;
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_free_ptr free_fn = NULL;
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_voidp mem_ptr = NULL;
|
||||
#endif
|
||||
|
||||
png_debug(1, "in png_destroy_read_struct\n");
|
||||
/* save jump buffer and error functions */
|
||||
@@ -831,18 +1037,20 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
free_fn = png_ptr->free_fn;
|
||||
mem_ptr = png_ptr->mem_ptr;
|
||||
#endif
|
||||
|
||||
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
|
||||
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
|
||||
png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
|
||||
(png_voidp)mem_ptr);
|
||||
#else
|
||||
png_destroy_struct((png_voidp)info_ptr);
|
||||
#endif
|
||||
@@ -851,11 +1059,12 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
|
||||
if (end_info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_free(png_ptr, end_info_ptr->text);
|
||||
#if defined(PNG_READ_TEXT_SUPPORTED)
|
||||
png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1);
|
||||
#endif
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)end_info_ptr, free_fn);
|
||||
png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn,
|
||||
(png_voidp)mem_ptr);
|
||||
#else
|
||||
png_destroy_struct((png_voidp)end_info_ptr);
|
||||
#endif
|
||||
@@ -865,7 +1074,8 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)png_ptr, free_fn);
|
||||
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
|
||||
(png_voidp)mem_ptr);
|
||||
#else
|
||||
png_destroy_struct((png_voidp)png_ptr);
|
||||
#endif
|
||||
@@ -874,10 +1084,12 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
}
|
||||
|
||||
/* free all memory used by the read (old method) */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf tmp_jmp;
|
||||
#endif
|
||||
png_error_ptr error_fn;
|
||||
png_error_ptr warning_fn;
|
||||
png_voidp error_ptr;
|
||||
@@ -907,16 +1119,37 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_from_1);
|
||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||
#endif
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_PLTE)
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED) || \
|
||||
png_ptr->free_me &= ~PNG_FREE_PLTE;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_PLTE)
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
|
||||
#endif
|
||||
#if defined(PNG_tRNS_SUPPORTED) || \
|
||||
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_TRNS)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
png_ptr->free_me &= ~PNG_FREE_TRNS;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_TRNS)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_HIST)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
png_ptr->free_me &= ~PNG_FREE_HIST;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
@@ -954,7 +1187,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
#endif
|
||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->time_buffer);
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif
|
||||
|
||||
inflateEnd(&png_ptr->zstream);
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
@@ -964,7 +1197,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
/* Save the important info out of the png_struct, in case it is
|
||||
* being used again.
|
||||
*/
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
error_fn = png_ptr->error_fn;
|
||||
warning_fn = png_ptr->warning_fn;
|
||||
@@ -982,11 +1217,157 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_ptr->free_fn = free_fn;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
||||
{
|
||||
png_ptr->read_row_fn = read_row_fn;
|
||||
}
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||
int transforms,
|
||||
voidp params)
|
||||
{
|
||||
int row;
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
/* invert the alpha channel from opacity to transparency */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||
png_set_invert_alpha(png_ptr);
|
||||
#endif
|
||||
|
||||
/* The call to png_read_info() gives us all of the information from the
|
||||
* PNG file before the first IDAT (image data chunk).
|
||||
*/
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
/* -------------- image transformations start here ------------------- */
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
|
||||
if (transforms & PNG_TRANSFORM_STRIP_16)
|
||||
png_set_strip_16(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
/* Strip alpha bytes from the input data without combining with the
|
||||
* background (not recommended).
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
|
||||
png_set_strip_alpha(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
|
||||
* byte into separate bytes (useful for paletted and grayscale images).
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_PACKING)
|
||||
png_set_packing(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
/* Change the order of packed pixels to least significant bit first
|
||||
* (not useful if you are using png_set_packing). */
|
||||
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
||||
png_set_packswap(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
/* 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.
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_EXPAND)
|
||||
if ((png_ptr->bit_depth < 8) ||
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
|
||||
(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
|
||||
png_set_expand(png_ptr);
|
||||
#endif
|
||||
|
||||
/* We don't handle background color or gamma transformation or dithering. */
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED)
|
||||
/* invert monochrome files to have 0 as white and 1 as black */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||
png_set_invert_mono(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
/* 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:
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_SHIFT)
|
||||
&& png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
|
||||
{
|
||||
png_color_8p sig_bit;
|
||||
|
||||
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
|
||||
png_set_shift(png_ptr, sig_bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED)
|
||||
/* flip the RGB pixels to BGR (or RGBA to BGRA) */
|
||||
if (transforms & PNG_TRANSFORM_BGR)
|
||||
png_set_bgr(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
|
||||
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||
png_set_swap_alpha(png_ptr);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED)
|
||||
/* swap bytes of 16 bit files to least significant byte first */
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||
png_set_swap(png_ptr);
|
||||
#endif
|
||||
|
||||
/* We don't handle adding filler bytes */
|
||||
|
||||
/* 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).
|
||||
*/
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
/* -------------- image transformations end here ------------------- */
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
#endif
|
||||
if(info_ptr->row_pointers == NULL)
|
||||
{
|
||||
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
||||
info_ptr->height * sizeof(png_bytep));
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_ROWS;
|
||||
#endif
|
||||
for (row = 0; row < (int)info_ptr->height; row++)
|
||||
{
|
||||
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
|
||||
png_get_rowbytes(png_ptr, info_ptr));
|
||||
}
|
||||
}
|
||||
|
||||
png_read_image(png_ptr, info_ptr->row_pointers);
|
||||
info_ptr->valid |= PNG_INFO_IDAT;
|
||||
|
||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
|
||||
if(transforms == 0 || params == NULL)
|
||||
/* quiet compiler warnings */ return;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
45
pngrio.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file provides a location for all input. Users who need
|
||||
* special handling are expected to write a function that has the same
|
||||
@@ -23,10 +23,10 @@
|
||||
with very small lengths, so you should implement some kind of simple
|
||||
buffering if you are using unbuffered reads. This should never be asked
|
||||
to read more then 64K on a 16 bit machine. */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4,"reading %d bytes\n", length);
|
||||
png_debug1(4,"reading %d bytes\n", (int)length);
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||
else
|
||||
@@ -39,7 +39,7 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
read_data function and use it at run time with png_set_read_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
@@ -47,13 +47,16 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||
check = 0;
|
||||
#else
|
||||
check = (png_size_t)fread(data, (png_size_t)1, length,
|
||||
(FILE *)png_ptr->io_ptr);
|
||||
(png_FILE_p)png_ptr->io_ptr);
|
||||
#endif
|
||||
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* this is the model-independent version. Since the standard I/O library
|
||||
@@ -64,19 +67,24 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
int check;
|
||||
png_byte *n_data;
|
||||
FILE *io_ptr;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (FILE *)CVT_PTR(png_ptr->io_ptr);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||
check = 0;
|
||||
#else
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -87,7 +95,12 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
|
||||
err = 0;
|
||||
#else
|
||||
err = fread(buf, (png_size_t)1, read, io_ptr);
|
||||
#endif
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
if(err != read)
|
||||
break;
|
||||
@@ -99,9 +112,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
while (remaining != 0);
|
||||
}
|
||||
if ((png_uint_32)check != (png_uint_32)length)
|
||||
{
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -119,7 +130,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
unsigned int that is the number of bytes to be read.
|
||||
To exit and output any fatal error messages the new write
|
||||
function should call png_error(png_ptr, "Error msg"). */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
@@ -146,6 +157,6 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
367
pngrtran.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file contains functions optionally called by an application
|
||||
* in order to tell libpng how to handle data when reading a PNG.
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "png.h"
|
||||
|
||||
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
||||
{
|
||||
png_debug(1, "in png_set_crc_action\n");
|
||||
@@ -69,9 +69,10 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* handle alpha and tRNS via a background color */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_background(png_structp png_ptr,
|
||||
png_color_16p background_color, int background_gamma_code,
|
||||
int need_expand, double background_gamma)
|
||||
@@ -104,7 +105,7 @@ png_set_background(png_structp png_ptr,
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
/* strip 16 bit depth files to 8 bit depth */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_strip_16(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_16\n");
|
||||
@@ -113,7 +114,7 @@ png_set_strip_16(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_strip_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_alpha\n");
|
||||
@@ -140,7 +141,7 @@ typedef struct png_dsort_struct
|
||||
typedef png_dsort FAR * png_dsortp;
|
||||
typedef png_dsort FAR * FAR * png_dsortpp;
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette, int maximum_colors, png_uint_16p histogram,
|
||||
int full_dither)
|
||||
@@ -366,7 +367,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
int j, next_j;
|
||||
|
||||
if (num_new_palette & 1)
|
||||
if (num_new_palette & 0x01)
|
||||
{
|
||||
j = p->left;
|
||||
next_j = p->right;
|
||||
@@ -504,13 +505,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* Transform the image from the file_gamma to the screen_gamma. We
|
||||
* only do transformations on images where the file_gamma and screen_gamma
|
||||
* are not close reciprocals, otherwise it slows things down slightly, and
|
||||
* also needlessly introduces small errors.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_gamma\n");
|
||||
@@ -526,7 +527,7 @@ png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks
|
||||
* to alpha channels.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_expand(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
@@ -548,7 +549,7 @@ png_set_expand(png_structp png_ptr)
|
||||
*/
|
||||
|
||||
/* Expand paletted images to RGB. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_palette_to_rgb(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
@@ -556,7 +557,7 @@ png_set_palette_to_rgb(png_structp png_ptr)
|
||||
}
|
||||
|
||||
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_gray_1_2_4_to_8(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
@@ -564,7 +565,7 @@ png_set_gray_1_2_4_to_8(png_structp png_ptr)
|
||||
}
|
||||
|
||||
/* Expand tRNS chunks to alpha channels. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_tRNS_to_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
@@ -573,7 +574,7 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
|
||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_gray_to_rgb(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_gray_to_rgb\n");
|
||||
@@ -582,12 +583,24 @@ png_set_gray_to_rgb(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* Convert a RGB image to a grayscale of the same width. This allows us,
|
||||
* for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
|
||||
*/
|
||||
void
|
||||
|
||||
void PNGAPI
|
||||
png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
||||
double green)
|
||||
double green)
|
||||
{
|
||||
int red_fixed = (int)((float)red*100000.0 + 0.5);
|
||||
int green_fixed = (int)((float)green*100000.0 + 0.5);
|
||||
png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||
png_fixed_point red, png_fixed_point green)
|
||||
{
|
||||
png_debug(1, "in png_set_rgb_to_gray\n");
|
||||
switch(error_action)
|
||||
@@ -608,41 +621,54 @@ png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
||||
}
|
||||
#endif
|
||||
{
|
||||
png_byte red_byte = (png_byte)((float)red*255.0 + 0.5);
|
||||
png_byte green_byte = (png_byte)((float)green*255.0 + 0.5);
|
||||
if(red < 0.0 || green < 0.0)
|
||||
png_uint_16 red_int, green_int;
|
||||
if(red < 0 || green < 0)
|
||||
{
|
||||
red_byte = 54;
|
||||
green_byte = 183;
|
||||
red_int = 6968; /* .212671 * 32768 + .5 */
|
||||
green_int = 23434; /* .715160 * 32768 + .5 */
|
||||
}
|
||||
else if(red_byte + green_byte > 255)
|
||||
else if(red + green < 100000L)
|
||||
{
|
||||
red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L);
|
||||
green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients");
|
||||
red_byte = 54;
|
||||
green_byte = 183;
|
||||
red_int = 6968;
|
||||
green_int = 23434;
|
||||
}
|
||||
png_ptr->rgb_to_gray_red_coeff = red_byte;
|
||||
png_ptr->rgb_to_gray_green_coeff = green_byte;
|
||||
png_ptr->rgb_to_gray_blue_coeff = (png_byte)(255-red_byte-green_byte);
|
||||
png_ptr->rgb_to_gray_red_coeff = red_int;
|
||||
png_ptr->rgb_to_gray_green_coeff = green_int;
|
||||
png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
read_user_transform_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_transform_fn\n");
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||
#endif
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
if(read_user_transform_fn)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transforms");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize everything needed for the read. This includes modifying
|
||||
* the palette.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_init_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_init_read_transformations\n");
|
||||
@@ -656,7 +682,8 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
(png_ptr->transformations & PNG_EXPAND))
|
||||
{
|
||||
if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */
|
||||
{
|
||||
@@ -718,7 +745,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_ptr->background_1 = png_ptr->background;
|
||||
#endif
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY))
|
||||
{
|
||||
png_build_gamma_table(png_ptr);
|
||||
@@ -731,7 +758,6 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
png_colorp palette = png_ptr->palette;
|
||||
int num_palette = png_ptr->num_palette;
|
||||
int i;
|
||||
|
||||
if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)
|
||||
{
|
||||
back.red = png_ptr->gamma_table[png_ptr->background.red];
|
||||
@@ -789,7 +815,6 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
back_1.blue = (png_byte)(pow(
|
||||
(double)png_ptr->background.blue/255, g) * 255.0 + .5);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff)
|
||||
@@ -897,8 +922,8 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* No GAMMA transformation */
|
||||
if (png_ptr->transformations & PNG_BACKGROUND &&
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND) &&
|
||||
(color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
int i;
|
||||
int istop = (int)png_ptr->num_trans;
|
||||
@@ -931,7 +956,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_SHIFT) &&
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
(color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
png_uint_16 i;
|
||||
png_uint_16 istop = png_ptr->num_palette;
|
||||
@@ -954,13 +979,18 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \
|
||||
&& !defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if(png_ptr)
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Modify the info structure to reflect the transformations. The
|
||||
* info should be updated so a PNG file could be written with it,
|
||||
* assuming the transformations result in valid PNG data.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_transform_info\n");
|
||||
@@ -998,11 +1028,18 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_GAMMA)
|
||||
{
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
info_ptr->gamma = png_ptr->gamma;
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
info_ptr->int_gamma = png_ptr->int_gamma;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) && info_ptr->bit_depth == 16)
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16))
|
||||
info_ptr->bit_depth = 8;
|
||||
#endif
|
||||
|
||||
@@ -1019,7 +1056,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_PACK) && info_ptr->bit_depth < 8)
|
||||
if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
|
||||
info_ptr->bit_depth = 8;
|
||||
#endif
|
||||
|
||||
@@ -1050,13 +1087,19 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
/* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */
|
||||
if (png_ptr->transformations & PNG_FILLER &&
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_GRAY))
|
||||
if ((png_ptr->transformations & PNG_FILLER) &&
|
||||
((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))
|
||||
{
|
||||
info_ptr->channels++;
|
||||
#if 0 /* if adding a true alpha channel not just filler */
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
|
||||
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if(png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
{
|
||||
if(info_ptr->bit_depth < png_ptr->user_transform_depth)
|
||||
@@ -1070,20 +1113,24 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
info_ptr->bit_depth);
|
||||
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
|
||||
|
||||
#if !defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
if(png_ptr)
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Transform the row. The order of transformations is significant,
|
||||
* and is very touchy. If you add a transformation, take care to
|
||||
* decide how it fits in with the other transformations here.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_do_read_transformations\n");
|
||||
#if !defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||
if (png_ptr->row_buf == NULL)
|
||||
{
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
||||
char msg[50];
|
||||
|
||||
sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number,
|
||||
@@ -1170,7 +1217,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
/* if gray -> RGB, do so now only if background is non-gray; else do later
|
||||
* for performance reasons */
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB &&
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
!(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
@@ -1244,8 +1291,8 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
/* if gray -> RGB, do so now only if we did not do so above */
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB &&
|
||||
png_ptr->mode & PNG_BACKGROUND_IS_GRAY)
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
@@ -1284,13 +1331,15 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
if(png_ptr->user_transform_depth)
|
||||
png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
|
||||
if(png_ptr->user_transform_channels)
|
||||
png_ptr->row_info.channels = png_ptr->user_transform_channels;
|
||||
#endif
|
||||
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
||||
png_ptr->row_info.channels);
|
||||
png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
|
||||
png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
|
||||
png_ptr->row_info.pixel_depth+7)>>3;
|
||||
}
|
||||
#endif
|
||||
@@ -1304,7 +1353,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
* the numbers 0 or 1. If you would rather they contain 0 and 255, use
|
||||
* png_do_shift() after this.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_unpack\n");
|
||||
@@ -1323,10 +1372,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = 7 - (int)((row_width + 7) & 7);
|
||||
png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x1);
|
||||
*dp = (png_byte)((*sp >> shift) & 0x01);
|
||||
if (shift == 7)
|
||||
{
|
||||
shift = 0;
|
||||
@@ -1344,10 +1393,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = (int)((3 - ((row_width + 3) & 3)) << 1);
|
||||
png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x3);
|
||||
*dp = (png_byte)((*sp >> shift) & 0x03);
|
||||
if (shift == 6)
|
||||
{
|
||||
shift = 0;
|
||||
@@ -1364,10 +1413,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = (int)((1 - ((row_width + 1) & 1)) << 2);
|
||||
png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0xf);
|
||||
*dp = (png_byte)((*sp >> shift) & 0x0f);
|
||||
if (shift == 4)
|
||||
{
|
||||
shift = 0;
|
||||
@@ -1394,7 +1443,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
* a row of bit depth 8, but only 5 are significant, this will shift
|
||||
* the values back to 0 through 31.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
{
|
||||
png_debug(1, "in png_do_unshift\n");
|
||||
@@ -1500,7 +1549,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
/* chop rows of bit depth 16 down to 8 */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_chop\n");
|
||||
@@ -1554,7 +1603,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_read_swap_alpha\n");
|
||||
@@ -1646,7 +1695,7 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_read_invert_alpha\n");
|
||||
@@ -1667,9 +1716,15 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
|
||||
/* This does nothing:
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
We can replace it with:
|
||||
*/
|
||||
sp-=3;
|
||||
dp=sp;
|
||||
}
|
||||
}
|
||||
/* This inverts the alpha channel in RRGGBBAA */
|
||||
@@ -1683,12 +1738,18 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
|
||||
/* This does nothing:
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
We can replace it with:
|
||||
*/
|
||||
sp-=6;
|
||||
dp=sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1718,8 +1779,12 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
/*
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*/
|
||||
sp-=2;
|
||||
dp=sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1729,7 +1794,7 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
/* Add filler channel if we have RGB color */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
png_uint_32 filler, png_uint_32 flags)
|
||||
{
|
||||
@@ -1905,7 +1970,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
/* expand grayscale files to RGB, with or without alpha */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_uint_32 i;
|
||||
@@ -1988,7 +2053,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
/* reduce RGB files to grayscale, with or without alpha
|
||||
/* reduce RGB files to grayscale, with or without alpha
|
||||
* using the equation given in Poynton's ColorFAQ at
|
||||
* <http://www.inforamp.net/~poynton/>
|
||||
* Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
|
||||
@@ -1996,18 +2061,18 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
* Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
|
||||
*
|
||||
* We approximate this with
|
||||
*
|
||||
* Y = 0.211 * R + 0.715 * G + 0.074 * B
|
||||
*
|
||||
* Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
|
||||
*
|
||||
* which can be expressed with integers as
|
||||
*
|
||||
* Y = (54 * R + 183 * G + 19 * B)/256
|
||||
* Y = (6969 * R + 23434 * G + 2365 * B)/32768
|
||||
*
|
||||
* The calculation is to be done in a linear colorspace.
|
||||
*
|
||||
* Other integer coefficents can be used via png_set_rgb_to_gray().
|
||||
*/
|
||||
int
|
||||
int /* PRIVATE */
|
||||
png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
{
|
||||
@@ -2023,9 +2088,9 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
png_byte rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
png_byte gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
png_byte bc = png_ptr->rgb_to_gray_blue_coeff;
|
||||
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
@@ -2046,7 +2111,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
*(dp++) = png_ptr->gamma_from_1[
|
||||
(rc*red+gc*green+bc*blue)>>8];
|
||||
(rc*red+gc*green+bc*blue)>>15];
|
||||
}
|
||||
else
|
||||
*(dp++) = *(sp-1);
|
||||
@@ -2065,14 +2130,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
if(red != green || red != blue)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
*(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>8);
|
||||
*(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15);
|
||||
}
|
||||
else
|
||||
*(dp++) = *(sp-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else /* RGB bit_depth == 16 */
|
||||
{
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
@@ -2097,15 +2162,15 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
png_ptr->gamma_shift][red>>8];
|
||||
png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >>
|
||||
png_ptr->gamma_shift][green>>8];
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
||||
png_ptr->gamma_shift][blue>>8];
|
||||
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
|
||||
+ bc*blue_1)>>8);
|
||||
+ bc*blue_1)>>15);
|
||||
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
||||
png_ptr->gamma_shift][gray16 >> 8];
|
||||
rgb_error |= 1;
|
||||
}
|
||||
|
||||
|
||||
*(dp++) = (png_byte)((w>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(w & 0xff);
|
||||
}
|
||||
@@ -2125,7 +2190,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
if(red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>8);
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||
}
|
||||
@@ -2149,7 +2214,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
if(red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
*(dp++) = png_ptr->gamma_from_1
|
||||
[(rc*red + gc*green + bc*blue)>>8];
|
||||
[(rc*red + gc*green + bc*blue)>>15];
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
}
|
||||
}
|
||||
@@ -2194,15 +2259,15 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
png_ptr->gamma_shift][red>>8];
|
||||
png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >>
|
||||
png_ptr->gamma_shift][green>>8];
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
||||
png_ptr->gamma_shift][blue>>8];
|
||||
png_uint_16 gray16 = (png_uint_16)((rc * red_1
|
||||
+ gc * green_1 + bc * blue_1)>>8);
|
||||
+ gc * green_1 + bc * blue_1)>>15);
|
||||
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
||||
png_ptr->gamma_shift][gray16 >> 8];
|
||||
rgb_error |= 1;
|
||||
}
|
||||
|
||||
|
||||
*(dp++) = (png_byte)((w>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(w & 0xff);
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
@@ -2222,7 +2287,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
|
||||
if(red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>8);
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
@@ -2247,7 +2312,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
* paletted. Most useful for gamma correction and simplification
|
||||
* of code.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
{
|
||||
int num_palette;
|
||||
@@ -2293,12 +2358,13 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
|
||||
/* This function is currently unused. Do we really need it? */
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_correct_palette(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette)
|
||||
{
|
||||
png_debug(1, "in png_correct_palette\n");
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND))
|
||||
{
|
||||
png_color back, back_1;
|
||||
@@ -2477,7 +2543,7 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
|
||||
* "background" is already in the screen gamma, while "background_1" is
|
||||
* at a gamma of 1.0. Paletted files have already been taken care of.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_background(png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_values, png_color_16p background,
|
||||
png_color_16p background_1,
|
||||
@@ -2510,7 +2576,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 7;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0x1)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x01)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
|
||||
@@ -2535,7 +2601,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 6;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0x3)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x03)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
@@ -2543,9 +2609,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0x3);
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0x03);
|
||||
png_byte g = (png_byte)((gamma_table [p | (p << 2) |
|
||||
(p << 4) | (p << 6)] >> 6) & 0x3);
|
||||
(p << 4) | (p << 6)] >> 6) & 0x03);
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(g << shift);
|
||||
}
|
||||
@@ -2565,7 +2631,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 6;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0x3)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x03)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
@@ -2591,7 +2657,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 4;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0xf)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
@@ -2599,9 +2665,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0xf);
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0x0f);
|
||||
png_byte g = (png_byte)((gamma_table[p |
|
||||
(p << 4)] >> 4) & 0xf);
|
||||
(p << 4)] >> 4) & 0x0f);
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(g << shift);
|
||||
}
|
||||
@@ -2621,7 +2687,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 4;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((png_uint_16)((*sp >> shift) & 0xf)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
@@ -3148,7 +3214,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
* is 16, use gamma_16_table and gamma_shift. Build these with
|
||||
* build_gamma_table().
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
png_bytep gamma_table, png_uint_16pp gamma_16_table,
|
||||
int gamma_shift)
|
||||
@@ -3330,7 +3396,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
/* Expands a palette row to an RGB or RGBA row depending
|
||||
* upon whether you supply trans and num_trans.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
png_colorp palette, png_bytep trans, int num_trans)
|
||||
{
|
||||
@@ -3354,10 +3420,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = 7 - (int)((row_width + 7) & 7);
|
||||
shift = 7 - (int)((row_width + 7) & 0x07);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((*sp >> shift) & 0x1)
|
||||
if ((*sp >> shift) & 0x01)
|
||||
*dp = 1;
|
||||
else
|
||||
*dp = 0;
|
||||
@@ -3377,10 +3443,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((3 - ((row_width + 3) & 3)) << 1);
|
||||
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0x3;
|
||||
value = (*sp >> shift) & 0x03;
|
||||
*dp = (png_byte)value;
|
||||
if (shift == 6)
|
||||
{
|
||||
@@ -3398,10 +3464,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((row_width & 1) << 2);
|
||||
shift = (int)((row_width & 0x01) << 2);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0xf;
|
||||
value = (*sp >> shift) & 0x0f;
|
||||
*dp = (png_byte)value;
|
||||
if (shift == 4)
|
||||
{
|
||||
@@ -3473,7 +3539,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
/* If the bit depth < 8, it is expanded to 8. Also, if the
|
||||
* transparency value is supplied, an alpha channel is built.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_value)
|
||||
{
|
||||
@@ -3500,10 +3566,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
gray = (png_uint_16)(gray*0xff);
|
||||
sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = 7 - (int)((row_width + 7) & 7);
|
||||
shift = 7 - (int)((row_width + 7) & 0x07);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if ((*sp >> shift) & 0x1)
|
||||
if ((*sp >> shift) & 0x01)
|
||||
*dp = 0xff;
|
||||
else
|
||||
*dp = 0;
|
||||
@@ -3524,10 +3590,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
gray = (png_uint_16)(gray*0x55);
|
||||
sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((3 - ((row_width + 3) & 3)) << 1);
|
||||
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0x3;
|
||||
value = (*sp >> shift) & 0x03;
|
||||
*dp = (png_byte)(value | (value << 2) | (value << 4) |
|
||||
(value << 6));
|
||||
if (shift == 6)
|
||||
@@ -3547,10 +3613,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
gray = (png_uint_16)(gray*0x11);
|
||||
sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((1 - ((row_width + 1) & 1)) << 2);
|
||||
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0xf;
|
||||
value = (*sp >> shift) & 0x0f;
|
||||
*dp = (png_byte)(value | (value << 4));
|
||||
if (shift == 4)
|
||||
{
|
||||
@@ -3672,7 +3738,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
png_bytep palette_lookup, png_bytep dither_lookup)
|
||||
{
|
||||
@@ -3764,6 +3830,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
static int png_gamma_shift[] =
|
||||
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0};
|
||||
@@ -3773,7 +3840,7 @@ static int png_gamma_shift[] =
|
||||
* the future. Note also how the gamma_16 tables are segmented so that
|
||||
* we don't need to allocate > 64K chunks for a full 16-bit table.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_build_gamma_table(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_build_gamma_table\n");
|
||||
@@ -3800,7 +3867,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY))
|
||||
if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY))
|
||||
{
|
||||
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
@@ -3814,7 +3881,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
g) * 255.0 + .5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
|
||||
@@ -3983,4 +4050,66 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* To do: install integer version of png_build_gamma_table here */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* undoes intrapixel differencing */
|
||||
void /* PRIVATE */
|
||||
png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_read_intrapixel\n");
|
||||
if (
|
||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||
row != NULL && row_info != NULL &&
|
||||
#endif
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 3;
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 4;
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
*(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff);
|
||||
*(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff);
|
||||
}
|
||||
}
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 6;
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 8;
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0=*(rp )<<8 | *(rp+1);
|
||||
png_uint_32 s1=*(rp+2)<<8 | *(rp+3);
|
||||
png_uint_32 s2=*(rp+4)<<8 | *(rp+5);
|
||||
png_uint_32 red=(65536+s0+s1)&0xffff;
|
||||
png_uint_32 blue=(65536+s2+s1)&0xffff;
|
||||
*(rp ) = (png_byte)((red>>8)&0xff);
|
||||
*(rp+1) = (png_byte)(red&0xff);
|
||||
*(rp+4) = (png_byte)((blue>>8)&0xff);
|
||||
*(rp+5) = (png_byte)(blue&0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
|
||||
1360
pngrutil.c
772
pngset.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* The functions here are used during reads to store data from the file
|
||||
* into the info struct, and during writes to store application data
|
||||
@@ -16,8 +16,8 @@
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_bKGD_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "bKGD");
|
||||
@@ -29,8 +29,9 @@ png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
double white_x, double white_y, double red_x, double red_y,
|
||||
double green_x, double green_y, double blue_x, double blue_y)
|
||||
@@ -47,12 +48,56 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
info_ptr->y_green = (float)green_y;
|
||||
info_ptr->x_blue = (float)blue_x;
|
||||
info_ptr->y_blue = (float)blue_y;
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5);
|
||||
info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5);
|
||||
info_ptr->int_x_red = (png_fixed_point)(red_x*100000.+0.5);
|
||||
info_ptr->int_y_red = (png_fixed_point)(red_y*100000.+0.5);
|
||||
info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5);
|
||||
info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5);
|
||||
info_ptr->int_x_blue = (png_fixed_point)(blue_x*100000.+0.5);
|
||||
info_ptr->int_y_blue = (png_fixed_point)(blue_y*100000.+0.5);
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_cHRM;
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
|
||||
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
|
||||
png_fixed_point blue_x, png_fixed_point blue_y)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "cHRM");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
void
|
||||
info_ptr->int_x_white = white_x;
|
||||
info_ptr->int_y_white = white_y;
|
||||
info_ptr->int_x_red = red_x;
|
||||
info_ptr->int_y_red = red_y;
|
||||
info_ptr->int_x_green = green_x;
|
||||
info_ptr->int_y_green = green_y;
|
||||
info_ptr->int_x_blue = blue_x;
|
||||
info_ptr->int_y_blue = blue_y;
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
info_ptr->x_white = (float)(white_x/100000.);
|
||||
info_ptr->y_white = (float)(white_y/100000.);
|
||||
info_ptr->x_red = (float)(red_x/100000.);
|
||||
info_ptr->y_red = (float)(red_y/100000.);
|
||||
info_ptr->x_green = (float)(green_x/100000.);
|
||||
info_ptr->y_green = (float)(green_y/100000.);
|
||||
info_ptr->x_blue = (float)(blue_x/100000.);
|
||||
info_ptr->y_blue = (float)(blue_y/100000.);
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_cHRM;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "gAMA");
|
||||
@@ -60,24 +105,70 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||
return;
|
||||
|
||||
info_ptr->gamma = (float)file_gamma;
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
info_ptr->int_gamma = (int)(file_gamma*100000.+.5);
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_gAMA;
|
||||
if(file_gamma == 0.0)
|
||||
png_warning(png_ptr, "Setting gamma=0");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
|
||||
void
|
||||
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
||||
void PNGAPI
|
||||
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
||||
int_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "hIST");
|
||||
png_debug1(1, "in %s storage function\n", "gAMA");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->hist = hist;
|
||||
info_ptr->valid |= PNG_INFO_hIST;
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
info_ptr->gamma = (float)(int_gamma/100000.);
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
info_ptr->int_gamma = int_gamma;
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_gAMA;
|
||||
if(int_gamma == 0)
|
||||
png_warning(png_ptr, "Setting gamma=0");
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
||||
{
|
||||
int i;
|
||||
|
||||
png_debug1(1, "in %s storage function\n", "hIST");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
if (info_ptr->num_palette == 0)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Palette size 0, hIST allocation skipped.");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
|
||||
#endif
|
||||
png_ptr->hist = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(info_ptr->num_palette * sizeof (png_uint_16)));
|
||||
|
||||
for (i = 0; i < info_ptr->num_palette; i++)
|
||||
png_ptr->hist[i] = hist[i];
|
||||
info_ptr->hist = png_ptr->hist;
|
||||
info_ptr->valid |= PNG_INFO_hIST;
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_HIST;
|
||||
#else
|
||||
png_ptr->flags |= PNG_FLAG_FREE_HIST;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
int color_type, int interlace_type, int compression_type,
|
||||
@@ -88,6 +179,61 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* check for width and height valid values */
|
||||
if (width == 0 || height == 0)
|
||||
png_error(png_ptr, "Image width or height is zero in IHDR");
|
||||
if (width > PNG_MAX_UINT || height > PNG_MAX_UINT)
|
||||
png_error(png_ptr, "Invalid image size in IHDR");
|
||||
|
||||
/* check other values */
|
||||
if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
|
||||
bit_depth != 8 && bit_depth != 16)
|
||||
png_error(png_ptr, "Invalid bit depth in IHDR");
|
||||
|
||||
if (color_type < 0 || color_type == 1 ||
|
||||
color_type == 5 || color_type > 6)
|
||||
png_error(png_ptr, "Invalid color type in IHDR");
|
||||
|
||||
if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
|
||||
((color_type == PNG_COLOR_TYPE_RGB ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
|
||||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
|
||||
png_error(png_ptr, "Invalid color type/bit depth combination in IHDR");
|
||||
|
||||
if (interlace_type >= PNG_INTERLACE_LAST)
|
||||
png_error(png_ptr, "Unknown interlace method in IHDR");
|
||||
|
||||
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
|
||||
png_error(png_ptr, "Unknown compression method in IHDR");
|
||||
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* Accept filter_method 64 (intrapixel differencing) only if
|
||||
* 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
|
||||
* 2. Libpng did not read a PNG signature (this filter_method is only
|
||||
* used in PNG datastreams that are embedded in MNG datastreams) and
|
||||
* 3. The application called png_permit_mng_features with a mask that
|
||||
* included PNG_FLAG_MNG_FILTER_64 and
|
||||
* 4. The filter_method is 64 and
|
||||
* 5. The color_type is RGB or RGBA
|
||||
*/
|
||||
if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
|
||||
png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n");
|
||||
if(filter_type != PNG_FILTER_TYPE_BASE)
|
||||
{
|
||||
if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
|
||||
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
|
||||
(color_type == PNG_COLOR_TYPE_RGB ||
|
||||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
|
||||
png_error(png_ptr, "Unknown filter method in IHDR");
|
||||
if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
|
||||
png_warning(png_ptr, "Invalid filter method in IHDR");
|
||||
}
|
||||
#else
|
||||
if(filter_type != PNG_FILTER_TYPE_BASE)
|
||||
png_error(png_ptr, "Unknown filter method in IHDR");
|
||||
#endif
|
||||
|
||||
info_ptr->width = width;
|
||||
info_ptr->height = height;
|
||||
info_ptr->bit_depth = (png_byte)bit_depth;
|
||||
@@ -117,10 +263,10 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
info_ptr->rowbytes = (info_ptr->width * info_ptr->pixel_depth + 7) >> 3;
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 offset_x, png_uint_32 offset_y, int unit_type)
|
||||
png_int_32 offset_x, png_int_32 offset_y, int unit_type)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "oFFs");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
@@ -133,8 +279,8 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_pCAL_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
|
||||
png_charp units, png_charpp params)
|
||||
@@ -147,7 +293,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
return;
|
||||
|
||||
length = png_strlen(purpose) + 1;
|
||||
png_debug1(3, "allocating purpose for info (%d bytes)\n", length);
|
||||
png_debug1(3, "allocating purpose for info (%lu bytes)\n", length);
|
||||
info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
|
||||
|
||||
@@ -158,28 +304,81 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
info_ptr->pcal_nparams = (png_byte)nparams;
|
||||
|
||||
length = png_strlen(units) + 1;
|
||||
png_debug1(3, "allocating units for info (%d bytes)\n", length);
|
||||
png_debug1(3, "allocating units for info (%lu bytes)\n", length);
|
||||
info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
|
||||
|
||||
info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr,
|
||||
(png_uint_32)((nparams + 1) * sizeof(png_charp)));
|
||||
|
||||
info_ptr->pcal_params[nparams] = NULL;
|
||||
|
||||
for (i = 0; i < nparams; i++)
|
||||
{
|
||||
length = png_strlen(params[i]) + 1;
|
||||
png_debug2(3, "allocating parameter %d for info (%d bytes)\n", i, length);
|
||||
png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length);
|
||||
info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
|
||||
}
|
||||
|
||||
info_ptr->valid |= PNG_INFO_pCAL;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_PCAL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
int unit, double width, double height)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "sCAL");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->scal_unit = (png_byte)unit;
|
||||
info_ptr->scal_pixel_width = width;
|
||||
info_ptr->scal_pixel_height = height;
|
||||
|
||||
info_ptr->valid |= PNG_INFO_sCAL;
|
||||
}
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
int unit, png_charp swidth, png_charp sheight)
|
||||
{
|
||||
png_uint_32 length;
|
||||
|
||||
png_debug1(1, "in %s storage function\n", "sCAL");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->scal_unit = (png_byte)unit;
|
||||
|
||||
length = png_strlen(swidth) + 1;
|
||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
||||
info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
|
||||
|
||||
length = png_strlen(sheight) + 1;
|
||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
||||
info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
|
||||
|
||||
info_ptr->valid |= PNG_INFO_sCAL;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_SCAL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
|
||||
{
|
||||
@@ -194,21 +393,40 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
png_colorp palette, int num_palette)
|
||||
{
|
||||
|
||||
png_debug1(1, "in %s storage function\n", "PLTE");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->palette = palette;
|
||||
info_ptr->num_palette = (png_uint_16)num_palette;
|
||||
/*
|
||||
* It may not actually be necessary to set png_ptr->palette here;
|
||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||
* function used to do the allocation.
|
||||
*/
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
||||
#endif
|
||||
png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)num_palette,
|
||||
sizeof (png_color));
|
||||
png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color));
|
||||
info_ptr->palette = png_ptr->palette;
|
||||
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_PLTE;
|
||||
#else
|
||||
png_ptr->flags |= PNG_FLAG_FREE_PLTE;
|
||||
#endif
|
||||
|
||||
info_ptr->valid |= PNG_INFO_PLTE;
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_sBIT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_8p sig_bit)
|
||||
{
|
||||
@@ -221,8 +439,8 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_sRGB_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "sRGB");
|
||||
@@ -232,15 +450,27 @@ png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
|
||||
info_ptr->srgb_intent = (png_byte)intent;
|
||||
info_ptr->valid |= PNG_INFO_sRGB;
|
||||
}
|
||||
void
|
||||
|
||||
void PNGAPI
|
||||
png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
int intent)
|
||||
{
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float file_gamma;
|
||||
#endif
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_fixed_point int_file_gamma;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
|
||||
int_green_y, int_blue_x, int_blue_y;
|
||||
#endif
|
||||
#endif
|
||||
png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
@@ -248,12 +478,33 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
png_set_sRGB(png_ptr, info_ptr, intent);
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
file_gamma = (float).45455;
|
||||
png_set_gAMA(png_ptr, info_ptr, file_gamma);
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
int_file_gamma = 45455L;
|
||||
png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
int_white_x = 31270L;
|
||||
int_white_y = 32900L;
|
||||
int_red_x = 64000L;
|
||||
int_red_y = 33000L;
|
||||
int_green_x = 30000L;
|
||||
int_green_y = 60000L;
|
||||
int_blue_x = 15000L;
|
||||
int_blue_y = 6000L;
|
||||
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr,
|
||||
int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y,
|
||||
int_blue_x, int_blue_y);
|
||||
#endif
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
white_x = (float).3127;
|
||||
white_y = (float).3290;
|
||||
red_x = (float).64;
|
||||
@@ -265,14 +516,47 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
png_set_cHRM(png_ptr, info_ptr,
|
||||
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
|
||||
defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
void
|
||||
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp name, int compression_type,
|
||||
png_charp profile, png_uint_32 proflen)
|
||||
{
|
||||
png_charp new_iccp_name;
|
||||
png_charp new_iccp_profile;
|
||||
|
||||
png_debug1(1, "in %s storage function\n", "iCCP");
|
||||
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
|
||||
return;
|
||||
|
||||
new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1);
|
||||
png_strcpy(new_iccp_name, name);
|
||||
new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen);
|
||||
png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
|
||||
|
||||
info_ptr->iccp_proflen = proflen;
|
||||
info_ptr->iccp_name = new_iccp_name;
|
||||
info_ptr->iccp_profile = new_iccp_profile;
|
||||
/* Compression is always zero but is here so the API and info structure
|
||||
* does not have to change if we introduce multiple compression types */
|
||||
info_ptr->iccp_compression = (png_byte)compression_type;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_ICCP;
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_iCCP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
int num_text)
|
||||
{
|
||||
@@ -309,52 +593,113 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
info_ptr->num_text = 0;
|
||||
info_ptr->text = (png_textp)png_malloc(png_ptr,
|
||||
(png_uint_32)(info_ptr->max_text * sizeof (png_text)));
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_TEXT;
|
||||
#endif
|
||||
}
|
||||
png_debug1(3, "allocated %d entries for info_ptr->text\n",
|
||||
info_ptr->max_text);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text; i++)
|
||||
{
|
||||
png_size_t text_length,key_len;
|
||||
png_size_t lang_len,lang_key_len;
|
||||
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
||||
png_charp key,text;
|
||||
|
||||
if (text_ptr[i].key == (png_charp)NULL)
|
||||
continue;
|
||||
if (text_ptr[i].key == NULL)
|
||||
continue;
|
||||
|
||||
if (text_ptr[i].text[0] == '\0')
|
||||
key_len = png_strlen(text_ptr[i].key);
|
||||
|
||||
if(text_ptr[i].compression <= 0)
|
||||
{
|
||||
textp->text_length = 0;
|
||||
textp->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
lang_len = 0;
|
||||
lang_key_len = 0;
|
||||
}
|
||||
else
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
{
|
||||
/* set iTXt data */
|
||||
if (text_ptr[i].key != NULL)
|
||||
lang_len = png_strlen(text_ptr[i].lang);
|
||||
else
|
||||
lang_len = 0;
|
||||
if (text_ptr[i].lang_key != NULL)
|
||||
lang_key_len = png_strlen(text_ptr[i].lang_key);
|
||||
else
|
||||
lang_key_len = 0;
|
||||
}
|
||||
#else
|
||||
{
|
||||
png_warning(png_ptr, "iTXt chunk not supported.");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
|
||||
{
|
||||
text_length = 0;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if(text_ptr[i].compression > 0)
|
||||
textp->compression = PNG_ITXT_COMPRESSION_NONE;
|
||||
else
|
||||
#endif
|
||||
textp->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
textp->text_length = png_strlen(text_ptr[i].text);
|
||||
text_length = png_strlen(text_ptr[i].text);
|
||||
textp->compression = text_ptr[i].compression;
|
||||
}
|
||||
key=text_ptr[i].key;
|
||||
for (text = key; *text++;)
|
||||
/* empty loop to find the byte after the zero byte after the
|
||||
end of key */ ;
|
||||
|
||||
textp->key = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(text+textp->text_length - key)+1);
|
||||
/* Caution: the calling program, not libpng, is responsible for
|
||||
freeing this, if libpng wasn't the caller. */
|
||||
png_debug2(2, "Allocated %d bytes at %x in png_set_text\n",
|
||||
text+textp->text_length-key+1, textp->key);
|
||||
(png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
|
||||
png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
|
||||
(png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4),
|
||||
(int)textp->key);
|
||||
|
||||
png_memcpy(textp->key, text_ptr[i].key,
|
||||
(png_size_t)(text - key)); /* includes the zero-byte separator */
|
||||
textp->text = textp->key + (text-key);
|
||||
if(textp->text_length)
|
||||
(png_size_t)(key_len));
|
||||
*(textp->key+key_len) = '\0';
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if (text_ptr[i].compression > 0)
|
||||
{
|
||||
png_memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(textp->text_length));
|
||||
*(textp->text+textp->text_length) = '\0';
|
||||
textp->lang=textp->key + key_len + 1;
|
||||
png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
|
||||
*(textp->lang+lang_len) = '\0';
|
||||
textp->lang_key=textp->lang + lang_len + 1;
|
||||
png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
|
||||
*(textp->lang_key+lang_key_len) = '\0';
|
||||
textp->text=textp->lang_key + lang_key_len + 1;
|
||||
}
|
||||
else
|
||||
textp->text--;
|
||||
#endif
|
||||
{
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
textp->lang=(png_charp)NULL;
|
||||
textp->lang_key=(png_charp)NULL;
|
||||
#endif
|
||||
textp->text=textp->key + key_len + 1;
|
||||
}
|
||||
if(text_length)
|
||||
png_memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(text_length));
|
||||
*(textp->text+text_length) = '\0';
|
||||
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if(textp->compression > 0)
|
||||
{
|
||||
textp->text_length = 0;
|
||||
textp->itxt_length = text_length;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
textp->text_length = text_length;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
textp->itxt_length = 0;
|
||||
#endif
|
||||
}
|
||||
info_ptr->text[info_ptr->num_text]= *textp;
|
||||
info_ptr->num_text++;
|
||||
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
|
||||
@@ -362,8 +707,8 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_tIME_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "tIME");
|
||||
@@ -376,8 +721,8 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||
void
|
||||
#if defined(PNG_tRNS_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep trans, int num_trans, png_color_16p trans_values)
|
||||
{
|
||||
@@ -387,7 +732,22 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
if (trans != NULL)
|
||||
{
|
||||
info_ptr->trans = trans;
|
||||
/*
|
||||
* It may not actually be necessary to set png_ptr->trans here;
|
||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||
* function used to do the allocation.
|
||||
*/
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||
#endif
|
||||
png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
|
||||
num_trans);
|
||||
png_memcpy(info_ptr->trans, trans, num_trans);
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||
#else
|
||||
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (trans_values != NULL)
|
||||
@@ -402,13 +762,265 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED)
|
||||
void
|
||||
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
||||
#if defined(PNG_sPLT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_sPLT(png_structp png_ptr,
|
||||
png_infop info_ptr, png_sPLT_tp entries, int nentries)
|
||||
{
|
||||
png_debug1(1, "in png_permit_empty_plte\n", "");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->empty_plte_permitted=(png_byte)empty_plte_permitted;
|
||||
png_sPLT_tp np;
|
||||
int i;
|
||||
|
||||
np = (png_sPLT_tp)png_malloc(png_ptr,
|
||||
(info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t));
|
||||
|
||||
png_memcpy(np, info_ptr->splt_palettes,
|
||||
info_ptr->splt_palettes_num * sizeof(png_sPLT_t));
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes=NULL;
|
||||
|
||||
for (i = 0; i < nentries; i++)
|
||||
{
|
||||
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||
png_sPLT_tp from = entries + i;
|
||||
|
||||
to->name = (png_charp)png_malloc(png_ptr,
|
||||
png_strlen(from->name) + 1);
|
||||
png_strcpy(to->name, from->name);
|
||||
to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
|
||||
from->nentries * sizeof(png_sPLT_t));
|
||||
png_memcpy(to->entries, from->entries,
|
||||
from->nentries * sizeof(png_sPLT_t));
|
||||
to->nentries = from->nentries;
|
||||
to->depth = from->depth;
|
||||
}
|
||||
|
||||
info_ptr->splt_palettes = np;
|
||||
info_ptr->splt_palettes_num += nentries;
|
||||
info_ptr->valid |= PNG_INFO_sPLT;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_SPLT;
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_unknown_chunks(png_structp png_ptr,
|
||||
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
|
||||
{
|
||||
png_unknown_chunkp np;
|
||||
int i;
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
|
||||
return;
|
||||
|
||||
np = (png_unknown_chunkp)png_malloc(png_ptr,
|
||||
(info_ptr->unknown_chunks_num + num_unknowns) *
|
||||
sizeof(png_unknown_chunk));
|
||||
|
||||
png_memcpy(np, info_ptr->unknown_chunks,
|
||||
info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk));
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks=NULL;
|
||||
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
{
|
||||
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
||||
png_unknown_chunkp from = unknowns + i;
|
||||
|
||||
png_strcpy((png_charp)to->name, (png_charp)from->name);
|
||||
to->data = (png_bytep)png_malloc(png_ptr, from->size);
|
||||
png_memcpy(to->data, from->data, from->size);
|
||||
to->size = from->size;
|
||||
|
||||
/* note our location in the read or write sequence */
|
||||
to->location = (png_byte)(png_ptr->mode & 0xff);
|
||||
}
|
||||
|
||||
info_ptr->unknown_chunks = np;
|
||||
info_ptr->unknown_chunks_num += num_unknowns;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_UNKN;
|
||||
#endif
|
||||
}
|
||||
void PNGAPI
|
||||
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
||||
int chunk, int location)
|
||||
{
|
||||
if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
|
||||
(int)info_ptr->unknown_chunks_num)
|
||||
info_ptr->unknown_chunks[chunk].location = (png_byte)location;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
||||
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
||||
{
|
||||
/* This function is deprecated in favor of png_permit_mng_features()
|
||||
and will be removed from libpng-2.0.0 */
|
||||
png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->mng_features_permitted = (png_byte)
|
||||
((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) |
|
||||
((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
|
||||
{
|
||||
png_debug(1, "in png_permit_mng_features\n");
|
||||
if (png_ptr == NULL)
|
||||
return (png_uint_32)0;
|
||||
png_ptr->mng_features_permitted =
|
||||
(png_byte)(mng_features & PNG_ALL_MNG_FEATURES);
|
||||
return (png_uint_32)png_ptr->mng_features_permitted;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
|
||||
chunk_list, int num_chunks)
|
||||
{
|
||||
png_bytep new_list, p;
|
||||
int i, old_num_chunks;
|
||||
if (num_chunks == 0)
|
||||
{
|
||||
if(keep == HANDLE_CHUNK_ALWAYS || keep == HANDLE_CHUNK_IF_SAFE)
|
||||
png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
|
||||
|
||||
if(keep == HANDLE_CHUNK_ALWAYS)
|
||||
png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
|
||||
return;
|
||||
}
|
||||
if (chunk_list == NULL)
|
||||
return;
|
||||
old_num_chunks=png_ptr->num_chunk_list;
|
||||
new_list=(png_bytep)png_malloc(png_ptr,5*(num_chunks+old_num_chunks));
|
||||
if(png_ptr->chunk_list != NULL)
|
||||
{
|
||||
png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
}
|
||||
png_memcpy(new_list+5*old_num_chunks, chunk_list, 5*num_chunks);
|
||||
for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5)
|
||||
*p=(png_byte)keep;
|
||||
png_ptr->num_chunk_list=old_num_chunks+num_chunks;
|
||||
png_ptr->chunk_list=new_list;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_ptr->free_me |= PNG_FREE_LIST;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
|
||||
png_user_chunk_ptr read_user_chunk_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_chunk_fn\n");
|
||||
png_ptr->read_user_chunk_fn = read_user_chunk_fn;
|
||||
png_ptr->user_chunk_ptr = user_chunk_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "rows");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
info_ptr->row_pointers = row_pointers;
|
||||
if(row_pointers)
|
||||
info_ptr->valid |= PNG_INFO_IDAT;
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
if(png_ptr->zbuf)
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_ptr->zbuf_size = (png_size_t)size;
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
|
||||
{
|
||||
if (png_ptr && info_ptr)
|
||||
info_ptr->valid &= ~(mask);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||
/* this function was added to libpng 1.2.0 and should always exist by default */
|
||||
void PNGAPI
|
||||
png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
|
||||
{
|
||||
png_uint_32 settable_asm_flags;
|
||||
png_uint_32 settable_mmx_flags;
|
||||
|
||||
settable_mmx_flags =
|
||||
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
||||
#endif
|
||||
#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
||||
#endif
|
||||
#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH |
|
||||
#endif
|
||||
0;
|
||||
|
||||
/* could be some non-MMX ones in the future, but not currently: */
|
||||
settable_asm_flags = settable_mmx_flags;
|
||||
|
||||
if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) ||
|
||||
!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU))
|
||||
{
|
||||
/* clear all MMX flags if MMX isn't supported */
|
||||
settable_asm_flags &= ~settable_mmx_flags;
|
||||
png_ptr->asm_flags &= ~settable_mmx_flags;
|
||||
}
|
||||
|
||||
/* we're replacing the settable bits with those passed in by the user,
|
||||
* so first zero them out of the master copy, then logical-OR in the
|
||||
* allowed subset that was requested */
|
||||
|
||||
png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */
|
||||
png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */
|
||||
}
|
||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
void PNGAPI
|
||||
png_set_mmx_thresholds (png_structp png_ptr,
|
||||
png_byte mmx_bitdepth_threshold,
|
||||
png_uint_32 mmx_rowbytes_threshold)
|
||||
{
|
||||
png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold;
|
||||
png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
|
||||
}
|
||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||
|
||||
66
pngtrans.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* turn on BGR-to-RGB mapping */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_bgr(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_bgr\n");
|
||||
@@ -23,7 +23,7 @@ png_set_bgr(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* turn on 16 bit byte swapping */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_swap(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap\n");
|
||||
@@ -34,7 +34,7 @@ png_set_swap(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* turn on pixel packing */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_packing(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packing\n");
|
||||
@@ -48,7 +48,7 @@ png_set_packing(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
/* turn on packed pixel swapping */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_packswap(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packswap\n");
|
||||
@@ -58,7 +58,7 @@ png_set_packswap(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift\n");
|
||||
@@ -69,7 +69,7 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int
|
||||
int PNGAPI
|
||||
png_set_interlace_handling(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_interlace handling\n");
|
||||
@@ -89,7 +89,7 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||
* for 48-bit input data, as well as to avoid problems with some compilers
|
||||
* that don't like bytes as parameters.
|
||||
*/
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_filler\n");
|
||||
@@ -122,7 +122,7 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_swap_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap_alpha\n");
|
||||
@@ -132,7 +132,7 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_invert_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_alpha\n");
|
||||
@@ -141,7 +141,7 @@ png_set_invert_alpha(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_invert_mono(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_mono\n");
|
||||
@@ -149,7 +149,7 @@ png_set_invert_mono(png_structp png_ptr)
|
||||
}
|
||||
|
||||
/* invert monochrome grayscale data */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_invert\n");
|
||||
@@ -174,7 +174,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* swaps byte order on 16 bit depth images */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_swap\n");
|
||||
@@ -305,7 +305,7 @@ static png_byte fourbppswaptable[256] = {
|
||||
};
|
||||
|
||||
/* swaps pixel packing order within bytes */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_packswap\n");
|
||||
@@ -337,7 +337,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
/* remove filler or alpha byte(s) */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
{
|
||||
png_debug(1, "in png_do_strip_filler\n");
|
||||
@@ -392,11 +392,12 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
sp += 8; dp += 6;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
/* This could be (although memcpy is probably slower):
|
||||
/* This could be (although png_memcpy is probably slower):
|
||||
png_memcpy(dp, sp, 6);
|
||||
sp += 8;
|
||||
dp += 6;
|
||||
*/
|
||||
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
@@ -411,11 +412,12 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
/* This could be (although memcpy is probably slower):
|
||||
/* This could be (although png_memcpy is probably slower):
|
||||
png_memcpy(dp, sp, 6);
|
||||
sp += 8;
|
||||
dp += 6;
|
||||
*/
|
||||
|
||||
sp+=2;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
@@ -495,7 +497,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* swaps red and blue bytes within a pixel */
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_bgr\n");
|
||||
@@ -571,25 +573,39 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
void
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||
{
|
||||
png_debug(1, "in png_set_user_transform_info\n");
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
#else
|
||||
if(user_transform_ptr || user_transform_depth || user_transform_channels)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transform info");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function returns a pointer to the user_transform_ptr associated with
|
||||
* the user transform functions. The application should free any memory
|
||||
* associated with this pointer before png_write_destroy and png_read_destroy
|
||||
* are called.
|
||||
*/
|
||||
png_voidp
|
||||
png_voidp PNGAPI
|
||||
png_get_user_transform_ptr(png_structp png_ptr)
|
||||
{
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||
}
|
||||
#else
|
||||
if(png_ptr)
|
||||
return (NULL);
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
31
pngtypes.h
@@ -1,31 +0,0 @@
|
||||
/* pngtypes.h - array of chunk-types for libpng
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
*/
|
||||
|
||||
/* Constant strings for known chunk types. If you need to add a chunk,
|
||||
* define the string in png.h and invoke it here.
|
||||
*/
|
||||
|
||||
PNG_IHDR;
|
||||
PNG_IDAT;
|
||||
PNG_IEND;
|
||||
PNG_PLTE;
|
||||
PNG_bKGD;
|
||||
PNG_cHRM;
|
||||
PNG_gAMA;
|
||||
PNG_hIST;
|
||||
PNG_oFFs;
|
||||
PNG_pCAL;
|
||||
PNG_pHYs;
|
||||
PNG_sBIT;
|
||||
PNG_sRGB;
|
||||
PNG_tEXt;
|
||||
PNG_tIME;
|
||||
PNG_tRNS;
|
||||
PNG_zTXt;
|
||||
|
||||
250
pngvcrd.c
@@ -2,13 +2,22 @@
|
||||
*
|
||||
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, Intel Corporation
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
*
|
||||
* Contributed by Nirav Chhatrapati, Intel Corporation, 1998
|
||||
* Interface to libpng contributed by Gilles Vollant, 1999
|
||||
* Debugging and cleanup by Greg Roelofs, 2000, 2001
|
||||
*
|
||||
* In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d,
|
||||
* a sign error in the post-MMX cleanup code for each pixel_depth resulted
|
||||
* in bad pixels at the beginning of some rows of some images, and also
|
||||
* (due to out-of-range memory reads and writes) caused heap corruption
|
||||
* when compiled with MSVC 6.0. The error was fixed in version 1.0.4e.
|
||||
*
|
||||
* [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916]
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -17,22 +26,17 @@
|
||||
|
||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)
|
||||
|
||||
/*
|
||||
One of these might need to be defined.
|
||||
#define DISABLE_PNGVCRD_COMBINE
|
||||
#define DISABLE_PNGVCRD_INTERLACE
|
||||
*/
|
||||
|
||||
static int mmx_supported=2;
|
||||
|
||||
void
|
||||
png_read_filter_row_c(png_structp png_ptr, png_row_infop row_info,
|
||||
png_bytep row, png_bytep prev_row, int filter);
|
||||
|
||||
static int mmxsupport()
|
||||
int PNGAPI
|
||||
png_mmx_support(void)
|
||||
{
|
||||
int mmx_supported_local = 0;
|
||||
_asm {
|
||||
push ebx //CPUID will trash these
|
||||
push ecx
|
||||
push edx
|
||||
pushfd //Save Eflag to stack
|
||||
pop eax //Get Eflag from stack into eax
|
||||
mov ecx, eax //Make another copy of Eflag in ecx
|
||||
@@ -70,12 +74,15 @@ static int mmxsupport()
|
||||
|
||||
NOT_SUPPORTED:
|
||||
mov eax, mmx_supported_local //move return value to eax
|
||||
|
||||
pop edx //CPUID trashed these
|
||||
pop ecx
|
||||
pop ebx
|
||||
}
|
||||
|
||||
//mmx_supported_local=0; // test code for force don't support MMX
|
||||
//printf("MMX : %u (1=MMX supported)\n",mmx_supported_local);
|
||||
|
||||
mmx_supported = mmx_supported_local;
|
||||
return mmx_supported_local;
|
||||
}
|
||||
|
||||
@@ -93,25 +100,18 @@ NOT_SUPPORTED:
|
||||
/* Use this routine for x86 platform - uses faster MMX routine if machine
|
||||
supports MMX */
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
#endif
|
||||
#ifdef DISABLE_PNGVCRD_COMBINE
|
||||
int save_mmx_supported = mmx_supported;
|
||||
#endif
|
||||
|
||||
png_debug(1,"in png_combine_row_asm\n");
|
||||
|
||||
#ifdef DISABLE_PNGVCRD_COMBINE
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) && png_ptr->pass != 6)
|
||||
mmx_supported = 0;
|
||||
else
|
||||
#endif
|
||||
if (mmx_supported == 2)
|
||||
mmx_supported = mmxsupport();
|
||||
if (mmx_supported == 2) {
|
||||
png_mmx_support();
|
||||
}
|
||||
|
||||
if (mask == 0xff)
|
||||
{
|
||||
@@ -300,7 +300,7 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
||||
|
||||
__int64 mask0=0x0102040810204080;
|
||||
|
||||
if (mmx_supported)
|
||||
if ( mmx_supported )
|
||||
{
|
||||
srcptr = png_ptr->row_buf + 1;
|
||||
dstptr = row;
|
||||
@@ -382,6 +382,8 @@ end8:
|
||||
incr1 = (disp)*pixel_bytes;
|
||||
for (i = initial_val; i < final_val; i += incr1)
|
||||
{
|
||||
if (pixel_bytes > (png_size_t)(final_val-i))
|
||||
pixel_bytes = (png_size_t)(final_val-i);
|
||||
png_memcpy(dstptr, srcptr, pixel_bytes);
|
||||
srcptr += incr1;
|
||||
dstptr += incr1;
|
||||
@@ -400,7 +402,7 @@ end8:
|
||||
__int64 mask1=0x0101020204040808,
|
||||
mask0=0x1010202040408080;
|
||||
|
||||
if (mmx_supported)
|
||||
if ( mmx_supported )
|
||||
{
|
||||
srcptr = png_ptr->row_buf + 1;
|
||||
dstptr = row;
|
||||
@@ -493,6 +495,8 @@ end16:
|
||||
incr1 = (disp)*pixel_bytes;
|
||||
for (i = initial_val; i < final_val; i += incr1)
|
||||
{
|
||||
if (pixel_bytes > (png_size_t)(final_val-i))
|
||||
pixel_bytes = (png_size_t)(final_val-i);
|
||||
png_memcpy(dstptr, srcptr, pixel_bytes);
|
||||
srcptr += incr1;
|
||||
dstptr += incr1;
|
||||
@@ -520,7 +524,7 @@ end16:
|
||||
len = (png_ptr->width)&~7;
|
||||
diff = (png_ptr->width)&7;
|
||||
|
||||
if (mmx_supported)
|
||||
if ( mmx_supported )
|
||||
{
|
||||
_asm
|
||||
{
|
||||
@@ -623,6 +627,8 @@ end24:
|
||||
incr1 = (disp)*pixel_bytes;
|
||||
for (i = initial_val; i < final_val; i += incr1)
|
||||
{
|
||||
if (pixel_bytes > (png_size_t)(final_val-i))
|
||||
pixel_bytes = (png_size_t)(final_val-i);
|
||||
png_memcpy(dstptr, srcptr, pixel_bytes);
|
||||
srcptr += incr1;
|
||||
dstptr += incr1;
|
||||
@@ -651,7 +657,7 @@ end24:
|
||||
len = (png_ptr->width)&~7;
|
||||
diff = (png_ptr->width)&7;
|
||||
|
||||
if (mmx_supported)
|
||||
if ( mmx_supported )
|
||||
{
|
||||
_asm
|
||||
{
|
||||
@@ -762,6 +768,8 @@ end32:
|
||||
incr1 = (disp)*pixel_bytes;
|
||||
for (i = initial_val; i < final_val; i += incr1)
|
||||
{
|
||||
if (pixel_bytes > (png_size_t)(final_val-i))
|
||||
pixel_bytes = (png_size_t)(final_val-i);
|
||||
png_memcpy(dstptr, srcptr, pixel_bytes);
|
||||
srcptr += incr1;
|
||||
dstptr += incr1;
|
||||
@@ -785,7 +793,7 @@ end32:
|
||||
mask1=0x2020202040404040,
|
||||
mask0=0x4040808080808080;
|
||||
|
||||
if (mmx_supported)
|
||||
if ( mmx_supported )
|
||||
{
|
||||
srcptr = png_ptr->row_buf + 1;
|
||||
dstptr = row;
|
||||
@@ -919,6 +927,8 @@ end48:
|
||||
incr1 = (disp)*pixel_bytes;
|
||||
for (i = initial_val; i < final_val; i += incr1)
|
||||
{
|
||||
if (pixel_bytes > (png_size_t)(final_val-i))
|
||||
pixel_bytes = (png_size_t)(final_val-i);
|
||||
png_memcpy(dstptr, srcptr, pixel_bytes);
|
||||
srcptr += incr1;
|
||||
dstptr += incr1;
|
||||
@@ -947,6 +957,8 @@ end48:
|
||||
incr1 = (disp)*pixel_bytes;
|
||||
for (i = initial_val; i < final_val; i += incr1)
|
||||
{
|
||||
if (pixel_bytes > (png_size_t)(final_val-i))
|
||||
pixel_bytes = (png_size_t)(final_val-i);
|
||||
png_memcpy(dp, sptr, pixel_bytes);
|
||||
sptr += incr1;
|
||||
dp += incr1;
|
||||
@@ -956,43 +968,27 @@ end48:
|
||||
} /* end switch (png_ptr->row_info.pixel_depth) */
|
||||
} /* end if (non-trivial mask) */
|
||||
|
||||
#ifdef DISABLE_PNGVCRD_COMBINE
|
||||
mmx_supported = save_mmx_supported;
|
||||
#endif
|
||||
|
||||
} /* end png_combine_row() */
|
||||
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
||||
|
||||
void
|
||||
png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
png_uint_32 transformations)
|
||||
void /* PRIVATE */
|
||||
png_do_read_interlace(png_structp png_ptr)
|
||||
{
|
||||
png_row_infop row_info = &(png_ptr->row_info);
|
||||
png_bytep row = png_ptr->row_buf + 1;
|
||||
int pass = png_ptr->pass;
|
||||
png_uint_32 transformations = png_ptr->transformations;
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
#endif
|
||||
#ifdef DISABLE_PNGVCRD_INTERLACE
|
||||
int save_mmx_supported = mmx_supported;
|
||||
#endif
|
||||
|
||||
png_debug(1,"in png_do_read_interlace\n");
|
||||
|
||||
#ifdef DISABLE_PNGVCRD_INTERLACE
|
||||
/* In libpng versions 1.0.3a through 1.0.4d,
|
||||
* a sign error in the post-MMX cleanup code for each pixel_depth resulted
|
||||
* in bad pixels at the beginning of some rows of some images, and also
|
||||
* (due to out-of-range memory reads and writes) caused heap corruption
|
||||
* when compiled with MSVC 6.0. The error was fixed in version 1.0.4e,
|
||||
* and the code appears to work completely correctly, so it is enabled
|
||||
* by default.
|
||||
*/
|
||||
if (1) /* all passes caused a heap problem in the old code */
|
||||
mmx_supported = 0;
|
||||
else
|
||||
#endif
|
||||
if (mmx_supported == 2)
|
||||
mmx_supported = mmxsupport();
|
||||
if (mmx_supported == 2) {
|
||||
png_mmx_support();
|
||||
}
|
||||
|
||||
if (row != NULL && row_info != NULL)
|
||||
{
|
||||
@@ -1190,7 +1186,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
// sign fix by GRR
|
||||
// NOTE: there is NO MMX code for 48-bit and 64-bit images
|
||||
|
||||
if (mmx_supported) // use MMX routine if machine supports it
|
||||
// use MMX routine if machine supports it
|
||||
if ( mmx_supported )
|
||||
{
|
||||
if (pixel_bytes == 3)
|
||||
{
|
||||
@@ -1502,8 +1499,8 @@ loop2_pass0:
|
||||
}
|
||||
}
|
||||
|
||||
sptr -= (width_mmx*2 - 2); // sign fixed
|
||||
dp -= (width_mmx*16 - 2); // sign fixed
|
||||
sptr -= (width_mmx*2 - 2); // sign fixed
|
||||
dp -= (width_mmx*16 - 2); // sign fixed
|
||||
for (i = width; i; i--)
|
||||
{
|
||||
png_byte v[8];
|
||||
@@ -1547,8 +1544,8 @@ loop2_pass2:
|
||||
}
|
||||
}
|
||||
|
||||
sptr -= (width_mmx*2 - 2); // sign fixed
|
||||
dp -= (width_mmx*8 - 2); // sign fixed
|
||||
sptr -= (width_mmx*2 - 2); // sign fixed
|
||||
dp -= (width_mmx*8 - 2); // sign fixed
|
||||
for (i = width; i; i--)
|
||||
{
|
||||
png_byte v[8];
|
||||
@@ -1587,8 +1584,8 @@ loop2_pass4:
|
||||
}
|
||||
}
|
||||
|
||||
sptr -= (width_mmx*2 - 2); // sign fixed
|
||||
dp -= (width_mmx*4 - 2); // sign fixed
|
||||
sptr -= (width_mmx*2 - 2); // sign fixed
|
||||
dp -= (width_mmx*4 - 2); // sign fixed
|
||||
for (i = width; i; i--)
|
||||
{
|
||||
png_byte v[8];
|
||||
@@ -1640,8 +1637,8 @@ loop4_pass0:
|
||||
}
|
||||
}
|
||||
|
||||
sptr -= (width_mmx*4 - 4); // sign fixed
|
||||
dp -= (width_mmx*32 - 4); // sign fixed
|
||||
sptr -= (width_mmx*4 - 4); // sign fixed
|
||||
dp -= (width_mmx*32 - 4); // sign fixed
|
||||
for (i = width; i; i--)
|
||||
{
|
||||
png_byte v[8];
|
||||
@@ -1685,8 +1682,8 @@ loop4_pass2:
|
||||
}
|
||||
}
|
||||
|
||||
sptr -= (width_mmx*4 - 4); // sign fixed
|
||||
dp -= (width_mmx*16 - 4); // sign fixed
|
||||
sptr -= (width_mmx*4 - 4); // sign fixed
|
||||
dp -= (width_mmx*16 - 4); // sign fixed
|
||||
for (i = width; i; i--)
|
||||
{
|
||||
png_byte v[8];
|
||||
@@ -1728,8 +1725,8 @@ loop4_pass4:
|
||||
}
|
||||
}
|
||||
|
||||
sptr -= (width_mmx*4 - 4); // sign fixed
|
||||
dp -= (width_mmx*8 - 4); // sign fixed
|
||||
sptr -= (width_mmx*4 - 4); // sign fixed
|
||||
dp -= (width_mmx*8 - 4); // sign fixed
|
||||
for (i = width; i; i--)
|
||||
{
|
||||
png_byte v[8];
|
||||
@@ -1780,7 +1777,7 @@ loop4_pass4:
|
||||
} /* end of mmx_supported */
|
||||
|
||||
else /* MMX not supported: use modified C code - takes advantage
|
||||
* of inlining of memcpy for a constant */
|
||||
* of inlining of png_memcpy for a constant */
|
||||
{
|
||||
if (pixel_bytes == 1)
|
||||
{
|
||||
@@ -1878,9 +1875,6 @@ loop4_pass4:
|
||||
(png_uint_32)row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
|
||||
#ifdef DISABLE_PNGVCRD_INTERLACE
|
||||
mmx_supported = save_mmx_supported;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
@@ -1898,7 +1892,7 @@ union uAll {
|
||||
|
||||
|
||||
// Optimized code for PNG Average filter decoder
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row
|
||||
, png_bytep prev_row)
|
||||
{
|
||||
@@ -2112,8 +2106,8 @@ davg4lp:
|
||||
case 2:
|
||||
{
|
||||
ActiveMask.use = 0x000000000000ffff;
|
||||
ShiftBpp.use = 24; // == 3 * 8
|
||||
ShiftRem.use = 40; // == 64 - 24
|
||||
ShiftBpp.use = 16; // == 2 * 8 [BUGFIX]
|
||||
ShiftRem.use = 48; // == 64 - 16 [BUGFIX]
|
||||
_asm {
|
||||
// Load ActiveMask
|
||||
movq mm7, ActiveMask
|
||||
@@ -2128,7 +2122,7 @@ davg4lp:
|
||||
// (we correct position in loop below)
|
||||
davg2lp:
|
||||
movq mm0, [edi + ebx]
|
||||
psllq mm2, ShiftRem // shift data to position correctly
|
||||
psrlq mm2, ShiftRem // shift data to position correctly [BUGFIX]
|
||||
movq mm1, [esi + ebx]
|
||||
// Add (Prev_row/2) to Average
|
||||
movq mm3, mm5
|
||||
@@ -2331,7 +2325,7 @@ davgend:
|
||||
}
|
||||
|
||||
// Optimized code for PNG Paeth filter decoder
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row,
|
||||
png_bytep prev_row)
|
||||
{
|
||||
@@ -3227,7 +3221,7 @@ dpthend:
|
||||
}
|
||||
|
||||
// Optimized code for PNG Sub filter decoder
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
//int test;
|
||||
@@ -3316,7 +3310,7 @@ dsub3lp:
|
||||
case 1:
|
||||
{
|
||||
// Placed here just in case this is a duplicate of the
|
||||
// non-MMX code for the SUB filter in png_read_filter_row above
|
||||
// non-MMX code for the SUB filter in png_read_filter_row below
|
||||
//
|
||||
// png_bytep rp;
|
||||
// png_bytep lp;
|
||||
@@ -3531,7 +3525,7 @@ dsubend:
|
||||
}
|
||||
|
||||
// Optimized code for PNG Up filter decoder
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row,
|
||||
png_bytep prev_row)
|
||||
{
|
||||
@@ -3646,66 +3640,55 @@ dupend:
|
||||
|
||||
|
||||
// Optimized png_read_filter_row routines
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
|
||||
row, png_bytep prev_row, int filter)
|
||||
{
|
||||
#ifdef PNG_DEBUG
|
||||
char filnm[6];
|
||||
char filnm[10];
|
||||
#endif
|
||||
#define UseMMX 1
|
||||
|
||||
if (mmx_supported == 2)
|
||||
mmx_supported = mmxsupport();
|
||||
|
||||
if (!mmx_supported)
|
||||
{
|
||||
png_read_filter_row_c(png_ptr, row_info, row, prev_row, filter);
|
||||
return ;
|
||||
if (mmx_supported == 2) {
|
||||
png_mmx_support();
|
||||
}
|
||||
|
||||
#ifdef PNG_DEBUG
|
||||
png_debug(1, "in png_read_filter_row\n");
|
||||
#if (UseMMX == 1)
|
||||
png_debug1(0,"%s, ", "MMX");
|
||||
#else
|
||||
png_debug1(0,"%s, ", "x86");
|
||||
#endif
|
||||
switch (filter)
|
||||
{
|
||||
case 0: sprintf(filnm, "None ");
|
||||
case 0: sprintf(filnm, "none");
|
||||
break;
|
||||
case 1: sprintf(filnm, "Sub ");
|
||||
case 1: sprintf(filnm, "sub-%s", "MMX");
|
||||
break;
|
||||
case 2: sprintf(filnm, "Up ");
|
||||
case 2: sprintf(filnm, "up-%s", "MMX");
|
||||
break;
|
||||
case 3: sprintf(filnm, "Avg ");
|
||||
case 3: sprintf(filnm, "avg-%s", "MMX");
|
||||
break;
|
||||
case 4: sprintf(filnm, "Paeth");
|
||||
case 4: sprintf(filnm, "Paeth-%s", "MMX");
|
||||
break;
|
||||
default: sprintf(filnm, "Unknw");
|
||||
default: sprintf(filnm, "unknw");
|
||||
break;
|
||||
}
|
||||
png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm);
|
||||
png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth,
|
||||
(int)((row_info->pixel_depth + 7) >> 3));
|
||||
png_debug1(0,"len=%8d, ", row_info->rowbytes);
|
||||
#endif
|
||||
#endif /* PNG_DEBUG */
|
||||
|
||||
switch (filter)
|
||||
{
|
||||
case PNG_FILTER_VALUE_NONE:
|
||||
break;
|
||||
|
||||
case PNG_FILTER_VALUE_SUB:
|
||||
{
|
||||
#if (UseMMX == 1)
|
||||
if ((row_info->pixel_depth > 8) &&
|
||||
(row_info->rowbytes >= 128) )
|
||||
if (
|
||||
(row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) &&
|
||||
(row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT))
|
||||
{
|
||||
png_read_filter_row_mmx_sub(row_info, row);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
@@ -3718,41 +3701,43 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
} //end !UseMMX
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PNG_FILTER_VALUE_UP:
|
||||
{
|
||||
#if (UseMMX == 1)
|
||||
if ((row_info->pixel_depth > 8) &&
|
||||
(row_info->rowbytes >= 128) )
|
||||
if (
|
||||
(row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) &&
|
||||
(row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT))
|
||||
{
|
||||
png_read_filter_row_mmx_up(row_info, row, prev_row);
|
||||
} //end if UseMMX
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_bytep rp;
|
||||
png_bytep pp;
|
||||
png_uint_32 i;
|
||||
for (i = 0, rp = row, pp = prev_row;
|
||||
i < row_info->rowbytes; i++, rp++, pp++)
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
png_bytep rp = row;
|
||||
png_bytep pp = prev_row;
|
||||
|
||||
for (i = 0; i < istop; ++i)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*pp)) & 0xff);
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
} //end !UseMMX
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PNG_FILTER_VALUE_AVG:
|
||||
{
|
||||
#if (UseMMX == 1)
|
||||
if ((row_info->pixel_depth > 8) &&
|
||||
(row_info->rowbytes >= 128) )
|
||||
if (
|
||||
(row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) &&
|
||||
(row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT))
|
||||
{
|
||||
png_read_filter_row_mmx_avg(row_info, row, prev_row);
|
||||
} //end if UseMMX
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_bytep rp = row;
|
||||
@@ -3774,19 +3759,19 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
|
||||
((int)(*pp++ + *lp++) >> 1)) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
} //end !UseMMX
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PNG_FILTER_VALUE_PAETH:
|
||||
{
|
||||
#if (UseMMX == 1)
|
||||
if ((row_info->pixel_depth > 8) &&
|
||||
(row_info->rowbytes >= 128) )
|
||||
if (
|
||||
(row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) &&
|
||||
(row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT))
|
||||
{
|
||||
png_read_filter_row_mmx_paeth(row_info, row, prev_row);
|
||||
} //end if UseMMX
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_bytep rp = row;
|
||||
@@ -3837,12 +3822,15 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
|
||||
*rp = (png_byte)(((int)(*rp) + p) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
} //end !UseMMX
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "Bad adaptive filter type");
|
||||
png_warning(png_ptr, "Ignoring bad row filter type");
|
||||
*row=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED && PNG_USE_PNGVCRD */
|
||||
|
||||
53
pngwio.c
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file provides a location for all output. Users who need
|
||||
* special handling are expected to write functions that have the same
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Write the data to whatever output you are using. The default routine
|
||||
writes to a file pointer. Note that this routine sometimes gets called
|
||||
@@ -24,7 +25,7 @@
|
||||
buffering if you are using unbuffered writes. This should never be asked
|
||||
to write more than 64K on a 16 bit machine. */
|
||||
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
if (png_ptr->write_data_fn != NULL )
|
||||
@@ -39,16 +40,19 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
write_data function and use it at run time with png_set_write_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
|
||||
check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr));
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||
check = 0;
|
||||
#else
|
||||
check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
||||
#endif
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* this is the model-independent version. Since the standard I/O library
|
||||
@@ -59,19 +63,24 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||
FILE *io_ptr;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (FILE *)CVT_PTR(png_ptr->io_ptr);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
if ((png_bytep)near_data == data)
|
||||
{
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !WriteFile(io_ptr, near_data, length, &check, NULL) )
|
||||
check = 0;
|
||||
#else
|
||||
check = fwrite(near_data, 1, length, io_ptr);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -83,7 +92,12 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||
png_memcpy(buf, data, written); /* copy far buffer to near buffer */
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
|
||||
err = 0;
|
||||
#else
|
||||
err = fwrite(buf, 1, written, io_ptr);
|
||||
#endif
|
||||
if (err != written)
|
||||
break;
|
||||
else
|
||||
@@ -94,9 +108,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
while (remaining != 0);
|
||||
}
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -106,7 +118,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
to disk). After png_flush is called, there should be no data pending
|
||||
writing in any buffers. */
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_flush(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn != NULL)
|
||||
@@ -114,13 +126,15 @@ png_flush(png_structp png_ptr)
|
||||
}
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
FILE *io_ptr;
|
||||
io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr));
|
||||
#if !defined(_WIN32_WCE)
|
||||
png_FILE_p io_ptr;
|
||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||
if (io_ptr != NULL)
|
||||
fflush(io_ptr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -147,7 +161,7 @@ png_default_flush(png_structp png_ptr)
|
||||
PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||
time, output_flush_fn will be ignored, although it must be
|
||||
supplied for compatibility. */
|
||||
void
|
||||
void PNGAPI
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
@@ -211,3 +225,4 @@ void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
||||
570
pngwrite.c
88
pngwtran.c
@@ -1,24 +1,28 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 1.0.5d - November 29, 1999
|
||||
* libpng 1.0.12beta1 - May 14, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_write_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_do_write_transformations\n");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if(png_ptr->write_user_transform_fn != NULL)
|
||||
@@ -79,7 +83,7 @@ png_do_write_transformations(png_structp png_ptr)
|
||||
* row_info bit depth should be 8 (one pixel per byte). The channels
|
||||
* should be 1 (this only happens on grayscale and paletted images).
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_pack\n");
|
||||
@@ -137,7 +141,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
value = (png_byte)(*sp & 0x3);
|
||||
value = (png_byte)(*sp & 0x03);
|
||||
v |= (value << shift);
|
||||
if (shift == 0)
|
||||
{
|
||||
@@ -169,7 +173,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
value = (png_byte)(*sp & 0xf);
|
||||
value = (png_byte)(*sp & 0x0f);
|
||||
v |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
@@ -205,7 +209,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
* would pass 3 as bit_depth, and this routine would translate the
|
||||
* data to 0 to 15.
|
||||
*/
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_shift\n");
|
||||
@@ -329,7 +333,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_swap_alpha\n");
|
||||
@@ -417,7 +421,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
void /* PRIVATE */
|
||||
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_invert_alpha\n");
|
||||
@@ -495,3 +499,65 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* undoes intrapixel differencing */
|
||||
void /* PRIVATE */
|
||||
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_intrapixel\n");
|
||||
if (
|
||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||
row != NULL && row_info != NULL &&
|
||||
#endif
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 3;
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 4;
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
*(rp) = (png_byte)((*rp - *(rp+1))&0xff);
|
||||
*(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff);
|
||||
}
|
||||
}
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 6;
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 8;
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0=*(rp )<<8 | *(rp+1);
|
||||
png_uint_32 s1=*(rp+2)<<8 | *(rp+3);
|
||||
png_uint_32 s2=*(rp+4)<<8 | *(rp+5);
|
||||
png_uint_32 red=(s0-s1)&0xffff;
|
||||
png_uint_32 blue=(s2-s1)&0xffff;
|
||||
*(rp ) = (png_byte)((red>>8)&0xff);
|
||||
*(rp+1) = (png_byte)(red&0xff);
|
||||
*(rp+4) = (png_byte)((blue>>8)&0xff);
|
||||
*(rp+5) = (png_byte)(blue&0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
||||
988
pngwutil.c
BIN
projects/beos/x86-shared.proj
Normal file
22
projects/beos/x86-shared.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
This project builds a shared library version of libpng on x86 BeOS.
|
||||
|
||||
It defines PNG_USE_PNGGCCRD, which activates the assembly code in
|
||||
pnggccrd.c; this hasn't been extensively tested on BeOS.
|
||||
|
||||
To install:
|
||||
|
||||
1) build
|
||||
|
||||
Note: As of version 1.0.10, you'll get a fair number of warnings when
|
||||
you compile pnggccrd.c. As far as I know, these are harmless,
|
||||
but it would be better if someone fixed them.
|
||||
|
||||
2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which
|
||||
you'll have to make) is a good choice
|
||||
|
||||
3) copy libpng.so to /boot/home/config/lib
|
||||
|
||||
4) build your libpng.so applications (remember to include libz.a as
|
||||
well when you link)
|
||||
|
||||
- Chris Herborth, March 27, 2001
|
||||
BIN
projects/beos/x86-static.proj
Normal file
22
projects/beos/x86-static.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
This project builds a static library version of libpng on x86 BeOS.
|
||||
|
||||
It defines PNG_USE_PNGGCCRD, which activates the assembly code in
|
||||
pnggccrd.c; this hasn't been extensively tested on BeOS.
|
||||
|
||||
To install:
|
||||
|
||||
1) build
|
||||
|
||||
Note: As of version 1.0.10, you'll get a fair number of warnings when
|
||||
you compile pnggccrd.c. As far as I know, these are harmless,
|
||||
but it would be better if someone fixed them.
|
||||
|
||||
2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which
|
||||
you'll have to make) is a good choice
|
||||
|
||||
3) copy libpng.a to /boot/home/config/lib
|
||||
|
||||
4) build your libpng.a applications (remember to include libz.a as
|
||||
well when you link)
|
||||
|
||||
- Chris Herborth, March 27, 2001
|
||||
22
projects/borland/libpng.bpf
Normal file
@@ -0,0 +1,22 @@
|
||||
USEUNIT("libpng.cpp");
|
||||
USEUNIT("..\..\pngwutil.c");
|
||||
USEUNIT("..\..\pngerror.c");
|
||||
USEUNIT("..\..\pngget.c");
|
||||
USEUNIT("..\..\pngmem.c");
|
||||
USEUNIT("..\..\pngpread.c");
|
||||
USEUNIT("..\..\pngread.c");
|
||||
USEUNIT("..\..\pngrio.c");
|
||||
USEUNIT("..\..\pngrtran.c");
|
||||
USEUNIT("..\..\pngrutil.c");
|
||||
USEUNIT("..\..\pngset.c");
|
||||
USEUNIT("..\..\pngtrans.c");
|
||||
USEUNIT("..\..\pngwio.c");
|
||||
USEUNIT("..\..\pngwrite.c");
|
||||
USEUNIT("..\..\pngwtran.c");
|
||||
USEUNIT("..\..\png.c");
|
||||
USELIB("zlib.lib");
|
||||
//---------------------------------------------------------------------------
|
||||
This file is used by the project manager only and should be treated like the project file
|
||||
|
||||
|
||||
DllEntryPoint
|
||||
25
projects/borland/libpng.bpg
Normal file
@@ -0,0 +1,25 @@
|
||||
#------------------------------------------------------------------------------
|
||||
VERSION = BWS.01
|
||||
#------------------------------------------------------------------------------
|
||||
!ifndef ROOT
|
||||
ROOT = $(MAKEDIR)\..
|
||||
!endif
|
||||
#------------------------------------------------------------------------------
|
||||
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
|
||||
DCC = $(ROOT)\bin\dcc32.exe $**
|
||||
BRCC = $(ROOT)\bin\brcc32.exe $**
|
||||
#------------------------------------------------------------------------------
|
||||
PROJECTS = libpngstat.lib libpng.dll
|
||||
#------------------------------------------------------------------------------
|
||||
default: $(PROJECTS)
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
libpngstat.lib: libpngstat.bpr
|
||||
$(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
|
||||
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
|
||||
|
||||
libpng.dll: libpng.bpr
|
||||
$(ROOT)\bin\bpr2mak $**
|
||||
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
|
||||
|
||||
|
||||
157
projects/borland/libpng.bpr
Normal file
@@ -0,0 +1,157 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="libpng.dll"/>
|
||||
<OBJFILES value="libpng.obj ..\..\pngwutil.obj ..\..\pngerror.obj ..\..\pngget.obj
|
||||
..\..\pngmem.obj ..\..\pngpread.obj ..\..\pngread.obj ..\..\pngrio.obj
|
||||
..\..\pngrtran.obj ..\..\pngrutil.obj ..\..\pngset.obj ..\..\pngtrans.obj
|
||||
..\..\pngwio.obj ..\..\pngwrite.obj ..\..\pngwtran.obj ..\..\png.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value="zlib.lib"/>
|
||||
<LIBRARIES value="bcbsmp50.lib dclocx50.lib NMFast50.lib Tee50.lib Vclx50.lib Vcl50.lib"/>
|
||||
<SPARELIBS value="Vcl50.lib Vclx50.lib Tee50.lib NMFast50.lib dclocx50.lib bcbsmp50.lib"/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi
|
||||
ibsmp50.bpi vcldbx50.bpi TeeUI50.bpi TeeDB50.bpi Tee50.bpi TeeQR50.bpi
|
||||
VCLIB50.bpi bcbie50.bpi vclie50.bpi Inetdb50.bpi Inet50.bpi NMFast50.bpi
|
||||
dclocx50.bpi bcb97axserver50.bpi SIMULUSCOMPONENTS.bpi Simulus2.bpi"/>
|
||||
<PATHCPP value=".;..\.."/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL"/>
|
||||
<MAINSOURCE value="libpng.bpf"/>
|
||||
<INCLUDEPATH value="..\..;..\..\..\zlib;$(BCB)\include"/>
|
||||
<LIBPATH value="..\..;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wucp -wstv -wstu -wsig -wpin
|
||||
-wnod -wnak -wdef -wcln -wbbf -wasm -wamp -wamb"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-WD -O2 -w -Vx -Ve -x- -RT- -X- -a8 -5 -b- -d -k- -vi -tWD -tWM -c"/>
|
||||
<PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zn"/>
|
||||
<LFLAGS value="-D"" -aa -Tpd -x -Gn -Gi -w"/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0d32.obj $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=1
|
||||
Locale=2057
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlIncludePath]
|
||||
Count=18
|
||||
Item0=..\..;..\..\..\zlib;$(BCB)\include
|
||||
Item1=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
|
||||
Item2=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include
|
||||
Item3=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include
|
||||
Item4=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
|
||||
Item5=..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
|
||||
Item6=..\Source\ThirdParty\PortableNetworkGraphics;P:\Development\Source\ThirdParty\ZLibCompression;$(BCB)\include
|
||||
Item7=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\include
|
||||
Item8=$(BCB)\include
|
||||
Item9=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item10=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item11=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item12=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item13=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item14=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item15=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item16=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item17=$(BCB)\include;$(BCB)\include\vcl
|
||||
|
||||
[HistoryLists\hlLibraryPath]
|
||||
Count=10
|
||||
Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item1=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item2=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item3=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item4=$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item5=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item6=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item7=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item8=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item9=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib
|
||||
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=1
|
||||
Item0=$(BCB)\source\vcl
|
||||
|
||||
[HistoryLists\hlConditionals]
|
||||
Count=20
|
||||
Item0=ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF
|
||||
Item1=_DEBUG;ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF
|
||||
Item2=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_NO_MODULEDEF
|
||||
Item3=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_NO_GLOBAL_ARRAYS
|
||||
Item4=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED;PNG_DEBUG_FILE=stderr
|
||||
Item5=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED
|
||||
Item6=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED
|
||||
Item7=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF
|
||||
Item8=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5
|
||||
Item9=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG
|
||||
Item10=PNG_BUILD_DLL;ZLIB_DLL
|
||||
Item11=PNG_BUILD_DLL
|
||||
Item12=PNG_DLL;PNG_BUILD_DLL;ZLIB_DLL
|
||||
Item13=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS;ZLIB_DLL
|
||||
Item14=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS
|
||||
Item15=PNG_DLL;PNG_BUILD_DLL
|
||||
Item16=PNG_DLL;PNG_BUILD_DLL;PNG_MODULEDEF
|
||||
Item17=_HTML_FORM
|
||||
Item18=_DEBUG;_HTML_FORM
|
||||
Item19=_DEBUG
|
||||
|
||||
[HistoryLists\hlIntOutputDir]
|
||||
Count=2
|
||||
Item0=..\Obj
|
||||
Item1=P:\Development\Obj
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=P:\Development\Executables\LibPNGTestApp.exe
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
LinkCGLIB=0
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
29
projects/borland/libpng.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <windows.h>
|
||||
//---------------------------------------------------------------------------
|
||||
// Important note about DLL memory management when your DLL uses the
|
||||
// static version of the RunTime Library:
|
||||
//
|
||||
// If your DLL exports any functions that pass String objects (or structs/
|
||||
// classes containing nested Strings) as parameter or function results,
|
||||
// you will need to add the library MEMMGR.LIB to both the DLL project and
|
||||
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
|
||||
// if any other projects which use the DLL will be performing new or delete
|
||||
// operations on any non-TObject-derived classes which are exported from the
|
||||
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
|
||||
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
|
||||
// the file BORLNDMM.DLL should be deployed along with your DLL.
|
||||
//
|
||||
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
|
||||
// ShortString parameters.
|
||||
//
|
||||
// If your DLL uses the dynamic version of the RTL, you do not need to
|
||||
// explicitly add MEMMGR.LIB as this will be done implicitly for you
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
19
projects/borland/libpng.readme.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
Project files to build libpng using Borland C++ Builder v5.0
|
||||
|
||||
To use this dll, you will need to:
|
||||
|
||||
1) add the following conditional defines to your project
|
||||
|
||||
PNG_USE_DLL
|
||||
Z_PREFIX
|
||||
|
||||
2) add the paths to png.h and zlib.h to your include path
|
||||
|
||||
3) add libpng.lib or libpngstat.lib to the project.
|
||||
|
||||
If you are using libpng.dll, libpng.dll and zlib.dll will be required for the code to run.
|
||||
|
||||
Alternatively, the libpng.dll can be built using zlibstat.lib to produce one dll containing both the zlib and png code.
|
||||
|
||||
See the libpng documentation for instructions on how to use the code.
|
||||
|
||||
22
projects/borland/libpngstat.bpf
Normal file
@@ -0,0 +1,22 @@
|
||||
USELIB("zlibstat.lib");
|
||||
USEUNIT("..\..\pngerror.c");
|
||||
USEUNIT("..\..\png.c");
|
||||
USEUNIT("..\..\pngwutil.c");
|
||||
USEUNIT("..\..\pngmem.c");
|
||||
USEUNIT("..\..\pngpread.c");
|
||||
USEUNIT("..\..\pngread.c");
|
||||
USEUNIT("..\..\pngrio.c");
|
||||
USEUNIT("..\..\pngrtran.c");
|
||||
USEUNIT("..\..\pngrutil.c");
|
||||
USEUNIT("..\..\pngset.c");
|
||||
USEUNIT("..\..\pngtrans.c");
|
||||
USEUNIT("..\..\pngwio.c");
|
||||
USEUNIT("..\..\pngwrite.c");
|
||||
USEUNIT("..\..\pngwtran.c");
|
||||
USEUNIT("..\..\pngget.c");
|
||||
//---------------------------------------------------------------------------
|
||||
#define Library
|
||||
|
||||
// To add a file to the library use the Project menu 'Add to Project'.
|
||||
|
||||
|
||||
109
projects/borland/libpngstat.bpr
Normal file
@@ -0,0 +1,109 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="libpngstat.lib"/>
|
||||
<OBJFILES value="..\..\pngerror.obj ..\..\png.obj ..\..\pngwutil.obj ..\..\pngmem.obj
|
||||
..\..\pngpread.obj ..\..\pngread.obj ..\..\pngrio.obj ..\..\pngrtran.obj
|
||||
..\..\pngrutil.obj ..\..\pngset.obj ..\..\pngtrans.obj ..\..\pngwio.obj
|
||||
..\..\pngwrite.obj ..\..\pngwtran.obj ..\..\pngget.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value="zlibstat.lib"/>
|
||||
<LIBRARIES value=""/>
|
||||
<PACKAGES value=""/>
|
||||
<PATHCPP value=".;..\.."/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<LINKER value="TLib"/>
|
||||
<USERDEFINES value=""/>
|
||||
<SYSDEFINES value="_RTLDLL;NO_STRICT"/>
|
||||
<MAINSOURCE value="libpngstat.bpf"/>
|
||||
<INCLUDEPATH value="..\..;..\..\..\zlib;$(BCB)\include"/>
|
||||
<LIBPATH value="..\..;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
<LISTFILE value=""/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-O2 -w -Vx -Ve -X- -a8 -5 -b- -d -k- -vi -c -tW -tWM"/>
|
||||
<PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
|
||||
<AFLAGS value="/mx /w2 /zn"/>
|
||||
<LFLAGS value=""/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="$(OBJFILES)"/>
|
||||
<ALLLIB value=""/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=2057
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlIncludePath]
|
||||
Count=2
|
||||
Item0=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
|
||||
Item1=..\..;$(BCB)\include;$(BCB)\include\vcl
|
||||
|
||||
[HistoryLists\hlLibraryPath]
|
||||
Count=1
|
||||
Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib
|
||||
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=1
|
||||
Item0=$(BCB)\source\vcl
|
||||
|
||||
[HistoryLists\hlConditionals]
|
||||
Count=1
|
||||
Item0=_DEBUG
|
||||
|
||||
[HistoryLists\hlTlibPageSize]
|
||||
Count=1
|
||||
Item0=0x0010
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
LinkCGLIB=0
|
||||
|
||||
[Language]
|
||||
ActiveLang=
|
||||
ProjectLang=
|
||||
RootDir=
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
33
projects/borland/zlib+libpng.bpg
Normal file
@@ -0,0 +1,33 @@
|
||||
#------------------------------------------------------------------------------
|
||||
VERSION = BWS.01
|
||||
#------------------------------------------------------------------------------
|
||||
!ifndef ROOT
|
||||
ROOT = $(MAKEDIR)\..
|
||||
!endif
|
||||
#------------------------------------------------------------------------------
|
||||
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
|
||||
DCC = $(ROOT)\bin\dcc32.exe $**
|
||||
BRCC = $(ROOT)\bin\brcc32.exe $**
|
||||
#------------------------------------------------------------------------------
|
||||
PROJECTS = zlibstat.lib libpngstat.lib zlib.dll libpng.dll
|
||||
#------------------------------------------------------------------------------
|
||||
default: $(PROJECTS)
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
libpng.dll: libpng.bpr
|
||||
$(ROOT)\bin\bpr2mak $**
|
||||
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
|
||||
|
||||
zlibstat.lib: zlibstat.bpr
|
||||
$(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
|
||||
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
|
||||
|
||||
zlib.dll: zlib.bpr
|
||||
$(ROOT)\bin\bpr2mak $**
|
||||
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
|
||||
|
||||
libpngstat.lib: libpngstat.bpr
|
||||
$(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
|
||||
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
|
||||
|
||||
|
||||
20
projects/borland/zlib.bpf
Normal file
@@ -0,0 +1,20 @@
|
||||
USEUNIT("zlib.cpp");
|
||||
USEUNIT("..\..\..\zlib\zutil.c");
|
||||
USEUNIT("..\..\..\zlib\compress.c");
|
||||
USEUNIT("..\..\..\zlib\crc32.c");
|
||||
USEUNIT("..\..\..\zlib\deflate.c");
|
||||
USEUNIT("..\..\..\zlib\gzio.c");
|
||||
USEUNIT("..\..\..\zlib\infblock.c");
|
||||
USEUNIT("..\..\..\zlib\infcodes.c");
|
||||
USEUNIT("..\..\..\zlib\inffast.c");
|
||||
USEUNIT("..\..\..\zlib\inflate.c");
|
||||
USEUNIT("..\..\..\zlib\inftrees.c");
|
||||
USEUNIT("..\..\..\zlib\infutil.c");
|
||||
USEUNIT("..\..\..\zlib\trees.c");
|
||||
USEUNIT("..\..\..\zlib\uncompr.c");
|
||||
USEUNIT("..\..\..\zlib\adler32.c");
|
||||
//---------------------------------------------------------------------------
|
||||
This file is used by the project manager only and should be treated like the project file
|
||||
|
||||
|
||||
DllEntryPoint
|
||||
25
projects/borland/zlib.bpg
Normal file
@@ -0,0 +1,25 @@
|
||||
#------------------------------------------------------------------------------
|
||||
VERSION = BWS.01
|
||||
#------------------------------------------------------------------------------
|
||||
!ifndef ROOT
|
||||
ROOT = $(MAKEDIR)\..
|
||||
!endif
|
||||
#------------------------------------------------------------------------------
|
||||
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
|
||||
DCC = $(ROOT)\bin\dcc32.exe $**
|
||||
BRCC = $(ROOT)\bin\brcc32.exe $**
|
||||
#------------------------------------------------------------------------------
|
||||
PROJECTS = zlibstat.lib zlib.dll
|
||||
#------------------------------------------------------------------------------
|
||||
default: $(PROJECTS)
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
zlibstat.lib: zlibstat.bpr
|
||||
$(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
|
||||
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
|
||||
|
||||
zlib.dll: zlib.bpr
|
||||
$(ROOT)\bin\bpr2mak $**
|
||||
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
|
||||
|
||||
|
||||
147
projects/borland/zlib.bpr
Normal file
@@ -0,0 +1,147 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="zlib.dll"/>
|
||||
<OBJFILES value="zlib.obj ..\..\..\zlib\zutil.obj ..\..\..\zlib\compress.obj
|
||||
..\..\..\zlib\crc32.obj ..\..\..\zlib\deflate.obj ..\..\..\zlib\gzio.obj
|
||||
..\..\..\zlib\infblock.obj ..\..\..\zlib\infcodes.obj
|
||||
..\..\..\zlib\inffast.obj ..\..\..\zlib\inflate.obj
|
||||
..\..\..\zlib\inftrees.obj ..\..\..\zlib\infutil.obj
|
||||
..\..\..\zlib\trees.obj ..\..\..\zlib\uncompr.obj ..\..\..\zlib\adler32.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value="bcbsmp50.lib dclocx50.lib NMFast50.lib Tee50.lib Vclx50.lib Vcl50.lib"/>
|
||||
<SPARELIBS value="Vcl50.lib Vclx50.lib Tee50.lib NMFast50.lib dclocx50.lib bcbsmp50.lib"/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi
|
||||
ibsmp50.bpi vcldbx50.bpi TeeUI50.bpi TeeDB50.bpi Tee50.bpi TeeQR50.bpi
|
||||
VCLIB50.bpi bcbie50.bpi vclie50.bpi Inetdb50.bpi Inet50.bpi NMFast50.bpi
|
||||
dclocx50.bpi bcb97axserver50.bpi SIMULUSCOMPONENTS.bpi Simulus2.bpi"/>
|
||||
<PATHCPP value=".;..\..\..\zlib"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="ZLIB_DLL;Z_PREFIX"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL"/>
|
||||
<MAINSOURCE value="zlib.bpf"/>
|
||||
<INCLUDEPATH value="..\..\..\zlib;$(BCB)\include"/>
|
||||
<LIBPATH value="..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wuse -wucp -wstv -wstu -wpin
|
||||
-w-par -wnod -wnak -wdef -wcln -wbbf -w-aus -wasm -wamp -wamb"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-WD -O2 -w -Vx -Ve -x- -RT- -ff -X- -a8 -5 -b- -d -k- -vi -tWD -tWM -c"/>
|
||||
<PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zn"/>
|
||||
<LFLAGS value="-D"" -aa -Tpd -x -Gn -Gi -w"/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0d32.obj $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=1
|
||||
Locale=2057
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlIncludePath]
|
||||
Count=16
|
||||
Item0=..\..\..\zlib;$(BCB)\include
|
||||
Item1=..\..\..;..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\include
|
||||
Item2=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\include
|
||||
Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
|
||||
Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
|
||||
Item5=..\Source\ThirdParty\ZLibCompression;$(BCB)\include
|
||||
Item6=$(BCB)\include
|
||||
Item7=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item8=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item9=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item10=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item11=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item12=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item13=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item14=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl
|
||||
Item15=$(BCB)\include;$(BCB)\include\vcl
|
||||
|
||||
[HistoryLists\hlLibraryPath]
|
||||
Count=12
|
||||
Item0=..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item1=..\..\..;..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item2=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item5=$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item6=..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item7=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item8=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item9=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item10=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item11=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib
|
||||
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=1
|
||||
Item0=$(BCB)\source\vcl
|
||||
|
||||
[HistoryLists\hlConditionals]
|
||||
Count=8
|
||||
Item0=ZLIB_DLL;Z_PREFIX
|
||||
Item1=ZLIB_DLL;_DEBUG;Z_PREFIX
|
||||
Item2=ZLIB_DLL;_DEBUG
|
||||
Item3=ZLIB_DLL
|
||||
Item4=_WINDOWS;ZLIB_DLL
|
||||
Item5=_HTML_FORM
|
||||
Item6=_DEBUG;_HTML_FORM
|
||||
Item7=_DEBUG
|
||||
|
||||
[HistoryLists\hlIntOutputDir]
|
||||
Count=2
|
||||
Item0=..\Obj
|
||||
Item1=P:\Development\Obj
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
LinkCGLIB=0
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
30
projects/borland/zlib.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <windows.h>
|
||||
//---------------------------------------------------------------------------
|
||||
// Important note about DLL memory management when your DLL uses the
|
||||
// static version of the RunTime Library:
|
||||
//
|
||||
// If your DLL exports any functions that pass String objects (or structs/
|
||||
// classes containing nested Strings) as parameter or function results,
|
||||
// you will need to add the library MEMMGR.LIB to both the DLL project and
|
||||
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
|
||||
// if any other projects which use the DLL will be performing new or delete
|
||||
// operations on any non-TObject-derived classes which are exported from the
|
||||
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
|
||||
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
|
||||
// the file BORLNDMM.DLL should be deployed along with your DLL.
|
||||
//
|
||||
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
|
||||
// ShortString parameters.
|
||||
//
|
||||
// If your DLL uses the dynamic version of the RTL, you do not need to
|
||||
// explicitly add MEMMGR.LIB as this will be done implicitly for you
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
20
projects/borland/zlibstat.bpf
Normal file
@@ -0,0 +1,20 @@
|
||||
USEUNIT("..\..\..\zlib\zutil.c");
|
||||
USEUNIT("..\..\..\zlib\compress.c");
|
||||
USEUNIT("..\..\..\zlib\crc32.c");
|
||||
USEUNIT("..\..\..\zlib\deflate.c");
|
||||
USEUNIT("..\..\..\zlib\gzio.c");
|
||||
USEUNIT("..\..\..\zlib\infblock.c");
|
||||
USEUNIT("..\..\..\zlib\infcodes.c");
|
||||
USEUNIT("..\..\..\zlib\inffast.c");
|
||||
USEUNIT("..\..\..\zlib\inflate.c");
|
||||
USEUNIT("..\..\..\zlib\inftrees.c");
|
||||
USEUNIT("..\..\..\zlib\infutil.c");
|
||||
USEUNIT("..\..\..\zlib\trees.c");
|
||||
USEUNIT("..\..\..\zlib\uncompr.c");
|
||||
USEUNIT("..\..\..\zlib\adler32.c");
|
||||
//---------------------------------------------------------------------------
|
||||
#define Library
|
||||
|
||||
// To add a file to the library use the Project menu 'Add to Project'.
|
||||
|
||||
|
||||
131
projects/borland/zlibstat.bpr
Normal file
@@ -0,0 +1,131 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="zlibstat.lib"/>
|
||||
<OBJFILES value="..\..\..\zlib\zutil.obj ..\..\..\zlib\compress.obj ..\..\..\zlib\crc32.obj
|
||||
..\..\..\zlib\deflate.obj ..\..\..\zlib\gzio.obj
|
||||
..\..\..\zlib\infblock.obj ..\..\..\zlib\infcodes.obj
|
||||
..\..\..\zlib\inffast.obj ..\..\..\zlib\inflate.obj
|
||||
..\..\..\zlib\inftrees.obj ..\..\..\zlib\infutil.obj
|
||||
..\..\..\zlib\trees.obj ..\..\..\zlib\uncompr.obj ..\..\..\zlib\adler32.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value=""/>
|
||||
<PACKAGES value=""/>
|
||||
<PATHCPP value=".;..\..\..\zlib"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<LINKER value="TLib"/>
|
||||
<USERDEFINES value="Z_PREFIX"/>
|
||||
<SYSDEFINES value="_RTLDLL;NO_STRICT"/>
|
||||
<MAINSOURCE value="zlibstat.bpf"/>
|
||||
<INCLUDEPATH value="..\..\..\zlib;$(BCB)\include"/>
|
||||
<LIBPATH value="..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wuse -wucp -wstv -wstu -wpin
|
||||
-wnod -wnak -wdef -wcln -wbbf -w-aus -wasm -wamp -wamb"/>
|
||||
<LISTFILE value=""/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<CFLAG1 value="-O2 -w -Vx -Ve -x- -RT- -X- -a8 -5 -b- -d -k- -vi -c -tW -tWM"/>
|
||||
<PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
|
||||
<AFLAGS value="/mx /w2 /zn"/>
|
||||
<LFLAGS value=""/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="$(OBJFILES)"/>
|
||||
<ALLLIB value=""/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=2057
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlIncludePath]
|
||||
Count=8
|
||||
Item0=..\..\..\zlib;$(BCB)\include
|
||||
Item1=..\Source\ThirdParty\ZLibCompression\external;..\..\..\zlib;$(BCB)\include
|
||||
Item2=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
|
||||
Item3=..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include
|
||||
Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression\ext;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
|
||||
Item5=..\Source\ThirdParty\ZLibCompression;$(BCB)\include
|
||||
Item6=$(BCB)\include
|
||||
Item7=$(BCB)\include;$(BCB)\include\vcl
|
||||
|
||||
[HistoryLists\hlLibraryPath]
|
||||
Count=7
|
||||
Item0=..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item1=$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item2=..\Source\ThirdParty\ZLibCompression\external;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item4=..\Source\ThirdParty\ZLibCompression\external;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item5=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression\ext;..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Item6=..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
|
||||
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=1
|
||||
Item0=$(BCB)\source\vcl
|
||||
|
||||
[HistoryLists\hlConditionals]
|
||||
Count=3
|
||||
Item0=Z_PREFIX
|
||||
Item1=ZLIB_DLL
|
||||
Item2=_WINDOWS;ZLIB_DLL
|
||||
|
||||
[HistoryLists\hlIntOutputDir]
|
||||
Count=2
|
||||
Item0=..\Obj
|
||||
Item1=P:\Development\Obj
|
||||
|
||||
[HistoryLists\hlTlibPageSize]
|
||||
Count=1
|
||||
Item0=0x0010
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=0
|
||||
LinkCGLIB=0
|
||||
|
||||
[Language]
|
||||
ActiveLang=
|
||||
ProjectLang=
|
||||
RootDir=
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
||||
47
projects/msvc/README.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
Microsoft Developer Studio Build File, Format Version 6.00 for
|
||||
libpng 1.0.12beta1 (May 14, 2001) and zlib
|
||||
|
||||
Copyright (C) 2000 Simon-Pierre Cadieux
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
Assumes that libpng sources are in ..\..
|
||||
Assumes that zlib sources have been copied to ..\..\..\zlib
|
||||
|
||||
To build:
|
||||
|
||||
1) On the main menu Select "Build|Set Active configuration".
|
||||
Among the configurations beginning with "libpng" select the
|
||||
one you wish to build (the corresponding "zlib" configuration
|
||||
will be built automatically).
|
||||
|
||||
2) Select "Build|Clean"
|
||||
|
||||
3) Select "Build|Rebuild All"
|
||||
|
||||
4) Look in the appropriate "win32" subdirectories for both "zlib"
|
||||
and "libpng" binaries.
|
||||
|
||||
This project will build the PNG Development Group's "official" versions of
|
||||
libpng and zlib libraries:
|
||||
|
||||
libpng2.dll (default version, currently C code only)
|
||||
libpng2.dll (C + Assembler version)
|
||||
libpng2.dll (C + Assembler debug version)
|
||||
libpng2.dll (C code debug version)
|
||||
libpng2[c,e-m].dll (reserved for official versions)
|
||||
libpng2[n-z].dll (available for private versions)
|
||||
zlib.dll (default version, currently C code only)
|
||||
zlibd.dll (debug version)
|
||||
|
||||
If you change anything in libpng, or select different compiler settings,
|
||||
please change the library name to an unreserved name, and define
|
||||
DLLFNAME_POSTFIX and (PRIVATEBUILD or SPECIALBUILD) accordingly. DLLFNAME_POSTFIX
|
||||
should correspond to a string in the range of "N" to "Z" depending on the letter
|
||||
you choose for your private version.
|
||||
|
||||
All DLLs built by this project use the Microsoft dynamic C runtime library
|
||||
MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the
|
||||
above mentioned libraries you should also include this DLL in your package.
|
||||
For a list of files that are redistributable in Visual C++ 6.0, see
|
||||
Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs.
|
||||
|
||||
367
projects/msvc/libpng.dsp
Normal file
@@ -0,0 +1,367 @@
|
||||
# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=libpng - Win32 DLL
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "libpng.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "libpng - Win32 DLL" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libpng - Win32 DLL ASM" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libpng - Win32 DLL Debug ASM" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libpng - Win32 LIB" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
|
||||
!IF "$(CFG)" == "libpng - Win32 DLL"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\win32\libpng\dll"
|
||||
# PROP Intermediate_Dir ".\win32\libpng\dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /dll /machine:I386
|
||||
# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng2.dll"
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\win32\libpng\dll_dbg"
|
||||
# PROP Intermediate_Dir ".\win32\libpng\dll_dbg"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /GZ /c
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbg\libpng2d.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\win32\libpng\dll_asm"
|
||||
# PROP Intermediate_Dir ".\win32\libpng\dll_asm"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d "PNG_USE_PNGVCRD"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /dll /machine:I386
|
||||
# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_asm\libpng2a.dll"
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\win32\libpng\dll_dbga"
|
||||
# PROP Intermediate_Dir ".\win32\libpng\dll_dbga"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /GZ /c
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d "PNG_USE_PNGVCRD"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbga\libpng2b.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 LIB"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\win32\libpng\lib"
|
||||
# PROP Intermediate_Dir ".\win32\libpng\lib"
|
||||
# PROP Target_Dir ""
|
||||
MTL=midl.exe
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c
|
||||
# ADD CPP /nologo /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /Yu"png.h" /FD /c
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\win32\libpng\lib_dbg"
|
||||
# PROP Intermediate_Dir ".\win32\libpng\lib_dbg"
|
||||
# PROP Target_Dir ""
|
||||
MTL=midl.exe
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_LIB" /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /Yu"png.h" /FD /GZ /c
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "libpng - Win32 DLL"
|
||||
# Name "libpng - Win32 DLL Debug"
|
||||
# Name "libpng - Win32 DLL ASM"
|
||||
# Name "libpng - Win32 DLL Debug ASM"
|
||||
# Name "libpng - Win32 LIB"
|
||||
# Name "libpng - Win32 LIB Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\png.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\png.rc
|
||||
|
||||
!IF "$(CFG)" == "libpng - Win32 DLL"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 LIB"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\png32ms.def
|
||||
|
||||
!IF "$(CFG)" == "libpng - Win32 DLL"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 LIB"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngerror.c
|
||||
# ADD CPP /Yc"png.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngget.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngmem.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngpread.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngread.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngrio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngrtran.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngrutil.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngset.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngtrans.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngvcrd.c
|
||||
|
||||
!IF "$(CFG)" == "libpng - Win32 DLL"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 LIB"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngwio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngwrite.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngwtran.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngwutil.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\png.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pngconf.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
44
projects/msvc/libpng.dsw
Normal file
@@ -0,0 +1,44 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "libpng"=.\libpng.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name zlib
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "zlib"=.\zlib.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
100
projects/msvc/png.rc
Normal file
@@ -0,0 +1,100 @@
|
||||
#define PNG_VERSION_INFO_ONLY
|
||||
|
||||
#include <windows.h>
|
||||
#include "png.h"
|
||||
|
||||
#define _QUOTE(x) # x
|
||||
#define QUOTE(x) _QUOTE(x)
|
||||
|
||||
#define PNG_LIBPNG_DLLFNAME "LIBPNG"
|
||||
|
||||
#if defined(DLLFNAME_POSTFIX) && !defined(PRIVATEBUILD) && !defined(SPECIALBUILD)
|
||||
# error PRIVATEBUILD or SPECIALBUILD must be defined as a string describing the type of change brought to the standard library
|
||||
#endif /* defined(DLLFNAME_POSTFIX)... */
|
||||
|
||||
#if !defined(DLLFNAME_POSTFIX) && defined(PNG_USE_PNGVCRD)
|
||||
# if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
|
||||
# define DLLFNAME_POSTFIX "B"
|
||||
# else
|
||||
# define DLLFNAME_POSTFIX "A"
|
||||
# endif /* !defined(DLLFNAME_POSTFIX)... */
|
||||
# if !defined(SPECIALBUILD)
|
||||
# define SPECIALBUILD "Use MMX instructions"
|
||||
# endif /* SPECIALBUILD */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
|
||||
# define VS_DEBUG VS_FF_DEBUG
|
||||
# ifndef DLLFNAME_POSTFIX
|
||||
# define DLLFNAME_POSTFIX "D"
|
||||
# endif /* DLLFNAME_POSTFIX */
|
||||
# ifndef COMMENTS
|
||||
# define COMMENTS "PNG_DEBUG=" QUOTE(PNG_DEBUG)
|
||||
# endif /* COMMENTS */
|
||||
#else
|
||||
# define VS_DEBUG 0
|
||||
# ifndef DLLFNAME_POSTFIX
|
||||
# define DLLFNAME_POSTFIX
|
||||
# endif /* DLLFNAME_POSTFIX */
|
||||
#endif /* defined(DEBUG)... */
|
||||
|
||||
#ifdef PRIVATEBUILD
|
||||
# define VS_PRIVATEBUILD VS_FF_PRIVATEBUILD
|
||||
#else
|
||||
# define VS_PRIVATEBUILD 0
|
||||
#endif /* PRIVATEBUILD */
|
||||
|
||||
#ifdef SPECIALBUILD
|
||||
# define VS_SPECIALBUILD VS_FF_SPECIALBUILD
|
||||
#else
|
||||
# define VS_SPECIALBUILD 0
|
||||
#endif /* SPECIALBUILD */
|
||||
|
||||
#if ((PNG_LIBPNG_BUILD_TYPE & PNG_LIBPNG_BUILD_TYPEMASK) != \
|
||||
PNG_LIBPNG_BUILD_STABLE)
|
||||
# define VS_PRERELEASE VS_FF_PRERELEASE
|
||||
# define VS_PATCHED 0
|
||||
#else
|
||||
# define VS_PRERELEASE 0
|
||||
# if (PNG_LIBPNG_BUILD_TYPE & PNG_LIBPNG_BUILD_PATCHED)
|
||||
# define VS_PATCHED VS_FF_PATCHED
|
||||
# else
|
||||
# define VS_PATCHED 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD
|
||||
PRODUCTVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS VS_DEBUG | VS_PRIVATEBUILD | VS_SPECIALBUILD | VS_PRERELEASE | VS_PATCHED
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN BLOCK "040904E4" /* Language type = U.S English(0x0409) and Character Set = Windows, Multilingual(0x04E4) */
|
||||
BEGIN
|
||||
#ifdef COMMENTS
|
||||
VALUE "Comments", COMMENTS "\000"
|
||||
#endif /* COMMENTS */
|
||||
VALUE "FileDescription", "PNG image compression library\000"
|
||||
VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000"
|
||||
VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX " (Windows 32 bit)\000"
|
||||
VALUE "LegalCopyright", "\251 1998-2000 Glenn Randers-Pehrson\000"
|
||||
VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX ".DLL\000"
|
||||
#ifdef PRIVATEBUILD
|
||||
VALUE "PrivateBuild", PRIVATEBUILD
|
||||
#endif /* PRIVATEBUILD */
|
||||
VALUE "ProductName", "LibPNG\000"
|
||||
VALUE "ProductVersion", "1\000"
|
||||
#ifdef SPECIALBUILD
|
||||
VALUE "SpecialBuild", SPECIALBUILD
|
||||
#endif /* SPECIALBUILD */
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0409, 0x04E4
|
||||
END
|
||||
END
|
||||
213
projects/msvc/png32ms.def
Normal file
@@ -0,0 +1,213 @@
|
||||
;------------------------------------------
|
||||
; LIBPNG module definition file for Windows
|
||||
;------------------------------------------
|
||||
|
||||
LIBRARY
|
||||
DESCRIPTION "PNG image compression library for Windows"
|
||||
|
||||
EXPORTS
|
||||
;Version 1.0.12beta1
|
||||
png_build_grayscale_palette @1
|
||||
png_check_sig @2
|
||||
png_chunk_error @3
|
||||
png_chunk_warning @4
|
||||
png_convert_from_struct_tm @5
|
||||
png_convert_from_time_t @6
|
||||
png_create_info_struct @7
|
||||
png_create_read_struct @8
|
||||
png_create_write_struct @9
|
||||
png_data_freer @10
|
||||
png_destroy_info_struct @11
|
||||
png_destroy_read_struct @12
|
||||
png_destroy_write_struct @13
|
||||
png_error @14
|
||||
png_free @15
|
||||
png_free_data @16
|
||||
png_get_IHDR @17
|
||||
png_get_PLTE @18
|
||||
png_get_bKGD @19
|
||||
png_get_bit_depth @20
|
||||
png_get_cHRM @21
|
||||
png_get_cHRM_fixed @22
|
||||
png_get_channels @23
|
||||
png_get_color_type @24
|
||||
png_get_compression_buffer_size @25
|
||||
png_get_compression_type @26
|
||||
png_get_copyright @27
|
||||
png_get_error_ptr @28
|
||||
png_get_filter_type @29
|
||||
png_get_gAMA @30
|
||||
png_get_gAMA_fixed @31
|
||||
png_get_hIST @32
|
||||
png_get_header_ver @33
|
||||
png_get_header_version @34
|
||||
png_get_iCCP @35
|
||||
png_get_image_height @36
|
||||
png_get_image_width @37
|
||||
png_get_interlace_type @38
|
||||
png_get_io_ptr @39
|
||||
png_get_libpng_ver @40
|
||||
png_get_oFFs @41
|
||||
png_get_pCAL @42
|
||||
png_get_pHYs @43
|
||||
png_get_pixel_aspect_ratio @44
|
||||
png_get_pixels_per_meter @45
|
||||
png_get_progressive_ptr @46
|
||||
png_get_rgb_to_gray_status @47
|
||||
png_get_rowbytes @48
|
||||
png_get_rows @49
|
||||
png_get_sBIT @50
|
||||
png_get_sCAL @51
|
||||
png_get_sPLT @52
|
||||
png_get_sRGB @53
|
||||
png_get_signature @54
|
||||
png_get_tIME @55
|
||||
png_get_tRNS @56
|
||||
png_get_text @57
|
||||
png_get_unknown_chunks @58
|
||||
png_get_user_chunk_ptr @59
|
||||
png_get_user_transform_ptr @60
|
||||
png_get_valid @61
|
||||
png_get_x_offset_microns @62
|
||||
png_get_x_offset_pixels @63
|
||||
png_get_x_pixels_per_meter @64
|
||||
png_get_y_offset_microns @65
|
||||
png_get_y_offset_pixels @66
|
||||
png_get_y_pixels_per_meter @67
|
||||
png_malloc @68
|
||||
png_memcpy_check @69
|
||||
png_memset_check @70
|
||||
; png_permit_empty_plte is deprecated
|
||||
png_permit_empty_plte @71
|
||||
png_process_data @72
|
||||
png_progressive_combine_row @73
|
||||
png_read_end @74
|
||||
png_read_image @75
|
||||
png_read_info @76
|
||||
; png_read_init is deprecated
|
||||
png_read_init @77
|
||||
png_read_png @78
|
||||
png_read_row @79
|
||||
png_read_rows @80
|
||||
png_read_update_info @81
|
||||
png_reset_zstream @82
|
||||
png_set_IHDR @83
|
||||
png_set_PLTE @84
|
||||
png_set_bKGD @85
|
||||
png_set_background @86
|
||||
png_set_bgr @87
|
||||
png_set_cHRM @88
|
||||
png_set_cHRM_fixed @89
|
||||
png_set_compression_buffer_size @90
|
||||
png_set_compression_level @91
|
||||
png_set_compression_mem_level @92
|
||||
png_set_compression_method @93
|
||||
png_set_compression_strategy @94
|
||||
png_set_compression_window_bits @95
|
||||
png_set_crc_action @96
|
||||
png_set_dither @97
|
||||
png_set_error_fn @98
|
||||
png_set_expand @99
|
||||
png_set_filler @100
|
||||
png_set_filter @101
|
||||
png_set_filter_heuristics @102
|
||||
png_set_flush @103
|
||||
png_set_gAMA @104
|
||||
png_set_gAMA_fixed @105
|
||||
png_set_gamma @106
|
||||
png_set_gray_1_2_4_to_8 @107
|
||||
png_set_gray_to_rgb @108
|
||||
png_set_hIST @109
|
||||
png_set_iCCP @110
|
||||
png_set_interlace_handling @111
|
||||
png_set_invert_alpha @112
|
||||
png_set_invert_mono @113
|
||||
png_set_keep_unknown_chunks @114
|
||||
png_set_oFFs @115
|
||||
png_set_pCAL @116
|
||||
png_set_pHYs @117
|
||||
png_set_packing @118
|
||||
png_set_packswap @119
|
||||
png_set_palette_to_rgb @120
|
||||
png_set_progressive_read_fn @121
|
||||
png_set_read_fn @122
|
||||
png_set_read_status_fn @123
|
||||
png_set_read_user_chunk_fn @124
|
||||
png_set_read_user_transform_fn @125
|
||||
png_set_rgb_to_gray @126
|
||||
png_set_rgb_to_gray_fixed @127
|
||||
png_set_rows @128
|
||||
png_set_sBIT @129
|
||||
png_set_sCAL @130
|
||||
png_set_sPLT @131
|
||||
png_set_sRGB @132
|
||||
png_set_sRGB_gAMA_and_cHRM @133
|
||||
png_set_shift @134
|
||||
png_set_sig_bytes @135
|
||||
png_set_strip_16 @136
|
||||
png_set_strip_alpha @137
|
||||
png_set_swap @138
|
||||
png_set_swap_alpha @139
|
||||
png_set_tIME @140
|
||||
png_set_tRNS @141
|
||||
png_set_tRNS_to_alpha @142
|
||||
png_set_text @143
|
||||
png_set_unknown_chunk_location @144
|
||||
png_set_unknown_chunks @145
|
||||
png_set_user_transform_info @146
|
||||
png_set_write_fn @147
|
||||
png_set_write_status_fn @148
|
||||
png_set_write_user_transform_fn @149
|
||||
png_sig_cmp @150
|
||||
png_start_read_image @151
|
||||
png_warning @152
|
||||
png_write_chunk @153
|
||||
png_write_chunk_data @154
|
||||
png_write_chunk_end @155
|
||||
png_write_chunk_start @156
|
||||
png_write_end @157
|
||||
png_write_flush @158
|
||||
png_write_image @159
|
||||
png_write_info @160
|
||||
png_write_info_before_PLTE @161
|
||||
; png_write_init is deprecated
|
||||
png_write_init @162
|
||||
png_write_png @163
|
||||
png_write_row @164
|
||||
png_write_rows @165
|
||||
; png_read_init_2 and png_write_init_2 are deprecated.
|
||||
png_read_init_2 @166
|
||||
png_write_init_2 @167
|
||||
png_access_version_number @168
|
||||
; png_sig_bytes @169
|
||||
; png_libpng_ver @170
|
||||
png_init_io @171
|
||||
png_convert_to_rfc1123 @172
|
||||
png_set_invalid @173
|
||||
; Added at version 1.0.12
|
||||
; For compatiblity with 1.0.7-1.0.11
|
||||
png_info_init @174
|
||||
png_read_init_3 @175
|
||||
png_write_init_3 @176
|
||||
png_info_init_3 @177
|
||||
png_destroy_struct @178
|
||||
; To be added at version 1.2.0
|
||||
; For use with PNG_USER_MEM_SUPPORTED
|
||||
; png_destroy_struct_2 @179
|
||||
; png_create_read_struct_2 @180
|
||||
; png_create_write_struct_2 @181
|
||||
; png_malloc_default @182
|
||||
; png_free_default @183
|
||||
; MNG features
|
||||
; png_permit_mng_features @184
|
||||
; MMX support
|
||||
; png_mmx_support @185
|
||||
; png_get_mmx_flagmask @186
|
||||
; png_get_asm_flagmask @187
|
||||
; png_get_asm_flags @188
|
||||
; png_get_mmx_bitdepth_threshold @189
|
||||
; png_get_mmx_rowbytes_threshold @190
|
||||
; png_set_asm_flags @191
|
||||
; png_init_mmx_flags @192
|
||||
; Strip error numbers
|
||||
; png_set_strip_error_numbers @193
|
||||
45
projects/msvc/zlib.def
Normal file
@@ -0,0 +1,45 @@
|
||||
LIBRARY
|
||||
DESCRIPTION "zlib compression library for Windows"
|
||||
|
||||
EXPORTS
|
||||
adler32 @1
|
||||
compress @2
|
||||
crc32 @3
|
||||
deflate @4
|
||||
deflateCopy @5
|
||||
deflateEnd @6
|
||||
deflateInit2_ @7
|
||||
deflateInit_ @8
|
||||
deflateParams @9
|
||||
deflateReset @10
|
||||
deflateSetDictionary @11
|
||||
gzclose @12
|
||||
gzdopen @13
|
||||
gzerror @14
|
||||
gzflush @15
|
||||
gzopen @16
|
||||
gzread @17
|
||||
gzwrite @18
|
||||
inflate @19
|
||||
inflateEnd @20
|
||||
inflateInit2_ @21
|
||||
inflateInit_ @22
|
||||
inflateReset @23
|
||||
inflateSetDictionary @24
|
||||
inflateSync @25
|
||||
uncompress @26
|
||||
zlibVersion @27
|
||||
gzprintf @28
|
||||
gzputc @29
|
||||
gzgetc @30
|
||||
gzseek @31
|
||||
gzrewind @32
|
||||
gztell @33
|
||||
gzeof @34
|
||||
gzsetparams @35
|
||||
zError @36
|
||||
inflateSyncPoint @37
|
||||
get_crc_table @38
|
||||
compress2 @39
|
||||
gzputs @40
|
||||
gzgets @41
|
||||