diff --git a/BrokenSuite.md b/BrokenSuite.md new file mode 100644 index 0000000..163beed --- /dev/null +++ b/BrokenSuite.md @@ -0,0 +1,131 @@ +## Introduction ## + +As a means of increasing test coverage, I started working on suite of images to cover all the possible error cases. It has subsequently also been used to improve the excellent [pngcheck](http://www.libpng.org/pub/png/apps/pngcheck.html) tool. + +The code to generate the images is checked in: +[BrokenGenerator.java](http://javapng.googlecode.com/svn/trunk/javapng2/src/test/BrokenGenerator.java). In general I try to pick a simple image +from [PngSuite](http://www.schaik.com/pngsuite/) and mutate it by swapping chunks, adding in new chunks, etc. Contributions are welcome. + +## Download ## + +All releases are tagged with the [BrokenSuite label](http://code.google.com/p/javapng/downloads/list?q=label:BrokenSuite). + +## Images ## + +This table lists all of the images in the latest release and the corresponding errors (the message of the exception that will be thrown). + +| x00n0g01.png | Bad image size: 0x0 | +|:-------------|:--------------------| +| xcrn0g04.png | Improper signature, expected 0x89504e470d0a1a0a, got 0x89504e470d0d0a1a | +| xlfn0g04.png | Improper signature, expected 0x89504e470d0a1a0a, got 0x89504e470a0a0a1a | +| bkgd\_after\_idat.png | bKGD cannot appear after IDAT | +| chrm\_after\_idat.png | cHRM cannot appear after IDAT | +| chrm\_after\_plte.png | cHRM cannot appear after PLTE | +| chunk\_crc.png | Bad CRC value for IHDR chunk | +| chunk\_length.png | Bad chunk length: 4294967276 | +| chunk\_private\_critical.png | Private critical chunk encountered: GaMA | +| chunk\_type.png | Corrupted chunk type: 0x67614d5f | +| gama\_after\_idat.png | gAMA cannot appear after IDAT | +| gama\_after\_plte.png | gAMA cannot appear after PLTE | +| gama\_zero.png | Meaningless zero gAMA chunk value | +| hist\_after\_idat.png | hIST cannot appear after IDAT | +| hist\_before\_plte.png | PLTE must precede hIST | +| iccp\_after\_idat.png | iCCP cannot appear after IDAT | +| iccp\_after\_plte.png | iCCP cannot appear after PLTE | +| ihdr\_16bit\_palette.png | Bad bit depth for color type 3: 16 | +| ihdr\_1bit\_alpha.png | Bad bit depth for color type 6: 1 | +| ihdr\_bit\_depth.png | Bad bit depth: 7 | +| ihdr\_color\_type.png | Bad color type: 1 | +| ihdr\_compression\_method.png | Unrecognized compression method: 1 | +| ihdr\_filter\_method.png | Unrecognized filter method: 1 | +| ihdr\_image\_size.png | Bad image size: -32x-32 | +| ihdr\_interlace\_method.png | Unrecognized interlace method: 2 | +| itxt\_compression\_flag.png | Illegal iTXt compression flag: 2 | +| itxt\_compression\_method.png | Unrecognized iTXt compression method: 1 | +| itxt\_keyword\_length.png | Invalid keyword length: 0 | +| itxt\_keyword\_length\_2.png | Invalid keyword length: 80 | +| missing\_idat.png | Required data chunk(s) not found | +| missing\_ihdr.png | IHDR chunk must be first chunk | +| missing\_plte.png | Required PLTE chunk not found | +| missing\_plte\_2.png | Required PLTE chunk not found | +| multiple\_bkgd.png | Multiple bKGD chunks are not allowed | +| multiple\_chrm.png | Multiple cHRM chunks are not allowed | +| multiple\_gama.png | Multiple gAMA chunks are not allowed | +| multiple\_hist.png | Multiple hIST chunks are not allowed | +| multiple\_iccp.png | Multiple iCCP chunks are not allowed | +| multiple\_ihdr.png | Multiple IHDR chunks are not allowed | +| multiple\_offs.png | Multiple oFFs chunks are not allowed | +| multiple\_pcal.png | Multiple pCAL chunks are not allowed | +| multiple\_phys.png | Multiple pHYs chunks are not allowed | +| multiple\_plte.png | Multiple PLTE chunks are not allowed | +| multiple\_sbit.png | Multiple sBIT chunks are not allowed | +| multiple\_scal.png | Multiple sCAL chunks are not allowed | +| multiple\_srgb.png | Multiple sRGB chunks are not allowed | +| multiple\_ster.png | Multiple sTER chunks are not allowed | +| multiple\_time.png | Multiple tIME chunks are not allowed | +| multiple\_trns.png | Multiple tRNS chunks are not allowed | +| nonconsecutive\_idat.png | IDAT chunks must be consecutive | +| offs\_after\_idat.png | oFFs cannot appear after IDAT | +| pcal\_after\_idat.png | pCAL cannot appear after IDAT | +| phys\_after\_idat.png | pHYs cannot appear after IDAT | +| plte\_after\_idat.png | Required PLTE chunk not found | +| plte\_empty.png | PLTE chunk cannot be empty | +| plte\_in\_grayscale.png | PLTE chunk found in grayscale image | +| plte\_length\_mod\_three.png | PLTE chunk length indivisible by 3: 2 | +| plte\_too\_many\_entries.png | Too many palette entries: 17 | +| plte\_too\_many\_entries\_2.png | Too many palette entries: 257 | +| sbit\_after\_idat.png | sBIT cannot appear after IDAT | +| sbit\_after\_plte.png | sBIT cannot appear after PLTE | +| scal\_after\_idat.png | sCAL cannot appear after IDAT | +| splt\_after\_idat.png | sPLT cannot appear after IDAT | +| srgb\_after\_idat.png | sRGB cannot appear after IDAT | +| srgb\_after\_plte.png | sRGB cannot appear after PLTE | +| ster\_after\_idat.png | sTER cannot appear after IDAT | +| time\_value\_range.png | tIME month value 0 is out of bounds (1-12) | +| trns\_after\_idat.png | tRNS cannot appear after IDAT | +| trns\_bad\_color\_type.png | tRNS prohibited for color type 6 | +| trns\_too\_many\_entries.png | Too many transparency palette entries (200 > 173) | +| phys\_unit\_specifier.png | Illegal pHYs chunk unit specifier: 2 | +| offs\_unit\_specifier.png | Illegal oFFs chunk unit specifier: 2 | +| scal\_unit\_specifier.png | Illegal sCAL chunk unit specifier: 3 | +| scal\_floating\_point.png | For input string: "Q.527777777778" | +| scal\_negative.png | sCAL measurements must be >= 0 | +| scal\_zero.png | sCAL measurements must be >= 0 | +| sbit\_sample\_depth.png | Illegal sBIT sample depth | +| sbit\_sample\_depth\_2.png | Illegal sBIT sample depth | +| ster\_mode.png | Unknown sTER mode: 2 | +| splt\_sample\_depth.png | Sample depth must be 8 or 16 | +| splt\_length\_mod\_6.png | Incorrect sPLT data length for given sample depth | +| splt\_length\_mod\_10.png | Incorrect sPLT data length for given sample depth | +| splt\_duplicate\_name.png | Duplicate suggested palette name Lemonade | +| ztxt\_compression\_method.png | Unrecognized compression method: 3 | +| ztxt\_data\_format.png | unknown compression method | +| length\_ihdr.png | Bad IHDR chunk length: 14 (expected 13) | +| length\_iend.png | Bad IEND chunk length: 1 (expected 0) | +| length\_ster.png | Bad sTER chunk length: 2 (expected 1) | +| length\_srgb.png | Bad sRGB chunk length: 2 (expected 1) | +| length\_gama.png | Bad gAMA chunk length: 3 (expected 4) | +| length\_phys.png | Bad pHYs chunk length: 8 (expected 9) | +| length\_time.png | Bad tIME chunk length: 6 (expected 7) | +| length\_offs.png | Bad oFFs chunk length: 8 (expected 9) | +| length\_chrm.png | Bad cHRM chunk length: 31 (expected 32) | +| length\_gifg.png | Bad gIFg chunk length: 5 (expected 4) | +| length\_trns\_gray.png | Bad tRNS chunk length: 0 (expected 2) | +| length\_trns\_rgb.png | Bad tRNS chunk length: 0 (expected 6) | +| length\_trns\_palette.png | Too many transparency palette entries (174 > 173) | +| length\_hist.png | Bad hIST chunk length: 28 (expected 30) | +| length\_sbit.png | Bad sBIT chunk length: 4 (expected 3) | +| length\_sbit\_2.png | Bad sBIT chunk length: 3 (expected 1) | +| length\_bkgd\_gray.png | Bad bKGD chunk length: 6 (expected 2) | +| length\_bkgd\_rgb.png | Bad bKGD chunk length: 2 (expected 6) | +| length\_bkgd\_palette.png | Bad bKGD chunk length: 6 (expected 1) | +| truncate\_zlib.png | Unexpected end of ZLIB input stream | +| truncate\_zlib\_2.png | Unexpected end of ZLIB input stream | +| truncate\_idat\_0.png | Unexpected end of image data | +| truncate\_idat\_1.png | Unexpected end of image data | +| unknown\_filter\_type.png | Unrecognized filter type 5 | +| text\_trailing\_null.png | Text value contains null | +| private\_compression\_method.png | Unrecognized compression method: 128 | +| private\_filter\_method.png | Unrecognized filter method: 128 | +| private\_interlace\_method.png | Unrecognized interlace method: 128 | +| private\_filter\_type.png | Unrecognized filter type 128 | \ No newline at end of file diff --git a/CVSROOT/checkoutlist b/CVSROOT/checkoutlist deleted file mode 100644 index b04b350..0000000 --- a/CVSROOT/checkoutlist +++ /dev/null @@ -1,13 +0,0 @@ -# The "checkoutlist" file is used to support additional version controlled -# administrative files in $CVSROOT/CVSROOT, such as template files. -# -# The first entry on a line is a filename which will be checked out from -# the corresponding RCS file in the $CVSROOT/CVSROOT directory. -# The remainder of the line is an error message to use if the file cannot -# be checked out. -# -# File format: -# -# [] -# -# comment lines begin with '#' diff --git a/CVSROOT/commitinfo b/CVSROOT/commitinfo deleted file mode 100644 index b19e7b7..0000000 --- a/CVSROOT/commitinfo +++ /dev/null @@ -1,15 +0,0 @@ -# The "commitinfo" file is used to control pre-commit checks. -# The filter on the right is invoked with the repository and a list -# of files to check. A non-zero exit of the filter program will -# cause the commit to be aborted. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being committed to, relative -# to the $CVSROOT. For the first match that is found, then the remainder -# of the line is the name of the filter to run. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/config b/CVSROOT/config deleted file mode 100644 index ff43ec0..0000000 --- a/CVSROOT/config +++ /dev/null @@ -1,14 +0,0 @@ -# Set this to "no" if pserver shouldn't check system users/passwords -#SystemAuth=no - -# Put CVS lock files in this directory rather than directly in the repository. -#LockDir=/var/lock/cvs - -# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top -# level of the new working directory when using the `cvs checkout' -# command. -#TopLevelAdmin=no - -# Set `LogHistory' to `all' or `TOFEWGCMAR' to log all transactions to the -# history file, or a subset as needed (ie `TMAR' logs all write operations) -#LogHistory=TOFEWGCMAR diff --git a/CVSROOT/cvswrappers b/CVSROOT/cvswrappers deleted file mode 100644 index 0accaf1..0000000 --- a/CVSROOT/cvswrappers +++ /dev/null @@ -1,23 +0,0 @@ -# This file affects handling of files based on their names. -# -# The -t/-f options allow one to treat directories of files -# as a single file, or to transform a file in other ways on -# its way in and out of CVS. -# -# The -m option specifies whether CVS attempts to merge files. -# -# The -k option specifies keyword expansion (e.g. -kb for binary). -# -# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) -# -# wildcard [option value][option value]... -# -# where option is one of -# -f from cvs filter value: path to filter -# -t to cvs filter value: path to filter -# -m update methodology value: MERGE or COPY -# -k expansion mode value: b, o, kkv, &c -# -# and value is a single-quote delimited value. -# For example: -#*.gif -k 'b' diff --git a/CVSROOT/editinfo b/CVSROOT/editinfo deleted file mode 100644 index d78886c..0000000 --- a/CVSROOT/editinfo +++ /dev/null @@ -1,21 +0,0 @@ -# The "editinfo" file is used to allow verification of logging -# information. It works best when a template (as specified in the -# rcsinfo file) is provided for the logging procedure. Given a -# template with locations for, a bug-id number, a list of people who -# reviewed the code before it can be checked in, and an external -# process to catalog the differences that were code reviewed, the -# following test can be applied to the code: -# -# Making sure that the entered bug-id number is correct. -# Validating that the code that was reviewed is indeed the code being -# checked in (using the bug-id number or a seperate review -# number to identify this particular code set.). -# -# If any of the above test failed, then the commit would be aborted. -# -# Actions such as mailing a copy of the report to each reviewer are -# better handled by an entry in the loginfo file. -# -# One thing that should be noted is the the ALL keyword is not -# supported. There can be only one entry that matches a given -# repository. diff --git a/CVSROOT/loginfo b/CVSROOT/loginfo deleted file mode 100644 index 4f70ee8..0000000 --- a/CVSROOT/loginfo +++ /dev/null @@ -1,29 +0,0 @@ -# The "loginfo" file controls where "cvs commit" log information -# is sent. The first entry on a line is a regular expression which must match -# the directory that the change is being made to, relative to the -# $CVSROOT. If a match is found, then the remainder of the line is a filter -# program that should expect log information on its standard input. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name ALL appears as a regular expression it is always used -# in addition to the first matching regex or DEFAULT. -# -# You may specify a format string as part of the -# filter. The string is composed of a `%' followed -# by a single format character, or followed by a set of format -# characters surrounded by `{' and `}' as separators. The format -# characters are: -# -# s = file name -# V = old version number (pre-checkin) -# v = new version number (post-checkin) -# -# For example: -#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog -# or -#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog - -CVSROOT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} herbyderby@users.sourceforge.net -DEFAULT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} javapng-cvs@lists.sourceforge.net diff --git a/CVSROOT/modules b/CVSROOT/modules deleted file mode 100644 index cb9e9ef..0000000 --- a/CVSROOT/modules +++ /dev/null @@ -1,26 +0,0 @@ -# Three different line formats are valid: -# key -a aliases... -# key [options] directory -# key [options] directory files... -# -# Where "options" are composed of: -# -i prog Run "prog" on "cvs commit" from top-level of module. -# -o prog Run "prog" on "cvs checkout" of module. -# -e prog Run "prog" on "cvs export" of module. -# -t prog Run "prog" on "cvs rtag" of module. -# -u prog Run "prog" on "cvs update" of module. -# -d dir Place module in directory "dir" instead of module name. -# -l Top-level directory only -- do not recurse. -# -# NOTE: If you change any of the "Run" options above, you'll have to -# release and re-checkout any working directories of these modules. -# -# And "directory" is a path to a directory relative to $CVSROOT. -# -# The "-a" option specifies an alias. An alias is interpreted as if -# everything on the right of the "-a" had been typed on the command line. -# -# You can encode a module within a module by using the special '&' -# character to interpose another module into the current module. This -# can be useful for creating a module that consists of many directories -# spread out over the entire source repository. diff --git a/CVSROOT/notify b/CVSROOT/notify deleted file mode 100644 index 34f0bc2..0000000 --- a/CVSROOT/notify +++ /dev/null @@ -1,12 +0,0 @@ -# The "notify" file controls where notifications from watches set by -# "cvs watch add" or "cvs edit" are sent. The first entry on a line is -# a regular expression which is tested against the directory that the -# change is being made to, relative to the $CVSROOT. If it matches, -# then the remainder of the line is a filter program that should contain -# one occurrence of %s for the user to notify, and information on its -# standard input. -# -# "ALL" or "DEFAULT" can be used in place of the regular expression. -# -# For example: -#ALL mail %s -s "CVS notification" diff --git a/CVSROOT/rcsinfo b/CVSROOT/rcsinfo deleted file mode 100644 index 49e59f4..0000000 --- a/CVSROOT/rcsinfo +++ /dev/null @@ -1,13 +0,0 @@ -# The "rcsinfo" file is used to control templates with which the editor -# is invoked on commit and import. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being made to, relative to the -# $CVSROOT. For the first match that is found, then the remainder of the -# line is the name of the file that contains the template. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/taginfo b/CVSROOT/taginfo deleted file mode 100644 index 274a46d..0000000 --- a/CVSROOT/taginfo +++ /dev/null @@ -1,20 +0,0 @@ -# The "taginfo" file is used to control pre-tag checks. -# The filter on the right is invoked with the following arguments: -# -# $1 -- tagname -# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d -# $3 -- repository -# $4-> file revision [file revision ...] -# -# A non-zero exit of the filter program will cause the tag to be aborted. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being committed to, relative -# to the $CVSROOT. For the first match that is found, then the remainder -# of the line is the name of the filter to run. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/verifymsg b/CVSROOT/verifymsg deleted file mode 100644 index 86f747c..0000000 --- a/CVSROOT/verifymsg +++ /dev/null @@ -1,21 +0,0 @@ -# The "verifymsg" file is used to allow verification of logging -# information. It works best when a template (as specified in the -# rcsinfo file) is provided for the logging procedure. Given a -# template with locations for, a bug-id number, a list of people who -# reviewed the code before it can be checked in, and an external -# process to catalog the differences that were code reviewed, the -# following test can be applied to the code: -# -# Making sure that the entered bug-id number is correct. -# Validating that the code that was reviewed is indeed the code being -# checked in (using the bug-id number or a seperate review -# number to identify this particular code set.). -# -# If any of the above test failed, then the commit would be aborted. -# -# Actions such as mailing a copy of the report to each reviewer are -# better handled by an entry in the loginfo file. -# -# One thing that should be noted is the the ALL keyword is not -# supported. There can be only one entry that matches a given -# repository. diff --git a/ChangeLog.md b/ChangeLog.md new file mode 100644 index 0000000..0ac08ec --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1,69 @@ +## Changes from v2.0-rc8 → v2.0 (2008-05-26) ## + + * Remove undocumented low-pass filter code + * Add missing `PngConfig` documentation + * Remove use of `ProGuard` + +## Changes from v2.0-rc6 → v2.0-rc8 (2008-04-10) ## + + * Fix bug skipping over extra IDAT data + * Fix bug with tRNS chunk in paletted images + * Fix CRC calculation bug + * Allow multiple private chunks + * Some low-level changes needed by APNG code + +(skipped rc7) + +## Changes from v2.0-rc5 → v2.0-rc6 (2006-12-01) ## + + * Fix bugs found by `FindBugs` + * Change chunk read method to use `DataInput` instead of `PngInputStream` + * Fix stereo chunk parsing + * Fix compressed `iTXt` parsing + * Remove `PngChunk`, fold constants into `PngConstants` + * Add suite of broken images, for test coverage + +## Changes from v2.0-rc4 → v2.0-rc5 (2006-06-12) ## + + * Added `PngConfig.READ_EXCEPT_METADATA` + * Better progressive performance + * Support image source region + * Reduced number of classes to make jar smaller + * Use `ProGuard` to make jar smaller + * Eliminate all use of reflection + * Combine ext package into main package + * Support new `sTER` registered chunk + * Performance improvements + * Removed `get/setUserExponent` from configuration + * Removed support for limiting pass decoding + * Use Builder pattern for `PngConfig` to make configuration immutable + +## Changes from v2.0-rc3 → v2.0-rc4 (2006-04-05) ## + + * Java IIO-compatible plugin (thanks to Dimitri Koussa) + * Change `sBIT` to use `byte[]` instead of int[.md](.md) + * Support decimation subsampling + * Support limiting decoding of passes to a particular range + +## Changes from v2.0-rc2 → v2.0-rc3 (2005-10-07) ## + + * Fix decoding when there is leftover `IDAT` data + * Move some methods from `PngConfig` to `PngImage` + * Add `handleProgress` methods to `PngImage` + * Support abort from `handleFrame`, `handleProgress` + +## Changes from v2.0-rc1 → v2.0-rc2 (2005-09-14) ## + + * Fixed a buffering bug in `PngInputStream` + * Made `PngImage` implement `java.awt.Transparency` + +## Changes from v1.3.0 → v2.0-rc1 (2005-08-05) ## + + * Complete rewrite, now requires Java 1.2 or higher + * Uses the modern `BufferedImage`-based Java APIs + * Decoded images use less memory + * Smaller jar file (under 35K) + * Access to raw image data + * 16-bit images do not have to be reduced to 8-bit + * Faster decoding + * License changed from LGPL to GPL-with-library-exception (the same as the GNU Classpath project) \ No newline at end of file diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 0000000..aed24d9 --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1,3 @@ +Supports all valid bit depths (grayscale/color), interlacing, paletted images, alpha channel/transparency, gamma correction, access to most standard chunks, private chunk handling, and progressive display. + +**Note:** The latest version (2.x) requires JDK 1.2 or higher. The last JDK 1.1-compatible version is 1.3.0, [available here](http://javapng.googlecode.com/files/javapng-1.3.0-src.jar). \ No newline at end of file diff --git a/javapng/LICENSE.txt b/javapng/LICENSE.txt deleted file mode 100644 index a6d5a41..0000000 --- a/javapng/LICENSE.txt +++ /dev/null @@ -1,17 +0,0 @@ -com.sixlegs.image.png - Java package to read and display PNG images -Copyright (C) 1998-2004 Chris Nokleberg - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the -Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. diff --git a/javapng/README.txt b/javapng/README.txt deleted file mode 100644 index 716c471..0000000 --- a/javapng/README.txt +++ /dev/null @@ -1,217 +0,0 @@ -Copyright (C) 1998-2004 Chris Nokleberg -All rights reserved. - -README - com.sixlegs.image.png v1.3.0 - -Features - - Supports all valid bit depths (grayscale/color), interlacing, paletted - images, alpha channel/transparency, gamma correction, access to most - standard chunks, private chunk handling, and progressive display. - -Revision History - - Changes from v1.3.0 -> v1.3.1 (?) - - * Fix bug reading text values with a trailing carriage return. - [Michael Powers] - - Changes from v1.2.3 -> v1.3.0 (2004-5-26): - - * Add new constructor that allows you to disable the automatic - closing of the InputStream, useful for when a stream contains - multiple images. [David Steigleite] - * Bug fix: throws EOFException if InputStream is empty (instead of - NullPointerException). - * Remove SINGLEFRAMEDONE calls for compatibility with JDK. [Eugen Dueck] - * Add setBuffer(int[]) method to set internal pixel buffer. [Eugen Dueck] - * Add getEverything(boolean) to allow fatal exceptions to be thrown. - * First release via SourceForge: http://sourceforge.net/projects/javapng - - Changes from v1.2.2 -> v1.2.3 (2002-5-14): - - * Bug fix: make read() methods obey InputStream contract. [Joseph Bowbeer] - - Changes from v1.2.0 -> v1.2.2 (2001-9-14): - - * Bug fix: wide images with alpha channels triggered - ArrayIndexOutOfBoundsException. [Thomas Krammer] - - Changes from v1.1 -> v1.2.0 (2001-9-4): - - * Bug fix: now supports smooth scaling via AreaAveragingScaleFilter - class or Image.getScaledInstance method. [Eugen Dueck] - * Bug fix: NullPointerException, interlaced images, Win32 JRE 1.3.1. - [Ahmed Lacevic] - * Bug fix: isGrayscale() method was backwards. - * Changed default progressive display option to false. - * Optimized loading of non-interlaced images. - * Fatal errors are now always available via getErrors(). - * Added isIndexedColor() method. - * Added TextChunk.getChunkType() method. - * Added hasChunk(String) method. - * Added "background low bytes" property. - * Added "background index" property. - * Added "transparency" property. - * Added "transparency low bytes" property. - * Added "transparency size" property. - * Added alpha array to "palette" property when transparency info is present. - - Changes from v1.0a -> v1.1 (2001-7-7): - - * Support for gIFg and gIFx chunks. - * gAMA chunks with a value of zero are ignored. [Michael Toennies] - * Multiple productions of image data are now supported again (undid - some of the changes from v0.8 -> v0.9). [Klaus Goessl] - * File handles are now properly closed after the images are read. - [Steve Thorne] - * Added "setFlushAfterNextProduction" method. [Klaus Goessl] - - Changes from v0.9 -> v1.0a (1999-4-1): - - * Released as open-source under LGPL. - * Workaround for IE4.0, should work fine now. - - Changes from v0.8 -> v0.9 (1999-1-12): - - * Changes to significantly reduce memory usage (up to 40%): - + "setViewingGammaLocal", "setDisplayGammaLocal" methods removed. - + Multiple productions of image data no longer supported. - + Call "getEverything" only when you do not need image data. - * Support for proposed iTXt chunk (TextChunk class). - * "getTextChunk" now returns a TextChunk instead of String. - * "getTextKeys" changed to "getTextChunks". - * CR, LF, and CR-LF combinations in text chunks are transformed - to local newline conventions. - * Standard text chunks keywords are now case-sensitive. - * Character codes 0-8,11,12,14-31,127-159 in text chunks are - displayed using octal "\nnn" notation. - - Changes from v0.7 -> v0.8 (1998-10-13): - - * Support for oFFs, pCAL, sBIT, sCAL, and sPLT chunks. - * ChunkHandlers can now override standard ancillary chunks. - * Added documentation on reducing distribution size (see below). - * Fixed bug with getProperty("background"). - * Fixed bug with getProperty("time"). - * Modest performance improvements. - * Changed some property names and constants for consistency. - * Added source files for each example class. - - Changes from v0.6 -> v0.7 (1998-7-28): - - * Added getProperty method for easy access to chunk data. - * Added ChunkHandler interface for private chunk handling. - * Support for sRGB and iCCP chunks. - * Removed PngHeader class. Equivalent methods are now in PngImage. - * Improved text chunk handling. - * Changed "setViewingGamma" and "setDisplayGamma" to - "setViewingExponent" and "setDisplayExponent" to reflect proposed - changes to the PNG specification. - * Added GrayscaleFilter class (getGrayscaleFilter method removed). - * Example code documentation. - - Changes from v0.5 -> v0.6 (1998-3-11): - - * Progressive display of interlaced images. - * Grayscale filtering. - * "setViewingGammaLocal" and "setDisplayGammaLocal" allow you to - override the default gamma settings for an image. - * Added a RemoveAlphaFilter example class for better display - of transparent images. - * Fixed a bug with 16-bit grayscale images with bKGD chunks. - * Fixed a bug with very small interlaced images. - * Fixed a possible bug with interlaced images in which the first - scanline of each pass did not use the Sub or None filter. - * Package has changed from com.sixlegs.PNG to com.sixlegs.image.png; - this is the final package name. - * More documentation. - -Requirements - - This package uses the java.util.zip package for ZLIB decompression, - and so requires Java 1.1 or higher. This means that it will not work - in older browsers, such as Netscape 3.x. Let me know if you encounter - problems on platforms that supposedly support Java 1.1. - -Getting Started - - The entire com.sixlegs.PNG package has been archived in the png.jar - file. The easiest way to start using the package is to simply include - the path to the jar file in your CLASSPATH environment variable. - - Alternatively, you can extract the class files by running the command - - jar xvf png.jar - - You would still probably want to add the location of the extracted - files to your CLASSPATH. - -Using the Package - - Usually you will 'import com.sixlegs.image.png.*;' at the beginning - of your code. The PngImage class is an ImageProducer, so getting an - Image object from a local PNG file is easy: - - PngImage png = new PngImage("test.png"); - Image img = Toolkit.getDefaultToolkit().createImage(png); - - The PngImage object also has constructors to read from a URL or an - InputStream. In addition, you can set variables, such as gamma - parameters, that will affect the resulting image. See the - documentation located in the 'javadoc' directory for more details. - - Example code is located in the 'examples' directory. - -Reducing distribution size - - Not all of the class files in the library are critical. By removing - unnecessary classes you can reduce the total size of the jar file - by about half. - - Each chunk type has its own class. The only five that must be - included are IHDR, IDAT, IEND, PLTE, and tRNS. All others may be - safely removed. - - Be aware that the removal of certain chunks classes, such as gAMA, - sRGB, and bKGD, may affect the displayed image. - - Furthermore, there is a separate "BitMover" class for each image - color format. You may safely remove the formats that you *know* you - do not need to support. Here is a key to the BitMover classes: - - BitMover1G - 1 bit grayscale - BitMover1P - 1 bit paletted - BitMover2G - 2 bit grayscale - BitMover2P - 2 bit paletted - BitMover4G - 4 bit grayscale - BitMover4P - 4 bit paletted - BitMover8G - 8 bit grayscale - BitMover8GA - 8 bit grayscale + 8 bit alpha - BitMover8P - 8 bit paletted - BitMover8RGB - 24 bit truecolor - BitMover8RGBA - 24 bit truecolor + 8 bit alpha - BitMover16G - 16 bit grayscale - BitMover16GA - 16 bit grayscale + 16 bit alpha - BitMover16RGB - 48 bit truecolor - BitMover16RGBA - 48 bit truecolor + 16 bit alpha - - Miscellaneous: - - * Remove KeyValueChunk only if you remove AbstractTextChunk and iCCP. - * Remove AbstractTextChunk only if you remove tEXt, zTXt, and iTXt. - * Remove VcHRM only if you remove sRGB and cHRM. - * If you do not need private chunk handling you may remove - UserChunk and ChunkHandler. - * Remove GifExtension only if you remove gIFx and gIFg. - -Contact Information - - The latest version of this package is available from: - http://www.sixlegs.com/ - - Please let me know about any problems you encounter, or features - that you would find valuable. - - Chris Nokleberg - diff --git a/javapng/build.xml b/javapng/build.xml deleted file mode 100644 index 1d76418..0000000 --- a/javapng/build.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/javapng/lgpl.txt b/javapng/lgpl.txt deleted file mode 100644 index 22f601e..0000000 --- a/javapng/lgpl.txt +++ /dev/null @@ -1,439 +0,0 @@ -GNU LIBRARY GENERAL PUBLIC LICENSE - -Version 2, June 1991 - -Copyright (C) 1991 Free Software Foundation, Inc. -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is - numbered 2 because it goes with version 2 of the ordinary GPL.] - -Preamble - -The licenses for most software are designed to take away your freedom -to share and change it. By contrast, the GNU General Public Licenses -are intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. - -This license, the Library General Public License, applies to some -specially designated Free Software Foundation software, and to any -other libraries whose authors decide to use it. You can use it for -your libraries, too. - -When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library, or if you modify it. - -For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link a program with the library, you must provide -complete object files to the recipients so that they can relink them -with the library, after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - -Our method of protecting your rights has two steps: (1) copyright the -library, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the library. - -Also, for each distributor's protection, we want to make certain that -everyone understands that there is no warranty for this free -library. If the library is modified by someone else and passed on, we -want its recipients to know that what they have is not the original -version, so that any problems introduced by others will not reflect on -the original authors' reputations. - -Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that companies distributing free -software will individually obtain patent licenses, thus in effect -transforming the program into proprietary software. To prevent this, -we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. - -Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License, which was designed for utility -programs. This license, the GNU Library General Public License, -applies to certain designated libraries. This license is quite -different from the ordinary one; be sure to read it in full, and don't -assume that anything in it is the same as in the ordinary license. - -The reason we have a separate public license for some libraries is -that they blur the distinction we usually make between modifying or -adding to a program and simply using it. Linking a program with a -library, without changing the library, is in some sense simply using -the library, and is analogous to running a utility program or -application program. However, in a textual and legal sense, the linked -executable is a combined work, a derivative of the original library, -and the ordinary General Public License treats it as such. - -Because of this blurred distinction, using the ordinary General Public -License for libraries did not effectively promote software sharing, -because most developers did not use the libraries. We concluded that -weaker conditions might promote sharing better. - -However, unrestricted linking of non-free programs would deprive the -users of those programs of all benefit from the free status of the -libraries themselves. This Library General Public License is intended -to permit developers of non-free programs to use free libraries, while -preserving your freedom as a user of such programs to change the free -libraries that are incorporated in them. (We have not seen how to -achieve this as regards changes in header files, but we have achieved -it as regards changes in the actual functions of the Library.) The -hope is that this will lead to faster development of free libraries. - -The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, while the latter only -works together with the library. - -Note that it is possible for a library to be covered by the ordinary -General Public License rather than by this special one. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION -AND MODIFICATION - -0. This License Agreement applies to any software library which -contains a notice placed by the copyright holder or other authorized -party saying it may be distributed under the terms of this Library -General Public License (also called "this License"). Each licensee is -addressed as "you". - -A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does and -what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a -fee. - -2. You may modify your copy or copies of the Library or any portion of -it, thus forming a work based on the Library, and copy and distribute -such modifications or work under the terms of Section 1 above, -provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or - a table of data to be supplied by an application program that - uses the facility, other than as an argument passed when the - facility is invoked, then you must make a good faith effort to - ensure that, in the event an application does not supply such - function or table, the facility still operates, and performs - whatever part of its purpose remains meaningful. (For example, a - function in a library to compute square roots has a purpose that - is entirely well-defined independent of the application. - Therefore, Subsection 2d requires that any application-supplied - function or table used by this function must be optional: if the - application does not supply it, the square root function must - still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - -Once this change is made in a given copy, it is irreversible for that -copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the -Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative -of it, under Section 2) in object code or executable form under the -terms of Sections 1 and 2 above provided that you accompany it with -the complete corresponding machine-readable source code, which must be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange. - -If distribution of object code is made by offering access to copy from -a designated place, then offering equivalent access to copy the source -code from the same place satisfies the requirement to distribute the -source code, even though third parties are not compelled to copy the -source along with the object code. - -5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a work, -in isolation, is not a derivative work of the Library, and therefore -falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. Section -6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is -not. Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data structure -layouts and accessors, and small macros and small inline functions -(ten lines or less in length), then the use of the object file is -unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section -6. Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also compile or link -a "work that uses the Library" with the Library to produce a work -containing portions of the Library, and distribute that work under -terms of your choice, provided that the terms permit modification of -the work for the customer's own use and reverse engineering for -debugging such modifications. - -You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable - linked with the Library, with the complete machine-readable - "work that uses the Library", as object code and/or source code, - so that the user can modify the Library and then relink to - produce a modified executable containing the modified - Library. (It is understood that the user who changes the - contents of definitions files in the Library will not - necessarily be able to recompile the application to use the - modified definitions.) - - b) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - - c) If distribution of the work is made by offering access to - copy from a designated place, offer equivalent access to copy - the above specified materials from the same place. - - d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the source code distributed need not include anything that is normally -distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - -It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - -7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the -Library except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense, link with, or distribute the -Library is void, and will automatically terminate your rights under -this License. However, parties who have received copies, or rights, -from you under this License will not have their licenses terminated so -long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted -herein. You are not responsible for enforcing compliance by third -parties to this License. - -11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new -versions of the Library General Public License from time to time. Such -new versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE -LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS -AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF -ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - -END OF TERMS AND CONDITIONS diff --git a/javapng/lib/keep.txt b/javapng/lib/keep.txt deleted file mode 100644 index e69de29..0000000 diff --git a/javapng/src/examples/com/sixlegs/examples/ChunkHandlerExample.java b/javapng/src/examples/com/sixlegs/examples/ChunkHandlerExample.java deleted file mode 100644 index 3fd6435..0000000 --- a/javapng/src/examples/com/sixlegs/examples/ChunkHandlerExample.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.sixlegs.examples; - -import com.sixlegs.image.png.PngImage; -import com.sixlegs.image.png.ChunkHandler; -import java.io.IOException; - -public class ChunkHandlerExample -implements ChunkHandler -{ - - public static void main(String[] args) - throws IOException - { - // Register instance of this class as "heLo" handler - PngImage.registerChunk(new ChunkHandlerExample(), "heLo"); - - // Read PNG image from file - PngImage png = new PngImage(args[0]); - - // Ensures that entire PNG image has been read, - // triggering handleChunk when a "heLo" chunk is found - png.getEverything(); - } - - public void handleChunk(String type, byte[] data) - { - if (type.equals("heLo")) { - System.err.println("Found heLo chunk, " + data.length + " bytes."); - } - } -} diff --git a/javapng/src/examples/com/sixlegs/examples/ErrorExample.java b/javapng/src/examples/com/sixlegs/examples/ErrorExample.java deleted file mode 100644 index 1096e72..0000000 --- a/javapng/src/examples/com/sixlegs/examples/ErrorExample.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.sixlegs.examples; - -import com.sixlegs.image.png.PngImage; -import java.util.Enumeration; -import java.io.IOException; - -public class ErrorExample -{ - public static void main(String[] args) - { - try { - // Makes errors in ancillary chunks fatal - PngImage.setAllErrorsFatal(true); - - // Read PNG image from file - PngImage png = new PngImage(args[0]); - - // Read entire PNG image (doesn't throw exceptions) - png.getEverything(); - - // Print all errors - if (png.hasErrors()) { - System.err.println("Errors in PNG processing:"); - for (Enumeration e = png.getErrors(); e.hasMoreElements();) { - // Objects returned by getErrors derive from IOException, - // but you usually only want to print them - System.err.println(" " + e.nextElement()); - } - } - } catch (IOException e) { } - } -} diff --git a/javapng/src/examples/com/sixlegs/examples/GrayscaleApplet.java b/javapng/src/examples/com/sixlegs/examples/GrayscaleApplet.java deleted file mode 100644 index 6273cf6..0000000 --- a/javapng/src/examples/com/sixlegs/examples/GrayscaleApplet.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.sixlegs.examples; - -import com.sixlegs.image.png.PngImage; -import java.awt.image.FilteredImageSource; -import java.awt.image.ImageFilter; -import java.awt.image.ImageProducer; -import java.io.IOException; - -public class GrayscaleApplet -extends PngApplet -{ - public GrayscaleApplet() - { - } - - protected ImageProducer filter(PngImage png, ImageProducer in) - throws IOException - { - // Get chromaticity property if available - double[][] chrom = (double[][])png.getProperty("chromaticity xyz"); - - // Use luminance info from chromaticity array, or default - ImageFilter gray = (chrom == null ? - new GrayscaleFilter() : - new GrayscaleFilter(chrom[1][1], - chrom[2][1], - chrom[3][1])); - - // Chain PngImage to be filtered through GrayscaleFilter - return new FilteredImageSource(super.filter(png, in), gray); - } -} diff --git a/javapng/src/examples/com/sixlegs/examples/GrayscaleFilter.java b/javapng/src/examples/com/sixlegs/examples/GrayscaleFilter.java deleted file mode 100644 index c3f603b..0000000 --- a/javapng/src/examples/com/sixlegs/examples/GrayscaleFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.sixlegs.examples; - -import java.awt.image.RGBImageFilter; - -final class GrayscaleFilter -extends RGBImageFilter -{ - private double Yr, Yg, Yb; - - public GrayscaleFilter() - { - this(0.2126d, 0.7152d, 0.0722d); - } - - public GrayscaleFilter(double Yr, double Yg, double Yb) - { - this.Yr = Yr; - this.Yg = Yg; - this.Yb = Yb; - canFilterIndexColorModel = true; - } - - public int filterRGB(int x, int y, int rgb) - { - int a = (rgb & 0xFF000000); - int r = (rgb & 0x00FF0000) >>> 16; - int g = (rgb & 0x0000FF00) >>> 8; - int b = (rgb & 0x000000FF); - int Y = (int)(Yr * r + Yg * g + Yb * b); - if (Y > 255) Y = 255; - return a | (Y << 16) | (Y << 8) | Y; - } -} diff --git a/javapng/src/examples/com/sixlegs/examples/ObserverExample.java b/javapng/src/examples/com/sixlegs/examples/ObserverExample.java deleted file mode 100644 index de59f66..0000000 --- a/javapng/src/examples/com/sixlegs/examples/ObserverExample.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.sixlegs.examples; - -import com.sixlegs.image.png.PngImage; -import java.io.IOException; -import java.awt.Toolkit; -import java.awt.Image; -import java.awt.image.ImageObserver; - -public class ObserverExample -implements ImageObserver -{ - private static int counter = 0; - - public static void main(String[] args) - throws IOException - { - // Update ImageObservers after each interlace pass - PngImage.setProgressiveDisplay(true); - - // Read PNG image from file - PngImage png = new PngImage(args[0]); - Toolkit tk = Toolkit.getDefaultToolkit(); - Image img = tk.createImage(png); - int w = png.getWidth(); - int h = png.getHeight(); - - // Call prepareImage using an instance of this class - // as the ImageObserver; triggers imageUpdate (below) - tk.prepareImage(img, w, h, new ObserverExample()); - } - - public boolean imageUpdate(Image img, int infoflags, - int x, int y, int w, int h) - { - if ((infoflags & ALLBITS) != 0 || - (infoflags & FRAMEBITS) != 0) { - // We have a frame, do something with image here - System.out.println("Received frame " + ++counter); - } - return true; - } -} diff --git a/javapng/src/examples/com/sixlegs/examples/PixelGrabberExample.java b/javapng/src/examples/com/sixlegs/examples/PixelGrabberExample.java deleted file mode 100644 index b4dd969..0000000 --- a/javapng/src/examples/com/sixlegs/examples/PixelGrabberExample.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.sixlegs.examples; - -import com.sixlegs.image.png.PngImage; -import java.awt.Image; -import java.awt.Toolkit; -import java.awt.image.PixelGrabber; -import java.io.IOException; - -public class PixelGrabberExample -{ - static public void main(String[] args) - throws IOException - { - PngImage png = new PngImage(args[0]); - - int x = Integer.parseInt(args[1]); - int y = Integer.parseInt(args[2]); - int w = png.getWidth(); - - int[] pixels = new int[1]; - PixelGrabber pg = - new PixelGrabber(png, x, y, 1, 1, pixels, 0, w); - try { - pg.grabPixels(); - } catch (InterruptedException e) { } - - int a = 0xff & (pixels[0] >> 24); - int r = 0xff & (pixels[0] >> 16); - int g = 0xff & (pixels[0] >> 8); - int b = 0xff & (pixels[0] >> 0); - - System.out.println("pixel: 0x" + Integer.toHexString(pixels[0]) + - " a: " + a + " r: " + r + " g: " + g + " b: " + b); - } -} diff --git a/javapng/src/examples/com/sixlegs/examples/PngApplet.java b/javapng/src/examples/com/sixlegs/examples/PngApplet.java deleted file mode 100644 index f6bbe88..0000000 --- a/javapng/src/examples/com/sixlegs/examples/PngApplet.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.sixlegs.examples; - -import com.sixlegs.image.png.PngImage; -import java.applet.Applet; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.awt.image.ImageProducer; -import java.awt.image.FilteredImageSource; -import java.io.IOException; -import java.net.URL; - -public class PngApplet -extends Applet -{ - private Color imgbg; - private Image img; - private PngImage png; - - public PngApplet() - { - } - - public void init() - { - String loc = getParameter("URL"); - try { - if (loc != null) { - URL url = new URL(getCodeBase(), loc); - png = new PngImage(url); - String bgparam = getParameter("bgcolor"); - if (bgparam != null) - imgbg = new Color(Integer.valueOf(bgparam, 16).intValue()); - if (imgbg == null) - imgbg = png.getBackgroundColor(); - if (imgbg == null) - imgbg = Color.white; - img = Toolkit.getDefaultToolkit().createImage(filter(png, png)); - } - } catch (IOException e) { - System.err.println("error reading " + loc + ": " + e); - } - } - - protected ImageProducer filter(PngImage png, ImageProducer in) - throws IOException - { - return new FilteredImageSource(in, new RemoveAlphaFilter(imgbg)); - } - - public void update(Graphics g) - { - paint(g); - } - - public void paint(Graphics g) - { - try { - if (img != null) - g.drawImage(img, 0, 0, png.getWidth(), png.getHeight(), imgbg, null); - } catch (Exception e) { } - } -} diff --git a/javapng/src/examples/com/sixlegs/examples/PropertiesExample.java b/javapng/src/examples/com/sixlegs/examples/PropertiesExample.java deleted file mode 100644 index 7baf207..0000000 --- a/javapng/src/examples/com/sixlegs/examples/PropertiesExample.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.sixlegs.examples; - -import com.sixlegs.image.png.PngImage; -import java.util.Enumeration; -import java.io.IOException; - -public class PropertiesExample -{ - public static void main(String[] args) - throws IOException - { - // Read PNG image from file - PngImage png = new PngImage(args[0]); - - // Ensures that entire PNG image has been read - png.getEverything(); - - // Print all available properties - for (Enumeration e = png.getProperties(); e.hasMoreElements();) { - String key = (String)e.nextElement(); - System.out.println(key); - System.out.println("\t" + png.getProperty(key)); - } - } -} - diff --git a/javapng/src/examples/com/sixlegs/examples/RemoveAlphaFilter.java b/javapng/src/examples/com/sixlegs/examples/RemoveAlphaFilter.java deleted file mode 100644 index cd812c4..0000000 --- a/javapng/src/examples/com/sixlegs/examples/RemoveAlphaFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.sixlegs.examples; - -import java.awt.Color; -import java.awt.image.ColorModel; -import java.awt.image.ImageFilter; - -// This class composites an image with an alpha channel -// onto a background color. - -final class RemoveAlphaFilter -extends ImageFilter -{ - private final int r_bg; - private final int g_bg; - private final int b_bg; - private final int pixel_bg; - private final static ColorModel directcm = ColorModel.getRGBdefault(); - - public RemoveAlphaFilter(Color c) - { - // this(c.getRed(), c.getGreen(), c.getBlue()); // some compiler problem - r_bg = c.getRed(); - g_bg = c.getGreen(); - b_bg = c.getBlue(); - pixel_bg = 0xFF000000 | (r_bg << 16) | (g_bg << 8) | b_bg; - } - - public RemoveAlphaFilter(int r, int g, int b) - { - r_bg = r; - g_bg = g; - b_bg = b; - pixel_bg = 0xFF000000 | (r_bg << 16) | (g_bg << 8) | b_bg; - } - - public void setPixels(int x, int y, int w, int h, - ColorModel model, - int[] pixels, - int off, - int scansize) - { - int[] buf = new int[w * h]; - for (int yc = 0, i = off, bp = 0; yc < h; yc++) { - for (int xc = 0; xc < w; xc++) { - int pixel = pixels[i++]; - int alpha = model.getAlpha(pixel); - int red = model.getRed(pixel); - int green = model.getGreen(pixel); - int blue = model.getBlue(pixel); - switch (alpha) { - case 0: - buf[bp++] = pixel_bg; - break; - case 255: - buf[bp++] = 0xFF000000 | (red << 16) | (green << 8) | blue; - break; - default: - red = (alpha * red + (255 - alpha) * r_bg) / 255; - green = (alpha * green + (255 - alpha) * g_bg) / 255; - blue = (alpha * blue + (255 - alpha) * b_bg) / 255; - buf[bp++] = 0xFF000000 | (red << 16) | (green << 8) | blue; - } - } - i += (scansize - w); - } - super.setPixels(x, y, w, h, directcm, buf, 0, w); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/AbstractTextChunk.java b/javapng/src/main/com/sixlegs/image/png/AbstractTextChunk.java deleted file mode 100644 index 6c81b4c..0000000 --- a/javapng/src/main/com/sixlegs/image/png/AbstractTextChunk.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.CharArrayWriter; -import java.io.IOException; -import java.util.Hashtable; - -abstract class AbstractTextChunk -extends KeyValueChunk -implements TextChunk -{ - static private Hashtable special_keys = new Hashtable(); - static { - special_keys.put("Title", Boolean.TRUE); - special_keys.put("Author", Boolean.TRUE); - special_keys.put("Description", Boolean.TRUE); - special_keys.put("Copyright", Boolean.TRUE); - special_keys.put("Creation Time", Boolean.TRUE); - special_keys.put("Software", Boolean.TRUE); - special_keys.put("Disclaimer", Boolean.TRUE); - special_keys.put("Warning", Boolean.TRUE); - special_keys.put("Source", Boolean.TRUE); - special_keys.put("Comment", Boolean.TRUE); - } - - public String toString() { return getText(); } - - public String getKeyword() { return key; } - public String getText() { return value; } - abstract public String getTranslatedKeyword(); - abstract public String getLanguage(); - - AbstractTextChunk(int type) { super(type); } - - protected String readKey() - throws IOException - { - String key = super.readKey(); - if (special_keys.containsKey(key)) { - String lowerkey = key.toLowerCase(); - Object replace = img.data.properties.get(lowerkey); - if (replace == null || ((Chunk)replace).type != iTXt) - img.data.properties.put(lowerkey, this); - } - img.data.textChunks.put(key, this); - return key; - } - - protected String readValue() - throws IOException - { - return repairValue(super.readValue()); - } - - private static String repairValue(String val) - { - CharArrayWriter out_chars = new CharArrayWriter(val.length()); - try { - char[] chs = val.toCharArray(); - int p = 0; - int L = chs.length; - String endl = System.getProperty("line.separator"); - while (p < L) { - char ch = chs[p++]; - switch (ch) { - case '\r': - if (p + 1 < L && chs[p + 1] == '\n') break; - case '\n': - out_chars.write(endl); - break; - case '\t': - out_chars.write('\t'); - break; - default: - if (ch <= 31 || (ch >= 127 && ch <= 159)) { - out_chars.write('\\'); - out_chars.write(Integer.toOctalString(ch)); - } else { - out_chars.write(ch); - } - } - } - } catch (IOException e) { } - return out_chars.toString(); - } - - public String getChunkType() - { - return typeToString(type); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Adam7Interlacer.java b/javapng/src/main/com/sixlegs/image/png/Adam7Interlacer.java deleted file mode 100644 index cda8f64..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Adam7Interlacer.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -final class Adam7Interlacer -extends Interlacer -{ - static final int[] init = { 0, 0, 4, 0, 2, 0, 1, 0 }; - static final int[] sp = { 8, 8, 8, 4, 4, 2, 2, 1 }; - - Adam7Interlacer(int w, int h) - { - super(w, h); - } - - final int numPasses () - { - return 7; - } - - final int getSpacingX(int pass) - { - return sp[pass+1]; - } - - final int getSpacingY(int pass) - { - return sp[pass]; - } - - final int getOffsetX(int pass) - { - return init[pass+1]; - } - - final int getOffsetY(int pass) - { - return init[pass]; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover.java b/javapng/src/main/com/sixlegs/image/png/BitMover.java deleted file mode 100644 index a199f16..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -abstract class BitMover -{ - int trans = -1; - int transgray = -1; - int translow = -1; - int[] gammaTable; - - abstract int fill(int[] pixels, InputStream str, int off, int len) - throws IOException; - - static BitMover getBitMover(PngImage img) - throws PngException - { - StringBuffer clsname = new StringBuffer("com.sixlegs.image.png.BitMover"); - clsname.append(img.data.header.depth); - if (img.data.header.paletteUsed) { - clsname.append('P'); - } else { - clsname.append(img.data.header.colorUsed ? "RGB" : "G"); - } - if (img.data.header.alphaUsed) clsname.append('A'); - try { - BitMover b = (BitMover)Class.forName(clsname.toString()).newInstance(); - b.gammaTable = img.data.gammaTable; - if (img.data.header.colorType == PngImage.COLOR_TYPE_GRAY || - img.data.header.colorType == PngImage.COLOR_TYPE_RGB) { - Chunk_tRNS trans = (Chunk_tRNS)img.getChunk(Chunk.tRNS); - if (trans != null) { - b.trans = trans.rgb; - b.translow = trans.rgb_low; - b.transgray = trans.r; - } - } - return b; - } catch (Exception e) { - throw new PngException("Error loading " + clsname); - } - } -} - diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover16G.java b/javapng/src/main/com/sixlegs/image/png/BitMover16G.java deleted file mode 100644 index dde198a..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover16G.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover16G -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int hi = str.read(); - int lo = str.read(); - pixels[off++] = ((hi << 8 | lo) == transgray ? 0 : 0xFF000000) | gammaTable[hi]; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover16GA.java b/javapng/src/main/com/sixlegs/image/png/BitMover16GA.java deleted file mode 100644 index b10fa42..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover16GA.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover16GA -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int hi = str.read(); - str.read(); - pixels[off++] = gammaTable[hi] | (str.read() << 24); - str.read(); - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover16RGB.java b/javapng/src/main/com/sixlegs/image/png/BitMover16RGB.java deleted file mode 100644 index 012aa92..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover16RGB.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover16RGB -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int rhi = str.read(); - int rlo = str.read(); - int ghi = str.read(); - int glo = str.read(); - int bhi = str.read(); - int blo = str.read(); - int chkhi = rhi << 16 | ghi << 8 | bhi; - int chklo = rlo << 16 | glo << 8 | blo; - int val = gammaTable[rhi] << 16 | gammaTable[ghi] << 8 | gammaTable[bhi]; - pixels[off++] = (trans == chkhi && translow == chklo ? 0 : 0xFF000000) | val; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover16RGBA.java b/javapng/src/main/com/sixlegs/image/png/BitMover16RGBA.java deleted file mode 100644 index 2e66394..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover16RGBA.java +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover16RGBA -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int r = gammaTable[str.read()]; - str.read(); - int g = gammaTable[str.read()]; - str.read(); - int b = gammaTable[str.read()]; - str.read(); - pixels[off++] = r << 16 | g << 8 | b | str.read() << 24; - str.read(); - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover1G.java b/javapng/src/main/com/sixlegs/image/png/BitMover1G.java deleted file mode 100644 index 1f730c6..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover1G.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover1G -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int x = str.read(); - for (int i = 7; i >= 0; i--) { - int p1 = (x >>> i & 1); - pixels[off++] = (p1 == transgray ? 0 : 0xFF000000) | gammaTable[p1]; - } - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover1P.java b/javapng/src/main/com/sixlegs/image/png/BitMover1P.java deleted file mode 100644 index a54046a..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover1P.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover1P -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int x = str.read(); - for (int i = 7; i >= 0; i--) { - pixels[off++] = x >>> i & 1; - } - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover2G.java b/javapng/src/main/com/sixlegs/image/png/BitMover2G.java deleted file mode 100644 index 5b87739..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover2G.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover2G -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int x = str.read(); - int p1 = x >>> 6 & 0x03, p2 = x >>> 4 & 0x03, p3 = x >>> 2 & 0x03, p4 = x & 0x03; - pixels[off++] = (p1 == transgray ? 0 : 0xF0000000) | gammaTable[p1]; - pixels[off++] = (p2 == transgray ? 0 : 0xF0000000) | gammaTable[p2]; - pixels[off++] = (p3 == transgray ? 0 : 0xF0000000) | gammaTable[p3]; - pixels[off++] = (p4 == transgray ? 0 : 0xF0000000) | gammaTable[p4]; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover2P.java b/javapng/src/main/com/sixlegs/image/png/BitMover2P.java deleted file mode 100644 index 3878330..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover2P.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover2P -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int x = str.read(); - pixels[off++] = x >>> 6 & 0x03; - pixels[off++] = x >>> 4 & 0x03; - pixels[off++] = x >>> 2 & 0x03; - pixels[off++] = x & 0x03; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover4G.java b/javapng/src/main/com/sixlegs/image/png/BitMover4G.java deleted file mode 100644 index ae7e4d8..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover4G.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover4G -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int x = str.read(); - int p1 = x >>> 4 & 0xF, p2 = x & 0xF; - pixels[off++] = (p1 == transgray ? 0 : 0xFF000000) | gammaTable[p1]; - pixels[off++] = (p1 == transgray ? 0 : 0xFF000000) | gammaTable[p2]; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover4P.java b/javapng/src/main/com/sixlegs/image/png/BitMover4P.java deleted file mode 100644 index 21e0566..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover4P.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover4P -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int x = str.read(); - pixels[off++] = x >>> 4 & 0x0F; - pixels[off++] = x & 0x0F; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover8G.java b/javapng/src/main/com/sixlegs/image/png/BitMover8G.java deleted file mode 100644 index c56880d..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover8G.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover8G -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int x = str.read(); - pixels[off++] = (x == transgray ? 0 : 0xFF000000) | gammaTable[x]; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover8GA.java b/javapng/src/main/com/sixlegs/image/png/BitMover8GA.java deleted file mode 100644 index 86564da..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover8GA.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover8GA -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - pixels[off++] = gammaTable[str.read()] | (str.read() << 24); - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover8P.java b/javapng/src/main/com/sixlegs/image/png/BitMover8P.java deleted file mode 100644 index b67194b..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover8P.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover8P -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int x = str.read(); - pixels[off++] = x; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover8RGB.java b/javapng/src/main/com/sixlegs/image/png/BitMover8RGB.java deleted file mode 100644 index 03ac96c..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover8RGB.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover8RGB -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int r = str.read(); - int g = str.read(); - int b = str.read(); - int val = gammaTable[r] << 16 | gammaTable[g] << 8 | gammaTable[b]; - pixels[off++] = ((r << 16 | g << 8 | b) == trans ? 0 : 0xFF000000) | val; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/BitMover8RGBA.java b/javapng/src/main/com/sixlegs/image/png/BitMover8RGBA.java deleted file mode 100644 index 3c62483..0000000 --- a/javapng/src/main/com/sixlegs/image/png/BitMover8RGBA.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class BitMover8RGBA -extends BitMover -{ - int fill(int[] pixels, InputStream str, int off, int len) - throws IOException - { - for (int n = 0; n < len; n++) { - int r = gammaTable[str.read()]; - int g = gammaTable[str.read()]; - int b = gammaTable[str.read()]; - pixels[off++] = r << 16 | g << 8 | b | str.read() << 24; - } - return off; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/CRCInputStream.java b/javapng/src/main/com/sixlegs/image/png/CRCInputStream.java deleted file mode 100644 index c4cf093..0000000 --- a/javapng/src/main/com/sixlegs/image/png/CRCInputStream.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.CRC32; - -final class CRCInputStream -extends FilterInputStream -{ - private CRC32 crc = new CRC32(); - private int byteCount = 0; - - public CRCInputStream(InputStream in) - { - super(in); - } - - public long getValue() - { - return (long)crc.getValue(); - } - - public void reset() - { - byteCount = 0; - crc.reset(); - } - - public int count() - { - return byteCount; - } - - public int read() - throws IOException - { - int x = in.read(); - if (x != -1) { - crc.update(x); - byteCount++; - } - return x; - } - - public int read(byte[] b, int off, int len) - throws IOException - { - int x = in.read(b, off, len); - if (x != -1) { - crc.update(b, off, x); - byteCount += x; - } - return x; - } - - private byte[] byteArray = new byte[0]; - - public long skip(long n) - throws IOException - { - // TODO: what if n > Integer.MAX_VALUE ? - if (byteArray.length < n) byteArray = new byte[(int)n]; - return read(byteArray, 0, (int)n); - } -} - diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk.java b/javapng/src/main/com/sixlegs/image/png/Chunk.java deleted file mode 100644 index 4399b71..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; - -class Chunk -implements Cloneable -{ - /* package */ int length; - /* package */ int type; - - protected PngImage img; - protected ExDataInputStream in_data; - - Chunk(int type) - { - this.type = type; - } - - Chunk copy() - { - try { - return (Chunk)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - - boolean isAncillary() - { - return ((type & 0x20000000) != 0); - } - - final boolean isPrivate () - { - return ((type & 0x00200000) != 0); - } - - final boolean isReservedSet () - { - return ((type & 0x00002000) != 0); - } - - final boolean isSafeToCopy () - { - return ((type & 0x00000020) != 0); - } - - final boolean isUnknown () - { - return getClass() == Chunk.class; - } - - int bytesRemaining() - { - return Math.max(0, length + 4 - img.data.in_idat.count()); - } - - protected boolean multipleOK() { return true; } - protected boolean beforeIDAT() { return false; } - - static String typeToString(int x) - { - return ("" + - (char)((x >>> 24) & 0xFF) + - (char)((x >>> 16) & 0xFF) + - (char)((x >>> 8) & 0xFF) + - (char)((x ) & 0xFF)); - } - - static int stringToType(String id) - { - return ((((int)id.charAt(0) & 0xFF) << 24) | - (((int)id.charAt(1) & 0xFF) << 16) | - (((int)id.charAt(2) & 0xFF) << 8) | - (((int)id.charAt(3) & 0xFF) )); - } - - final void badLength(int correct) - throws PngException - { - throw new PngException("Bad " + typeToString(type) + - " chunk length: " + in_data.unsign(length) + - " (expected " + correct + ")"); - } - - final void badLength() - throws PngException - { - throw new PngException("Bad " + typeToString(type) + - " chunk length: " + in_data.unsign(length)); - } - - protected void readData() - throws IOException - { - in_data.skipBytes(length); - } - - static final int IHDR = stringToType("IHDR"); - static final int PLTE = stringToType("PLTE"); - static final int IDAT = stringToType("IDAT"); - static final int IEND = stringToType("IEND"); - static final int bKGD = stringToType("bKGD"); - static final int cHRM = stringToType("cHRM"); - static final int gAMA = stringToType("gAMA"); - static final int hIST = stringToType("hIST"); - static final int pHYs = stringToType("pHYs"); - static final int sBIT = stringToType("sBIT"); - static final int tEXt = stringToType("tEXt"); - static final int tIME = stringToType("tIME"); - static final int tRNS = stringToType("tRNS"); - static final int zTXt = stringToType("zTXt"); - static final int sRGB = stringToType("sRGB"); - static final int sPLT = stringToType("sPLT"); - static final int oFFs = stringToType("oFFs"); - static final int sCAL = stringToType("sCAL"); - static final int iCCP = stringToType("iCCP"); - static final int pCAL = stringToType("pCAL"); - static final int iTXt = stringToType("iTXt"); - static final int gIFg = stringToType("gIFg"); - static final int gIFx = stringToType("gIFx"); -} diff --git a/javapng/src/main/com/sixlegs/image/png/ChunkHandler.java b/javapng/src/main/com/sixlegs/image/png/ChunkHandler.java deleted file mode 100644 index d92df6f..0000000 --- a/javapng/src/main/com/sixlegs/image/png/ChunkHandler.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -/** - * A class implementing the ChunkHandler interface - * can be registered using the {@link PngImage#registerChunk} - * method. - */ -public interface ChunkHandler -{ - /** - * Process chunk data. - * This method is called upon encountering a chunk - * registered as being handled by the implementing class. - * @see PngImage#registerChunk - * @param type chunk type - * @param data raw chunk data - */ - void handleChunk(String type, byte[] data); -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_IDAT.java b/javapng/src/main/com/sixlegs/image/png/Chunk_IDAT.java deleted file mode 100644 index a53b3bb..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_IDAT.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -final class Chunk_IDAT -extends Chunk -{ - Chunk_IDAT() - { - super(IDAT); - } - - protected void readData() - { } -} - diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_IEND.java b/javapng/src/main/com/sixlegs/image/png/Chunk_IEND.java deleted file mode 100644 index da40f96..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_IEND.java +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -final class Chunk_IEND -extends Chunk -{ - Chunk_IEND() - { - super(IEND); - } - - protected boolean multipleOK() - { - return false; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_IHDR.java b/javapng/src/main/com/sixlegs/image/png/Chunk_IHDR.java deleted file mode 100644 index 62fae6f..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_IHDR.java +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.awt.image.ColorModel; -import java.awt.image.DirectColorModel; -import java.io.IOException; - -final class Chunk_IHDR -extends Chunk -{ - /* package */ int width; - /* package */ int height; - /* package */ int depth; - /* package */ int outputDepth; - /* package */ int compress; - /* package */ int filter; - /* package */ int interlace; - /* package */ Interlacer interlacer; - - /* package */ int samples = 1; - /* package */ int colorType; - /* package */ int cmBits; - - /* package */ boolean paletteUsed = false; - /* package */ boolean colorUsed = false; - /* package */ boolean alphaUsed = false; - - /* package */ ColorModel alphaModel; - /* package */ ColorModel model; - - Chunk_IHDR() - { - super(IHDR); - } - - protected boolean multipleOK() - { - return false; - } - - // TODO: shorten - protected void readData() - throws IOException - { - img.data.header = this; - if (length != 13) badLength(13); - - width = in_data.readInt(); - height = in_data.readInt(); - if (width <= 0 || height <= 0) { - throw new PngException("Bad image size: " + in_data.unsign(width) + - "x" + in_data.unsign(height)); - } - - depth = in_data.readUnsignedByte(); - outputDepth = (depth == 16 ? 8 : depth); - - int blue = 0; - switch (outputDepth) { - case 1: blue = 0x01; break; - case 2: blue = 0x03; break; - case 4: blue = 0x0F; break; - case 8: blue = 0xFF; break; - default: - throw new PngException("Bad bit depth: " + depth); - } - - byte[] sbit = null; - - int green = blue << outputDepth; - int red = green << outputDepth; - int alpha = red << outputDepth; - - byte b_depth = (byte)depth; - - colorType = in_data.readUnsignedByte(); - switch (colorType) { - case PngImage.COLOR_TYPE_GRAY: - sbit = new byte[]{b_depth, b_depth, b_depth}; - cmBits = 3 * outputDepth; - break; - case PngImage.COLOR_TYPE_RGB: - sbit = new byte[]{b_depth, b_depth, b_depth}; - cmBits = 3 * outputDepth; - samples = 3; - colorUsed = true; - break; - case PngImage.COLOR_TYPE_PALETTE: - sbit = new byte[]{8, 8, 8}; - cmBits = outputDepth; - colorUsed = paletteUsed = true; - break; - case PngImage.COLOR_TYPE_GRAY_ALPHA: - sbit = new byte[]{b_depth, b_depth, b_depth, b_depth}; - cmBits = 4 * outputDepth; - samples = 2; - alphaUsed = true; - break; - case PngImage.COLOR_TYPE_RGB_ALPHA: - sbit = new byte[]{b_depth, b_depth, b_depth, b_depth}; - cmBits = 4 * outputDepth; - samples = 4; - alphaUsed = colorUsed = true; - break; - default: - cmBits = 0; - throw new PngException("Bad color type: " + colorType); - } - - img.data.properties.put("significant bits", sbit); - - if (!paletteUsed) { - if (alphaUsed) { - model = alphaModel = new DirectColorModel(cmBits, red, green, blue, alpha); - } else { - // we may switch to alphaModel if a tRNS chunk is found later - alphaModel = ColorModel.getRGBdefault(); - model = new DirectColorModel(24, 0xFF0000, 0x00FF00, 0x0000FF); - } - } - - switch (colorType) { - case PngImage.COLOR_TYPE_GRAY: - break; - case PngImage.COLOR_TYPE_PALETTE: - if (depth == 16) - throw new PngException("Bad bit depth for color type " + colorType + ": " + depth); - break; - default: - if (depth <= 4) - throw new PngException("Bad bit depth for color type " + colorType + ": " + depth); - } - - if ((compress = in_data.readUnsignedByte()) != PngImage.COMPRESSION_TYPE_BASE) - throw new PngException("Unrecognized compression method: " + compress); - - if ((filter = in_data.readUnsignedByte()) != PngImage.FILTER_TYPE_BASE) - throw new PngException("Unrecognized filter method: " + filter); - - interlace = in_data.readUnsignedByte(); - switch (interlace) { - case PngImage.INTERLACE_TYPE_NONE: - interlacer = new NullInterlacer(width, height); - break; - case PngImage.INTERLACE_TYPE_ADAM7: - interlacer = new Adam7Interlacer(width, height); - break; - default: - throw new PngException("Unrecognized interlace method: " + interlace); - } - - img.data.properties.put("width", new Integer(width)); - img.data.properties.put("height", new Integer(height)); - img.data.properties.put("bit depth", new Integer(depth)); - img.data.properties.put("interlace type", new Integer(interlace)); - img.data.properties.put("compression type", new Integer(compress)); - img.data.properties.put("filter type", new Integer(filter)); - img.data.properties.put("color type", new Integer(colorType)); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_PLTE.java b/javapng/src/main/com/sixlegs/image/png/Chunk_PLTE.java deleted file mode 100644 index 267985d..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_PLTE.java +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.awt.image.IndexColorModel; -import java.io.IOException; - -final class Chunk_PLTE -extends Chunk -{ - private int size; - - /* package */ int[] r_raw; - /* package */ int[] g_raw; - /* package */ int[] b_raw; - /* package */ int[] a_raw; - - /* package */ byte[] r; - /* package */ byte[] g; - /* package */ byte[] b; - /* package */ byte[] a; - - Chunk_PLTE() - { - super(PLTE); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - img.data.palette = this; - if (img.getChunk(bKGD) != null) { - throw new PngException("bKGD chunk must follow PLTE chunk"); - } - if (!img.data.header.colorUsed) { - throw new PngExceptionSoft("PLTE chunk found in grayscale image"); - } - if (length % 3 != 0) { - throw new PngException("PLTE chunk length indivisible by 3"); - } - size = length / 3; - - /// look into this - if (img.data.header.colorType == PngImage.COLOR_TYPE_PALETTE) { - if (size > (2 << img.data.header.depth)) { - throw new PngException("Too many palette entries"); - } else if (size > 256) { - throw new PngExceptionSoft("Too many palette entries"); - } - } - - r = new byte[size]; - g = new byte[size]; - b = new byte[size]; - - int[][] raw = new int[3][size]; - r_raw = raw[0]; - g_raw = raw[1]; - b_raw = raw[2]; - - for (int i = 0; i < size; i++) { - r_raw[i] = in_data.readUnsignedByte(); - g_raw[i] = in_data.readUnsignedByte(); - b_raw[i] = in_data.readUnsignedByte(); - } - - updateProperties(false); - } - - // TODO: stop duplication of palette data? - /* package */ void updateProperties(boolean alpha) - { - int[][] prop = new int[alpha ? 4 : 3][size]; - System.arraycopy(r_raw, 0, prop[0], 0, size); - System.arraycopy(g_raw, 0, prop[1], 0, size); - System.arraycopy(b_raw, 0, prop[2], 0, size); - if (alpha) { - System.arraycopy(a_raw, 0, prop[3], 0, size); - } - img.data.properties.put("palette", prop); - img.data.properties.put("palette size", new Integer(size)); - } - - /* package */ void calculate() - { - for (int i = 0; i < size; i++) { - r[i] = (byte)img.data.gammaTable[r_raw[i]]; - g[i] = (byte)img.data.gammaTable[g_raw[i]]; - b[i] = (byte)img.data.gammaTable[b_raw[i]]; - } - if (img.data.header.paletteUsed) { - if (a != null) { - img.data.header.model = - new IndexColorModel(img.data.header.cmBits, size, r, g, b, a); - } else { - img.data.header.model = - new IndexColorModel(img.data.header.cmBits, size, r, g, b); - } - } - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_VcHRM.java b/javapng/src/main/com/sixlegs/image/png/Chunk_VcHRM.java deleted file mode 100644 index ef11f5d..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_VcHRM.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -final class Chunk_VcHRM -extends Chunk_cHRM -{ - Chunk_VcHRM(PngImage img) - { - this.img = img; - xw = 31270; - yw = 32900; - xr = 64000; - yr = 33000; - xg = 30000; - yg = 60000; - xb = 15000; - yb = 6000; - calc(); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_bKGD.java b/javapng/src/main/com/sixlegs/image/png/Chunk_bKGD.java deleted file mode 100644 index 6bd6054..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_bKGD.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.awt.Color; -import java.io.IOException; - -final class Chunk_bKGD -extends Chunk -{ - Chunk_bKGD() - { - super(bKGD); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - int index, r, g, b; - switch (img.data.header.colorType) { - case PngImage.COLOR_TYPE_PALETTE: - if (length != 1) badLength(1); - index = in_data.readUnsignedByte(); - if (img.data.palette == null) - throw new PngException("hIST chunk must follow PLTE chunk"); - img.data.properties.put("background index", new Integer(index)); - r = img.data.palette.r_raw[index]; - g = img.data.palette.g_raw[index]; - b = img.data.palette.b_raw[index]; - break; - - case PngImage.COLOR_TYPE_GRAY: - case PngImage.COLOR_TYPE_GRAY_ALPHA: - if (length != 2) badLength(2); - if (img.data.header.depth == 16) { - r = g = b = in_data.readUnsignedByte(); - int low = in_data.readUnsignedByte(); - img.data.properties.put("background low bytes", new Color(low, low, low)); - } else { - r = g = b = in_data.readUnsignedShort(); - } - break; - - default: // truecolor - if (length != 6) badLength(6); - if (img.data.header.depth == 16) { - r = in_data.readUnsignedByte(); - int low_r = in_data.readUnsignedByte(); - g = in_data.readUnsignedByte(); - int low_g = in_data.readUnsignedByte(); - b = in_data.readUnsignedByte(); - int low_b = in_data.readUnsignedByte(); - img.data.properties.put("background low bytes", new Color(low_r, low_g, low_b)); - } else { - r = in_data.readUnsignedShort(); - g = in_data.readUnsignedShort(); - b = in_data.readUnsignedShort(); - } - } - img.data.properties.put("background", new Color(r, g, b)); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_cHRM.java b/javapng/src/main/com/sixlegs/image/png/Chunk_cHRM.java deleted file mode 100644 index d765978..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_cHRM.java +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -class Chunk_cHRM -extends Chunk -{ - protected long xwlong, ywlong, xrlong, yrlong, xglong, yglong, xblong, yblong; - protected double xw, yw, xr, yr, xg, yg, xb, yb; - protected double Xw, Yw, Zw; - protected double Xr, Yr, Zr; - protected double Xg, Yg, Zg; - protected double Xb, Yb, Zb; - - Chunk_cHRM() - { - super(cHRM); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - /* - zr = 1 - (xr + yr) - zg = 1 - (xg + yg) - zb = 1 - (xb + yb) - zw = 1 - (xw + yw) - - / r \ / xr xg xb \-1 / xw / yw \ - | g | = | yr yg yb | | yw / yw | - \ b / \ zr zg zb / \ zw / yw / - - det: xr*yg*zb + xg*yb*zr + xb*yr*zg - xg*yr*zb - xr*yb*zg - xb*yg*zr - - Yr = r * yr - Yg = g * yg - Yb = b * yb - */ - - protected void calc() - { - double zr = 1 - (xr + yr); - double zg = 1 - (xg + yg); - double zb = 1 - (xb + yb); - double zw = 1 - (xw + yw); - - Xw = xw / yw; - Yw = 1; /* yw / yw; */ - Zw = zw / yw; - - double det = xr*(yg*zb-zg*yb)-xg*(yr*zb-zr*yb)+xb*(yr*zg-zr*yg); - double fr = (Xw*(yg*zb-zg*yb)-xg*(zb-Zw*yb)+xb*(zg-Zw*yg))/det; - double fg = (xr*(zb-Zw*yb)-Xw*(yr*zb-zr*yb)+xb*(yr*Zw-zr))/det; - double fb = (xr*(yg*Zw-zg)-xg*(yr*Zw-zr)+Xw*(yr*zg-zr*yg))/det; - - Xr = fr * xr; Yr = fr * yr; Zr = fr * zr; - Xg = fg * xg; Yg = fg * yg; Zg = fg * zg; - Xb = fb * xb; Yb = fb * yb; Zb = fb * zb; - - if (img.getChunk(sRGB) == null) { - img.data.properties.put("chromaticity xy", - new long[][]{{xwlong,ywlong}, - {xrlong,yrlong}, - {xglong,yglong}, - {xblong,yblong}}); - img.data.properties.put("chromaticity xyz", - new double[][]{{Xw, Yw, Zw}, - {Xr, Yr, Zr}, - {Xg, Yg, Zg}, - {Xb, Yb, Zb}}); - } - } - - protected void readData() - throws IOException - { - if (img.data.palette != null) - throw new PngException("cHRM chunk must precede PLTE chunk"); - if (length != 32) badLength(32); - checkRange(xw = (double)(xwlong = in_data.readUnsignedInt()) / 100000, "white"); - checkRange(yw = (double)(ywlong = in_data.readUnsignedInt()) / 100000, "white"); - checkRange(xr = (double)(xrlong = in_data.readUnsignedInt()) / 100000, "red"); - checkRange(yr = (double)(yrlong = in_data.readUnsignedInt()) / 100000, "red"); - checkRange(xg = (double)(xglong = in_data.readUnsignedInt()) / 100000, "green"); - checkRange(yg = (double)(yglong = in_data.readUnsignedInt()) / 100000, "green"); - checkRange(xb = (double)(xblong = in_data.readUnsignedInt()) / 100000, "blue"); - checkRange(yb = (double)(yblong = in_data.readUnsignedInt()) / 100000, "blue"); - - calc(); - } - - private void checkRange(double value, String color) - throws PngException - { - if (value < 0 || value > 0.8) - throw new PngExceptionSoft("Invalid cHRM " + color + " point"); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_gAMA.java b/javapng/src/main/com/sixlegs/image/png/Chunk_gAMA.java deleted file mode 100644 index 912840d..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_gAMA.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_gAMA -extends Chunk -{ - Chunk_gAMA() - { - super(gAMA); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - if (img.data.palette != null) - throw new PngException("gAMA chunk must precede PLTE chunk"); - if (length != 4) badLength(4); - long gamma = in_data.readUnsignedInt(); - - if (gamma == 0) - throw new PngExceptionSoft("Meaningless zero gAMA chunk value"); - - if (img.getChunk(sRGB) == null) - img.data.properties.put("gamma", new Long(gamma)); - } - -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_gIFg.java b/javapng/src/main/com/sixlegs/image/png/Chunk_gIFg.java deleted file mode 100644 index 8c8e059..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_gIFg.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_gIFg -extends Chunk -{ - Chunk_gIFg() - { - super(gIFg); - } - - protected void readData() - throws IOException - { - img.data.properties.put("gif disposal method", new Integer(in_data.readUnsignedByte())); - img.data.properties.put("gif user input flag", new Integer(in_data.readUnsignedByte())); - img.data.properties.put("gif delay time", new Integer(in_data.readShort())); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_gIFx.java b/javapng/src/main/com/sixlegs/image/png/Chunk_gIFx.java deleted file mode 100644 index 52e1413..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_gIFx.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_gIFx -extends Chunk -implements GifExtension -{ - private String identifier; - private byte[] auth_code; - private byte[] data; - - Chunk_gIFx() - { - super(gIFx); - } - - protected void readData() - throws IOException - { - identifier = in_data.readString(8, PngImage.ASCII_ENCODING); - in_data.skip(8 - identifier.length()); - - auth_code = new byte[3]; - in_data.readFully(auth_code); - - data = new byte[bytesRemaining()]; - in_data.readFully(data); - - img.data.gifExtensions.addElement(this); - } - - public String getIdentifier() - { - return identifier; - } - - public byte[] getAuthenticationCode() - { - return auth_code; - } - - public byte[] getData() - { - return data; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_hIST.java b/javapng/src/main/com/sixlegs/image/png/Chunk_hIST.java deleted file mode 100644 index 9f5f037..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_hIST.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_hIST -extends Chunk -{ - Chunk_hIST() - { - super(hIST); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - if (img.data.palette == null) - throw new PngException("hIST chunk must follow PLTE chunk"); - int num = img.data.palette.r.length; - if (length != num * 2) badLength(num * 2); - int[] values = new int[num]; - for (int i = 0; i < num; i++) - values[i] = in_data.readUnsignedShort(); - img.data.properties.put("histogram", values); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_iCCP.java b/javapng/src/main/com/sixlegs/image/png/Chunk_iCCP.java deleted file mode 100644 index 134eeb9..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_iCCP.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; - -final class Chunk_iCCP -extends KeyValueChunk -{ - Chunk_iCCP() { super(iCCP); } - - protected boolean isCompressed() - { - return true; - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected String getEncoding() - { - return PngImage.LATIN1_ENCODING; - } - - protected void readData() - throws IOException - { - if (img.data.palette != null) - throw new PngException("iCCP chunk must precede PLTE chunk"); - super.readData(); - - img.data.properties.put("icc profile name", key); - img.data.properties.put("icc profile", value); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_iTXt.java b/javapng/src/main/com/sixlegs/image/png/Chunk_iTXt.java deleted file mode 100644 index c71c820..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_iTXt.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_iTXt extends AbstractTextChunk implements TextChunk { - private boolean compressed; - private String language; - private String translated; - - Chunk_iTXt() - { - super(iTXt); - } - - public String getTranslatedKeyword() - { - return translated; - } - - public String getLanguage() - { - return language; - } - - protected boolean isCompressed() - { - return compressed; - } - - protected String readValue() - throws IOException - { - int flag = in_data.readByte(); - int method = in_data.readByte(); - if (flag == 1) { - compressed = true; - if (method != PngImage.COMPRESSION_TYPE_BASE) { - throw new PngExceptionSoft("Unrecognized " + typeToString(type) + - " compression method: " + method); - } - } else if (flag != 0) { - throw new PngExceptionSoft("Illegal " + typeToString(type) + - " compression flag: " + flag); - } - language = in_data.readString(PngImage.LATIN1_ENCODING); - translated = in_data.readString(PngImage.UTF8_ENCODING); - return super.readValue(); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_oFFs.java b/javapng/src/main/com/sixlegs/image/png/Chunk_oFFs.java deleted file mode 100644 index 5141e05..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_oFFs.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_oFFs -extends Chunk -{ - Chunk_oFFs () - { - super(oFFs); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - int imagePositionX = in_data.readInt(); - int imagePositionY = in_data.readInt(); - int unit = in_data.readUnsignedByte(); - if (unit != PngImage.UNIT_PIXEL && unit != PngImage.UNIT_MICROMETER) - throw new PngExceptionSoft("Illegal oFFs chunk unit specifier: " + unit); - - img.data.properties.put("image position x", new Integer(imagePositionX)); - img.data.properties.put("image position y", new Integer(imagePositionY)); - img.data.properties.put("image position unit", new Integer(unit)); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_pCAL.java b/javapng/src/main/com/sixlegs/image/png/Chunk_pCAL.java deleted file mode 100644 index f1b95ec..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_pCAL.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_pCAL -extends Chunk -{ - Chunk_pCAL() - { - super(pCAL); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - String purpose, unit_string; - - if ((purpose = in_data.readString()).length() > 79) { - throw new PngExceptionSoft("pCAL purpose too long"); - } - purpose = KeyValueChunk.repairKey(purpose); - - int X0 = in_data.readInt(); - int X1 = in_data.readInt(); - if (X1 == X0) { - throw new PngExceptionSoft("X1 == X0 in pCAL chunk"); - } - - int equation_type = in_data.readUnsignedByte(); - int N = in_data.readUnsignedByte(); - - if ((unit_string = in_data.readString()).length() > 79) { - throw new PngExceptionSoft("pCAL unit string too long"); - } - - double[] P = new double[N]; - for (int i = 0; i < N; i++) { - P[i] = in_data.readFloatingPoint(); - } - - img.data.properties.put("pixel calibration purpose", purpose); - img.data.properties.put("pixel calibration x0", new Integer(X0)); - img.data.properties.put("pixel calibration x1", new Integer(X1)); - img.data.properties.put("pixel calibration type", new Integer(equation_type)); - img.data.properties.put("pixel calibration n", new Integer(N)); - img.data.properties.put("pixel calibration unit", unit_string); - img.data.properties.put("pixel calibration parameters", P); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_pHYs.java b/javapng/src/main/com/sixlegs/image/png/Chunk_pHYs.java deleted file mode 100644 index 8ed0c39..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_pHYs.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_pHYs -extends Chunk -{ - Chunk_pHYs() - { - super(pHYs); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - long pixelsPerUnitX = in_data.readUnsignedInt(); - long pixelsPerUnitY = in_data.readUnsignedInt(); - int unit = in_data.readUnsignedByte(); - if (unit != PngImage.UNIT_UNKNOWN && unit != PngImage.UNIT_METER) - throw new PngExceptionSoft("Illegal pHYs chunk unit specifier: " + unit); - - img.data.properties.put("pixel dimensions x", new Long(pixelsPerUnitX)); - img.data.properties.put("pixel dimensions y", new Long(pixelsPerUnitY)); - img.data.properties.put("pixel dimensions unit", new Integer(unit)); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_sBIT.java b/javapng/src/main/com/sixlegs/image/png/Chunk_sBIT.java deleted file mode 100644 index 453724d..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_sBIT.java +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_sBIT -extends Chunk -{ - Chunk_sBIT() - { - super(sBIT); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - byte[] sbit = null; - if (img.data.palette != null) - throw new PngException("sBIT chunk must precede PLTE chunk"); - int compare_depth = img.data.header.depth; - switch (img.data.header.colorType) { - case PngImage.COLOR_TYPE_GRAY: - sbit = new byte[3]; - sbit[0] = sbit[1] = sbit[2] = in_data.readByte(); - break; - case PngImage.COLOR_TYPE_PALETTE: - compare_depth = 8; - /* fall through */ - case PngImage.COLOR_TYPE_RGB: - sbit = new byte[3]; - sbit[0] = in_data.readByte(); - sbit[1] = in_data.readByte(); - sbit[2] = in_data.readByte(); - break; - case PngImage.COLOR_TYPE_GRAY_ALPHA: - sbit = new byte[4]; - sbit[0] = sbit[1] = sbit[2] = in_data.readByte(); - sbit[3] = in_data.readByte(); - break; - case PngImage.COLOR_TYPE_RGB_ALPHA: - sbit = new byte[4]; - sbit[0] = in_data.readByte(); - sbit[1] = in_data.readByte(); - sbit[2] = in_data.readByte(); - sbit[3] = in_data.readByte(); - break; - } - for (int i = 0; i < sbit.length; i++) { - if (sbit[i] <= 0 || sbit[i] > compare_depth) - throw new PngExceptionSoft("Illegal sBIT component depth"); - } - - img.data.properties.put("significant bits", sbit); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_sCAL.java b/javapng/src/main/com/sixlegs/image/png/Chunk_sCAL.java deleted file mode 100644 index be12b97..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_sCAL.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_sCAL -extends Chunk -{ - Chunk_sCAL() - { - super(sCAL); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - int unit = in_data.readUnsignedByte(); - if (unit != PngImage.UNIT_METER && unit != PngImage.UNIT_RADIAN) - throw new PngExceptionSoft("Illegal sCAL chunk unit specifier: " + unit); - - String pixelWidthStr = in_data.readString(); - int limit = length - pixelWidthStr.length() + 2; - try { - double pixelWidth = in_data.parseFloatingPoint(pixelWidthStr); - double pixelHeight = in_data.parseFloatingPoint(in_data.readString(limit)); - if (pixelWidth < 0 || pixelHeight < 0) throw new NumberFormatException(); - - img.data.properties.put("pixel scale x", new Double(pixelWidth)); - img.data.properties.put("pixel scale y", new Double(pixelHeight)); - img.data.properties.put("pixel scale unit", new Integer(unit)); - } catch (NumberFormatException e) { - throw new PngExceptionSoft("Bad floating point value in sCAL chunk"); - } - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_sPLT.java b/javapng/src/main/com/sixlegs/image/png/Chunk_sPLT.java deleted file mode 100644 index 69f40ae..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_sPLT.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_sPLT -extends Chunk -{ - Chunk_sPLT() - { - super(sPLT); - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - String name; - if ((name = in_data.readString()).length() > 79) - throw new PngExceptionSoft("sPLT palette name too long"); - name = KeyValueChunk.repairKey(name); - if (img.data.palettes.containsKey(name)) - throw new PngExceptionSoft("Duplicate sPLT names"); - int depth = in_data.readUnsignedByte(); - int L = length - name.length(); - int[][] prop; - if (depth == 8) { - if (L % 6 != 0) badLength(); - int n = L / 6; - prop = new int[5][n]; - for (int i = 0; i < n; i++) { - prop[0][i] = in_data.readUnsignedByte(); - prop[1][i] = in_data.readUnsignedByte(); - prop[2][i] = in_data.readUnsignedByte(); - prop[3][i] = in_data.readUnsignedByte(); - prop[4][i] = in_data.readUnsignedShort(); - } - } else if (depth == 16) { - if (L % 10 != 0) badLength(); - int n = L / 10; - prop = new int[5][n]; - for (int i = 0; i < n; i++) { - prop[0][i] = in_data.readUnsignedShort(); - prop[1][i] = in_data.readUnsignedShort(); - prop[2][i] = in_data.readUnsignedShort(); - prop[3][i] = in_data.readUnsignedShort(); - prop[4][i] = in_data.readUnsignedShort(); - } - } else { - throw new PngExceptionSoft("Bad sPLT sample depth: " + depth); - } - img.data.palettes.put(name, prop); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_sRGB.java b/javapng/src/main/com/sixlegs/image/png/Chunk_sRGB.java deleted file mode 100644 index 2938ef6..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_sRGB.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; -import java.io.IOException; - -final class Chunk_sRGB -extends Chunk -{ - Chunk_sRGB() - { - super(sRGB); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - if (img.data.palette != null) - throw new PngException("sRGB chunk must precede PLTE chunk"); - if (length != 1) badLength(1); - int intent = in_data.readUnsignedByte(); - - new Chunk_VcHRM(img); - img.data.properties.put("gamma", new Long(PngImage.DEFAULT_GAMMA)); - img.data.properties.put("srgb rendering intent", new Integer(intent)); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_tEXt.java b/javapng/src/main/com/sixlegs/image/png/Chunk_tEXt.java deleted file mode 100644 index 6a8b7e5..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_tEXt.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -final class Chunk_tEXt -extends AbstractTextChunk -{ - Chunk_tEXt() - { - super(tEXt); - } - - protected boolean isCompressed() - { - return false; - } - - public String getTranslatedKeyword() - { - return null; - } - - public String getLanguage() - { - return null; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_tIME.java b/javapng/src/main/com/sixlegs/image/png/Chunk_tIME.java deleted file mode 100644 index e6195ca..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_tIME.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.util.Calendar; -import java.util.TimeZone; - -final class Chunk_tIME -extends Chunk -{ - Chunk_tIME() - { - super(tIME); - } - - protected boolean multipleOK() - { - return false; - } - - protected void readData() - throws IOException - { - TimeZone tz = TimeZone.getDefault(); - tz.setRawOffset(0); - Calendar cal = Calendar.getInstance(tz); - int year = in_data.readUnsignedShort(); - int month = in_data.readUnsignedByte(); - int day = in_data.readUnsignedByte(); - int hour = in_data.readUnsignedByte(); - int minute = in_data.readUnsignedByte(); - int second = in_data.readUnsignedByte(); - if (month > 12 || day > 31 || hour > 23 || minute > 59 || second > 60 || - month < 1 || day < 1 || hour < 0 || minute < 0 || second < 0) - throw new PngExceptionSoft("Bad tIME data; index out of bounds"); - cal.set(year, month - 1, day, hour, minute, second); - - img.data.properties.put("time", cal.getTime()); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_tRNS.java b/javapng/src/main/com/sixlegs/image/png/Chunk_tRNS.java deleted file mode 100644 index 4b2f414..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_tRNS.java +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.awt.Color; -import java.io.IOException; - -final class Chunk_tRNS -extends Chunk -{ - /* package */ int rgb; - /* package */ int rgb_low; - /* package */ int r, g, b; - - Chunk_tRNS() - { - super(tRNS); - } - - protected boolean multipleOK() - { - return false; - } - - protected boolean beforeIDAT() - { - return true; - } - - protected void readData() - throws IOException - { - int d = img.data.header.outputDepth; - switch (img.data.header.colorType) { - case PngImage.COLOR_TYPE_GRAY: - if (length != 2) badLength(2); - if (img.data.header.depth == 16) { - r = g = b = in_data.readUnsignedByte(); - int low = in_data.readUnsignedByte(); - img.data.properties.put("transparency low bytes", new Color(low, low, low)); - } else { - r = g = b = in_data.readUnsignedShort(); - } - rgb = r | r << d | r << (d * 2); - img.data.header.model = img.data.header.alphaModel; - img.data.properties.put("transparency", new Color(r, g, b)); - break; - - case PngImage.COLOR_TYPE_RGB: - if (length != 6) badLength(6); - if (img.data.header.depth == 16) { - r = in_data.readUnsignedByte(); - int low_r = in_data.readUnsignedByte(); - g = in_data.readUnsignedByte(); - int low_g = in_data.readUnsignedByte(); - b = in_data.readUnsignedByte(); - int low_b = in_data.readUnsignedByte(); - rgb_low = low_b | low_g << 8 | low_r << 16; - img.data.properties.put("transparency low bytes", new Color(low_r, low_g, low_b)); - } else { - r = in_data.readUnsignedShort(); - g = in_data.readUnsignedShort(); - b = in_data.readUnsignedShort(); - } - rgb = b | g << d | r << (d * 2); - img.data.header.model = img.data.header.alphaModel; - img.data.properties.put("transparency", new Color(r, g, b)); - break; - - case PngImage.COLOR_TYPE_PALETTE: - if (img.data.palette == null) - throw new PngException("tRNS chunk must follow PLTE chunk"); - Chunk_PLTE p = img.data.palette; - int size = p.r.length; - if (length > size) badLength(); - p.a_raw = new int[size]; - p.a = new byte[size]; - int i = 0; - while (i < length) { - p.a[i] = (byte)(p.a_raw[i] = in_data.readUnsignedByte()); - i++; - } - while (i < size) { - p.a[i] = (byte)(p.a_raw[i] = 0xFF); - i++; - } - img.data.properties.put("transparency size", new Integer(length)); - p.updateProperties(true); - break; - - default: - throw new PngException("tRNS prohibited for color type " + img.data.header.colorType); - } - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Chunk_zTXt.java b/javapng/src/main/com/sixlegs/image/png/Chunk_zTXt.java deleted file mode 100644 index 02e1211..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Chunk_zTXt.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -final class Chunk_zTXt -extends AbstractTextChunk -{ - Chunk_zTXt() - { - super(zTXt); - } - - protected boolean isCompressed() - { - return true; - } - - public String getTranslatedKeyword() - { - return null; - } - - public String getLanguage() - { - return null; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/DummyImageConsumer.java b/javapng/src/main/com/sixlegs/image/png/DummyImageConsumer.java deleted file mode 100644 index f5c3139..0000000 --- a/javapng/src/main/com/sixlegs/image/png/DummyImageConsumer.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.util.Hashtable; -import java.awt.image.ColorModel; -import java.awt.image.ImageConsumer; - -class DummyImageConsumer -implements ImageConsumer -{ - public void setDimensions(int width, int height) - { } - - public void setProperties(Hashtable props) - { } - - public void setHints(int hintflags) - { } - - public void setPixels(int x, int y, int w, int h, - ColorModel model, byte pixels[], int off, int scansize) - { } - - public void setPixels(int x, int y, int w, int h, - ColorModel model, int pixels[], int off, int scansize) - { } - - public void imageComplete(int status) - { } - - public void setColorModel(ColorModel model) - { } -} diff --git a/javapng/src/main/com/sixlegs/image/png/EmptyEnumeration.java b/javapng/src/main/com/sixlegs/image/png/EmptyEnumeration.java deleted file mode 100644 index 33607c4..0000000 --- a/javapng/src/main/com/sixlegs/image/png/EmptyEnumeration.java +++ /dev/null @@ -1,45 +0,0 @@ -/* -com.sixlegs.image.png - Java package to read and display PNG images -Copyright (C) 1998-2004 Chris Nokleberg - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the -Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -package com.sixlegs.image.png; - -import java.util.Enumeration; -import java.util.NoSuchElementException; - -public class EmptyEnumeration -implements Enumeration -{ - private static final EmptyEnumeration INSTANCE = new EmptyEnumeration(); - - public static EmptyEnumeration getInstance() - { - return INSTANCE; - } - - public boolean hasMoreElements() - { - return false; - } - - public Object nextElement() - { - throw new NoSuchElementException(); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/ExDataInputStream.java b/javapng/src/main/com/sixlegs/image/png/ExDataInputStream.java deleted file mode 100644 index edeaca7..0000000 --- a/javapng/src/main/com/sixlegs/image/png/ExDataInputStream.java +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; - -final class ExDataInputStream -extends DataInputStream -{ - - public ExDataInputStream(InputStream in) - { - super(in); - } - - public static long unsign(int x) - { - return 0xFFFFFFFFL & x; - } - - public long readUnsignedInt() - throws IOException - { - return unsign(readInt()); - } - - public String readString() - throws IOException - { - return readString(-1, PngImage.LATIN1_ENCODING); - } - - public String readString(String encoding) - throws IOException - { - return readString(-1, encoding); - } - - public String readString(int limit) - throws IOException - { - return readString(limit, PngImage.LATIN1_ENCODING); - } - - public String readString(int limit, String encoding) - throws IOException - { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(limit < 0 ? 80 : limit); - int i; - for (i = 0; i != limit; i++) { - int b = readByte(); - if (b == 0) break; - bytes.write(b); - } - return bytes.toString(encoding); - } - - static public double parseFloatingPoint(String token) - { - int st = 0; - int e1 = Math.max(token.indexOf('e'),token.indexOf('E')); - double d = Double.valueOf(token.substring(st, (e1 < 0 ? token.length() : e1))).doubleValue(); - if (e1 > 0) d *= Math.pow(10d, Double.valueOf(token.substring(e1+1)).doubleValue()); - return d; - } - - public double readFloatingPoint() - throws IOException - { - return parseFloatingPoint(readString()); - } - -// public int readBytes(byte[] b) -// throws IOException -// { -// return readBytes(b, 0, b.length); -// } - -// public int readBytes(byte[] b, int off, int len) -// throws IOException -// { -// int total = 0; -// while (total < len) { -// int result = in.read(b, off + total, len - total); -// if (result == -1) { -// throw new EOFException(); -// } -// total += result; -// } -// return total; -// } -} diff --git a/javapng/src/main/com/sixlegs/image/png/GifExtension.java b/javapng/src/main/com/sixlegs/image/png/GifExtension.java deleted file mode 100644 index 0d8fdda..0000000 --- a/javapng/src/main/com/sixlegs/image/png/GifExtension.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -/** - * Interface to GIF Application Extension chunks (gIFx), - * which constains application-specific information converted - * from GIF89a files. - * @see PngImage#getGifExtensions - */ -public interface GifExtension -{ - /** - * Returns the Application Identifier of this GifExtension, - * which identifies the application that created the extension. - */ - String getIdentifier(); - - /** - * Returns a the Authentication Code of this GifExtension, - * which may be used to further validate the extension. - */ - byte[] getAuthenticationCode(); - - /** - * Returns the application-specific data of this GifExtension, which - * is not defined by the GIF specification. - */ - byte[] getData(); -} diff --git a/javapng/src/main/com/sixlegs/image/png/IDATInputStream.java b/javapng/src/main/com/sixlegs/image/png/IDATInputStream.java deleted file mode 100644 index ab95724..0000000 --- a/javapng/src/main/com/sixlegs/image/png/IDATInputStream.java +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class IDATInputStream -extends InputStream -{ - private static final int[] signature = { 137, 80, 78, 71, 13, 10, 26, 10 }; - - private InputStream in_raw; - private CRCInputStream in_crc; - private ExDataInputStream in_data; - - private PngImage img; - private Chunk cur; - private int chunk_left; - private boolean close; - - public IDATInputStream(PngImage img, InputStream in_raw, boolean close) - { - this.img = img; - this.in_raw = in_raw; - this.close = close; - in_crc = new CRCInputStream(in_raw); - in_data = new ExDataInputStream(in_crc); - } - - // TODO: worry about non-consecutive IDAT chunks - - /* package */ void readToData() - throws IOException - { - if (cur != null) return; - for (int i = 0; i < 8; i++) { - int b = in_data.readUnsignedByte(); - if (b != signature[i]) { - throw new PngException("Improper signature, byte " + i + " should be 0x" + Integer.toHexString(signature[i]) + " but is 0x" + Integer.toHexString(b)); - } - } - try { - if (getNextChunk().type != Chunk.IHDR) { - throw new PngException("IHDR chunk must be first chunk"); - } - while (getNextChunk().type != Chunk.IDAT); - if (img.data.palette == null) { - if (img.data.header.paletteUsed) { - throw new PngException("Required PLTE chunk not found"); - } - } - img.fillGammaTable(); - } catch (NullPointerException e) { - throw new PngException("Can't find data chunk"); - } - } - - /* package */ int count() - { - return in_crc.count(); - } - - private void readChunk(Chunk chunk) - throws IOException - { - try { - if (!chunk.multipleOK() && img.getChunk(chunk.type) != null) { - String msg = "Multiple " + Chunk.typeToString(chunk.type) + " chunks are not allowed"; - if (chunk.isAncillary()) { - throw new PngExceptionSoft(msg); - } else { - throw new PngException(msg); - } - } - chunk.readData(); - img.putChunk(chunk.type, chunk); - } catch (PngExceptionSoft e) { - if (PngImage.allFatal) throw e; - img.addError(e); - } finally { - in_data.skipBytes(chunk.bytesRemaining()); - long crc_is = in_crc.getValue(); - long crc_should_be = in_data.readUnsignedInt(); - if (crc_is != crc_should_be) { - throw new PngException("Bad CRC value for " + Chunk.typeToString(chunk.type) + " chunk"); - } - } - } - - private Chunk getNextChunk() - throws IOException - { - if (cur != null) { - readChunk(cur); - if (cur.type == Chunk.IEND) { - return null; - } - } - - chunk_left = in_data.readInt(); - - in_crc.reset(); - int type = in_data.readInt(); - - if (chunk_left < 0) { - throw new PngException("Bad " + Chunk.typeToString(type) + " chunk length: " + in_data.unsign(chunk_left)); - } - - cur = PngImage.getRegisteredChunk(type); - cur.img = img; - cur.length = chunk_left; - cur.in_data = in_data; - - if (cur.isUnknown()) { - String type_string = Chunk.typeToString(type); - if (!cur.isAncillary()) { - throw new PngException("Private critical chunk encountered: " + type_string); - } - for (int i = 0; i < 4; i++) { - char c = type_string.charAt(i); - if (c < 65 || (c > 90 && c < 97) || c > 122) { - throw new PngException("Corrupted chunk type: " + type_string); - } - } - } - return cur; - } - - public int read(byte b[], int off, int len) - throws IOException - { - if (cur == null) - readToData(); - if (chunk_left == 0) - return -1; - int need = chunk_left < len ? chunk_left : len; - in_data.readFully(b, off, need); - chunk_left -= need; - if (chunk_left == 0 && getNextChunk().type != Chunk.IDAT) { - Chunk chunk; - while ((chunk = getNextChunk()) != null) { - if (chunk.beforeIDAT()) { - throw new PngException(Chunk.typeToString(chunk.type) + " chunk must precede first IDAT chunk"); - } - } - if (close) - close(); - } - return need; - } - - private byte[] _b = new byte[1]; - - public int read() - throws IOException - { - return read(_b, 0, 1) > 0 ? _b[0] & 0xff : -1; - } - - public void close() - throws IOException - { - in_data.close(); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/Interlacer.java b/javapng/src/main/com/sixlegs/image/png/Interlacer.java deleted file mode 100644 index 31d54ef..0000000 --- a/javapng/src/main/com/sixlegs/image/png/Interlacer.java +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -abstract class Interlacer -{ - abstract int numPasses(); - abstract int getSpacingX(int pass); - abstract int getSpacingY(int pass); - abstract int getOffsetX(int pass); - abstract int getOffsetY(int pass); - - private int maxSpacingX = 0; - private int maxSpacingY = 0; - private int widestPass = 0; - - protected int w, h; - - Interlacer(int w, int h) - { - this.w = w; - this.h = h; - int minSpacingX = w; - int n = numPasses(); - for (int i = 0; i < n; i++) { - int sp_x = getSpacingX(i); - if (sp_x < minSpacingX) { - minSpacingX = sp_x; - widestPass = i; - } - maxSpacingX = Math.max(maxSpacingX, sp_x); - maxSpacingY = Math.max(maxSpacingY, getSpacingY(i)); - } - } - - final int getMaxSpacingX() - { - return maxSpacingX; - } - - final int getMaxSpacingY() - { - return maxSpacingY; - } - - final int getMaxPassWidth() - { - return getPassWidth(widestPass); - } - - final int getPassWidth(int pass) - { - return ((w / maxSpacingX) * countPixelsX(pass, maxSpacingX) + - countPixelsX(pass, w % maxSpacingX)); - } - - final int getPassHeight(int pass) - { - return ((h / maxSpacingY) * countPixelsY(pass, maxSpacingY) + - countPixelsY(pass, h % maxSpacingY)); - } - - final int getBlockWidth(int pass) - { - return getSpacingX(pass) - getOffsetX(pass); - } - - final int getBlockHeight(int pass) - { - return getSpacingY(pass) - getOffsetY(pass); - } - - final int countPixelsX(int pass, int w) - { - int cur = 0; - int next = getOffsetX(pass); - int sp = getSpacingX(pass); - for (int x = 0; x < w; x++) { - if (x == next) { - cur++; - next = x + sp; - } - } - return cur; - } - - final int countPixelsY(int pass, int h) - { - int cur = 0; - int next = getOffsetY(pass); - int sp = getSpacingY(pass); - for (int y = 0; y < h; y++) { - if (y == next) { - cur++; - next = y + sp; - } - } - return cur; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/KeyValueChunk.java b/javapng/src/main/com/sixlegs/image/png/KeyValueChunk.java deleted file mode 100644 index 5639b01..0000000 --- a/javapng/src/main/com/sixlegs/image/png/KeyValueChunk.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.zip.DataFormatException; -import java.util.zip.Inflater; - -abstract class KeyValueChunk -extends Chunk -{ - protected String key; - protected String value; - - KeyValueChunk(int type) - { - super(type); - } - - protected abstract boolean isCompressed(); - - protected String getEncoding() - { - return PngImage.LATIN1_ENCODING; - }; - - protected void readData() - throws IOException - { - key = readKey(); - value = readValue(); - } - - protected String readKey() - throws IOException - { - String raw_key = in_data.readString(); - if (raw_key.length() > 79) - throw new PngExceptionSoft(typeToString(type) + " string too long"); - return repairKey(raw_key); - } - - protected String readValue() - throws IOException - { - int L = bytesRemaining(); - byte[] buf = new byte[L]; - in_data.readFully(buf); - - if (isCompressed()) { - byte method = buf[0]; - if (method != PngImage.COMPRESSION_TYPE_BASE) { - throw new PngExceptionSoft("Unrecognized " + typeToString(type) + - " compression method: " + method); - } - ByteArrayOutputStream bytes = new ByteArrayOutputStream(L * 3); - byte[] tbuf = new byte[512]; - Inflater inf = new Inflater(); - inf.reset(); - inf.setInput(buf, 1, L - 1); - try { - while (!inf.needsInput()) { - bytes.write(tbuf, 0, inf.inflate(tbuf)); - } - } catch (DataFormatException e) { - throw new PngExceptionSoft("Error inflating " + typeToString(type) + " chunk: " + e); - } - return bytes.toString(getEncoding()); - } else { - return new String(buf, 0, L, getEncoding()); - } - } - - /* package */ static String repairKey (String k) { - char[] chs = k.toCharArray(); - int i = 0, p = 0; - int L = chs.length; - BIGLOOP: - while (p < L) { - char ch = chs[p++]; - if (Character.isWhitespace(ch)) { - if (i > 0) chs[i++] = ' '; - while (Character.isWhitespace(ch = chs[p++])) - if (p == L) break BIGLOOP; - } - chs[i++] = ch; - } - if (Character.isWhitespace(chs[i-1])) i--; - return new String(chs, 0, i); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/NullInterlacer.java b/javapng/src/main/com/sixlegs/image/png/NullInterlacer.java deleted file mode 100644 index fbecb6e..0000000 --- a/javapng/src/main/com/sixlegs/image/png/NullInterlacer.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -final class NullInterlacer -extends Interlacer -{ - NullInterlacer(int w, int h) - { - super(w, h); - } - - final int numPasses() - { - return 1; - } - - final int getSpacingX(int pass) - { - return 1; - } - - final int getSpacingY(int pass) - { - return 1; - } - - final int getOffsetX(int pass) - { - return 0; - } - - final int getOffsetY(int pass) - { - return 0; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/PixelReader.java b/javapng/src/main/com/sixlegs/image/png/PixelReader.java deleted file mode 100644 index 447a497..0000000 --- a/javapng/src/main/com/sixlegs/image/png/PixelReader.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; - -final class PixelReader -{ - final private BitMover mover; - final private InputStream str; - private int[] leftover = new int[8]; - private int leftamt = 0; - - /* package */ final int fillSize; - - PixelReader(PngImage img, InputStream str) - throws PngException - { - this.str = str; - fillSize = Math.max(1, 8 / img.data.header.depth); - mover = BitMover.getBitMover(img); - } - - int read(int b[], int off, int len) - throws IOException - { - int needed = len; - int total = len; - if (leftamt > 0) { - int fromleft = (needed > leftamt ? leftamt : needed); - System.arraycopy(leftover, 8 - leftamt, b, off, fromleft); - needed -= fromleft; - leftamt -= fromleft; - } - if (needed > 0) { - off = mover.fill(b, str, off, needed / fillSize); - needed %= fillSize; - if (needed > 0) { - leftamt = fillSize - needed; - mover.fill(leftover, str, 8 - fillSize, 1); - System.arraycopy(leftover, 8 - fillSize, b, off, needed); - } - } - return total; - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/PngException.java b/javapng/src/main/com/sixlegs/image/png/PngException.java deleted file mode 100644 index f80dc15..0000000 --- a/javapng/src/main/com/sixlegs/image/png/PngException.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; - -class PngException -extends IOException -{ - PngException() - { - } - - PngException(String s) - { - super(s); - } - - public String toString() - { - return getMessage(); - } -} - diff --git a/javapng/src/main/com/sixlegs/image/png/PngExceptionSoft.java b/javapng/src/main/com/sixlegs/image/png/PngExceptionSoft.java deleted file mode 100644 index 63410d8..0000000 --- a/javapng/src/main/com/sixlegs/image/png/PngExceptionSoft.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -class PngExceptionSoft -extends PngException -{ - PngExceptionSoft() - { - } - - PngExceptionSoft(String s) - { - super(s); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/PngImage.java b/javapng/src/main/com/sixlegs/image/png/PngImage.java deleted file mode 100644 index 66d5163..0000000 --- a/javapng/src/main/com/sixlegs/image/png/PngImage.java +++ /dev/null @@ -1,1061 +0,0 @@ -/* -com.sixlegs.image.png - Java package to read and display PNG images -Copyright (C) 1998-2004 Chris Nokleberg - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the -Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -package com.sixlegs.image.png; - -import java.awt.Color; -import java.awt.image.ImageConsumer; -import java.awt.image.ImageProducer; -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -/** - * For more information visit http://www.sixlegs.com/ - * @see java.awt.image.ImageProducer - * @version 1.3.0 May 26, 2004 - * @author Chris Nokleberg <chris@sixlegs.com> - */ - -public final class PngImage -implements ImageProducer -{ - /* package */ static boolean allFatal = false; - /* package */ static final int BUFFER_SIZE = 8192; - private static boolean progressive = true; - private static Hashtable prototypes = new Hashtable(); - - /* package */ static final String ASCII_ENCODING = "US-ASCII"; - /* package */ static final String LATIN1_ENCODING = "8859_1"; - /* package */ static final String UTF8_ENCODING = "UTF8"; - /* package */ static final long DEFAULT_GAMMA = 45455; - private static double DISPLAY_EXPONENT = 2.2; - private static double USER_EXPONENT = 1.0; - - /* package */ Data data = new Data(); - private Vector errorList; - - final class Data { - Vector consumers = new Vector(); - Hashtable chunks = new Hashtable(); - - int[] pixels; - boolean produced; - boolean produceFailed; - boolean useFlush; - boolean close; - - /* package */ IDATInputStream in_idat; - /* package */ Chunk_IHDR header; - /* package */ Chunk_PLTE palette; - /* package */ int[] gammaTable = new int[256]; - /* package */ Hashtable textChunks = new Hashtable(); - /* package */ Hashtable properties = new Hashtable(); - /* package */ Hashtable palettes = new Hashtable(1); - /* package */ Vector gifExtensions = new Vector(); - - private Data() {} - } - - /////////////////// start public //////////////////////// - - public static final int COLOR_TYPE_GRAY = 0; - public static final int COLOR_TYPE_GRAY_ALPHA = 4; - public static final int COLOR_TYPE_PALETTE = 3; - public static final int COLOR_TYPE_RGB = 2; - public static final int COLOR_TYPE_RGB_ALPHA = 6; - - public static final int INTERLACE_TYPE_NONE = 0; - public static final int INTERLACE_TYPE_ADAM7 = 1; - - public static final int FILTER_TYPE_BASE = 0; - public static final int FILTER_TYPE_INTRAPIXEL = 64; - - public static final int COMPRESSION_TYPE_BASE = 0; - - public static final int UNIT_UNKNOWN = 0; - public static final int UNIT_METER = 1; - public static final int UNIT_PIXEL = 0; - public static final int UNIT_MICROMETER = 1; - public static final int UNIT_RADIAN = 2; - - public static final int SRGB_PERCEPTUAL = 0; - public static final int SRGB_RELATIVE_COLORIMETRIC = 1; - public static final int SRGB_SATURATION_PRESERVING = 2; - public static final int SRGB_ABSOLUTE_COLORIMETRIC = 3; - - /** - * Constructs a PngImage object from a local PNG file. - * @param filename full path to local PNG file - */ - public PngImage(String filename) - throws IOException - { - this(new BufferedInputStream(new FileInputStream(filename), BUFFER_SIZE)); - } - - /** - * Constructs a PngImage object from a URL. - * @param url URL of PNG image - */ - public PngImage(URL url) - throws IOException - { - this(new BufferedInputStream(url.openConnection().getInputStream(), BUFFER_SIZE)); - } - - /** - * Constructs a PngImage object from an input stream. - * Buffer the stream for better performance. The stream will be closed - * when the image has been fully read or is flushed. - * @param is InputStream containing PNG image data - * @see java.io.BufferedInputStream - */ - public PngImage(InputStream is) - { - this(is, true); - } - - /** - * Constructs a PngImage object from an input stream. - * Buffer the stream for better performance. - * @param is InputStream containing PNG image data - * @param close Whether to close the input stream when the image - * has been fully read or is flushed. When set to false you need - * to manage the closing of the stream yourself. This is useful, for example, when - * you have a file with multiple images concatenated together. - * @see java.io.BufferedInputStream - */ - public PngImage(InputStream is, boolean close) - { - data.close = close; - data.properties.put("gamma", new Long(DEFAULT_GAMMA)); - data.in_idat = new IDATInputStream(this, is, close); - } - - /** - * Adds an ImageConsumer to the list of consumers interested in - * data for this image. - * @see java.awt.image.ImageConsumer - */ - public void addConsumer(ImageConsumer ic) - { - if (data == null) return; - if (data.consumers.contains(ic)) return; - data.consumers.addElement(ic); - } - - /** - * Determine if an ImageConsumer is on the list of consumers currently - * interested in data for this image. - * @return true if the consumer is on the list, false otherwise. - * @see java.awt.image.ImageConsumer - */ - public boolean isConsumer(ImageConsumer ic) - { - if (data == null) return false; - return data.consumers.contains(ic); - } - - /** - * Remove an ImageConsumer from the list of consumers interested in - * data for this image. - * @see java.awt.image.ImageConsumer - */ - public void removeConsumer(ImageConsumer ic) - { - if (data == null) return; - data.consumers.removeElement(ic); - } - - /** - * Adds an ImageConsumer to the list of consumers interested in - * data for this image, and immediately start delivery of the - * image data through the consumer/producer interface. - * @see java.awt.image.ImageConsumer - */ - public void startProduction(ImageConsumer ic) - { - if (data == null) - throw new IllegalStateException("Object has been flushed."); - addConsumer(ic); - ImageConsumer[] ics = new ImageConsumer[data.consumers.size()]; - data.consumers.copyInto(ics); - produceHelper(ics); - } - - /** - * Requests delivery of image data to the specified ImageConsumer - * one more time in top-down, left-right order. - * @see #startProduction - * @see java.awt.image.ImageConsumer - */ - public void requestTopDownLeftRightResend(ImageConsumer ic) - { - if (data == null || data.pixels == null) return; - startProduction(ic); - } - - /** - * Sets the default desired final user exponent. Ideal setting - * depends on user viewing conditions. The default value is 1.0. - * Set greater than 1.0 to darken the mid-level tones, or less than - * 1.0 to lighten them. - *

- * This method sets the user exponent for new PngImage objects. - * It is not possible to change the user exponent of an existing - * PngImage. - * @param exponent desired user exponent - */ - static public void setUserExponent(double exponent) - { - USER_EXPONENT = exponent; - } - - /** - * Sets the default display exponent. Depends on monitor and gamma lookup - * table settings (if any). Default value is 2.2, which should - * work well with most PC displays. If the operating system has - * a gamma lookup table (Macintosh) the display exponent should be lower. - *

- * This method sets the display exponent for new PngImage objects. - * It is not possible to change the display exponent of an existing - * PngImage. - * @param exponent desired display exponent - */ - static public void setDisplayExponent(double exponent) - { - DISPLAY_EXPONENT = exponent; - } - - /** - * Checks if there were errors during image production. - * A good time to check this is when you implement the ImageObserver - * interface and the ERROR flag is set. - * @see java.awt.image.ImageObserver - * @see #getErrors - */ - public boolean hasErrors() - { - if (errorList == null) return false; - return errorList.size() > 0; - } - - public boolean hasFatalError() - { - return hasErrors() && - !(errorList.elementAt(errorList.size() - 1) instanceof PngExceptionSoft); - } - - /** - * Returns an Enumeration of all the errors that occurred during - * image production. This includes any non-fatal errors. - * @see #hasErrors - */ - public Enumeration getErrors() - { - - if (errorList == null) - return EmptyEnumeration.getInstance(); - return errorList.elements(); - } - - /** - * Specifies whether all errors will abort the image production. - * Normally, a value error in a non-critical chunk causes the - * PNG loader to simply skip the offending chunk. - */ - static public void setAllErrorsFatal(boolean allFatal) - { - PngImage.allFatal = allFatal; - } - - /** - * Interlaced images can either be displayed when completely - * read (default) or progressively. When progressive display is - * enabled, a PngImage will call the setPixels - * method of its registered image consumers after each pass. - *

- * Note: Images are only delivered progressively on the - * first production of the image data. Subsequent requests for the - * (cached) image data will send the image as a complete single - * frame. - * @see java.awt.image.ImageConsumer - * @see java.awt.image.ImageObserver - */ - static public void setProgressiveDisplay(boolean progressive) - { - PngImage.progressive = progressive; - } - - /** - * Get a suggested background color (from the bKGD chunk). - * @see #getProperty - * @return the suggested Color, or null if no valid bKGD was found. - */ - public Color getBackgroundColor() - throws IOException - { - return (Color)getProperty("background"); - } - - /** - * Gets width of image in pixels. - * @see #getProperty - */ - public int getWidth() - throws IOException - { - readToData(); - return data.header.width; - } - - /** - * Gets height of image in pixels. - * @see #getProperty - */ - public int getHeight() - throws IOException - { - readToData(); - return data.header.height; - } - - /** - * Gets bit depth of image data. - * @see #getProperty - * @return 1, 2, 4, 8, or 16. - */ - public int getBitDepth() - throws IOException - { - readToData(); - return data.header.depth; - } - - /** - * Gets the interlacing method used by this image. - * @see #getProperty - * @return one of the INTERLACE_TYPE_* constants. - */ - public int getInterlaceType() - throws IOException { - readToData(); - return data.header.interlace; - } - - /** - * Gets the alpha and color properties of an image. - * An image can either be grayscale, grayscale with alpha channel, - * RGB, RGB with alpha channel, or paletted. - * @see #getProperty - * @return COLOR_TYPE_GRAY
- * COLOR_TYPE_GRAY_ALPHA
- * COLOR_TYPE_PALETTE
- * COLOR_TYPE_RGB
- * COLOR_TYPE_RGB_ALPHA - */ - public int getColorType() - throws IOException - { - readToData(); - return data.header.colorType; - } - - /** - * Returns true if the image has an alpha channel. - * @see #getProperty - * @see #getColorType - */ - public boolean hasAlphaChannel() - throws IOException - { - readToData(); - return data.header.alphaUsed; - } - - /** - * Returns true if the image is grayscale. - * @see #getProperty - * @see #getColorType - */ - public boolean isGrayscale() - throws IOException - { - readToData(); - return !data.header.colorUsed; - } - - /** - * Returns true if the image is paletted. - * @see #getProperty - * @see #getColorType - */ - public boolean isIndexedColor() - throws IOException - { - readToData(); - return data.header.paletteUsed; - } - - /** - * Gets a property of this image by name. If a property is not - * defined for a particular image, this method returns null. - *

- * Note: This method will only read up to the beginning of - * the image data unless the image data has already been read, - * either through the consumer/producer interface or by calling - * {@link #getEverything}. - *

- * The following properties are guaranteed to be defined: - *

- *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
NameTypeDescription
"width"IntegerImage width in pixels
"height"IntegerImage height in pixels
"interlace type"IntegerSee getInterlaceType
"compression type"IntegerCOMPRESSION_TYPE_BASE
"filter type"IntegerFILTER_TYPE_BASE
"color type"IntegerSee getColorType
"bit depth"Integer1, 2, 4, 8, or 16 (1)
"gamma"LongFile gamma * 100000 (2)
"significant bits"byte[]Significant bits per component:
[r,g,b] or [r,g,b,alpha] (3)
- *
- * - *
1 16-bit pixel components are reduced to 8 bits
- * 2 Uses value from sRGB or gAMA chunks, - * or default (45455)
- * 3 For grayscale images, r == g == b
- - *

- * The following properties are optional:

- *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - - * - * - * - * - * - * - - *
NameTypeDescription
"palette"int[][]Palette or suggested palette (PLTE chunk):
- * [r,g,b][entry] or [r,g,b][entry]
"palette size"IntegerSize of palette, 1 - 256
"histogram"int[]Palette entry usage frequency
"background"java.awt.ColorSuggested background color
"background low bytes"java.awt.ColorThe low (least significant) bytes of a 16-bit background color
"background index"IntegerThe palette index of the suggested background color
"time"java.util.DateTime of last image modification
"pixel dimensions x"LongPixels per unit, X axis
"pixel dimensions y"LongPixels per unit, Y axis
"pixel dimensions unit"IntegerUNIT_UNKNOWN or UNIT_METER
"image position x"IntegerHorizontal offset from left of page
"image position y"IntegerVertical offset from top of page
"image position unit"IntegerUNIT_PIXEL or UNIT_MICROMETER
"pixel scale x"DoublePixel width, physical scale of subject
"pixel scale y"DoublePixel height, physical scale of subject
"pixel scale unit"IntegerUNIT_METER or UNIT_RADIAN
"chromaticity xy"long[][]CIE x,y chromaticities * 100000: [white,r,g,b][x,y]
"chromaticity xyz"double[][]CIE XYZ chromaticities: [white,r,g,b][X,Y,Z]
"srgb rendering intent"Integer - * SRGB_PERCEPTUAL or
- * SRGB_RELATIVE_COLORIMETRIC or
- * SRGB_SATURATION_PRESERVING or
- * SRGB_ABSOLUTE_COLORIMETRIC
"icc profile name"StringInternal ICC profile name
"icc profile"StringUncompressed ICC profile
"pixel calibration purpose"String Equation identifier
"pixel calibration x0"Integer Lower limit of original sample range
"pixel calibration x1"Integer Upper limit of original sample range
"pixel calibration type"Integer - * 0: Linear mapping
- * 1: Base-e exponential mapping
- * 2: Arbitrary-base exponential mapping
- * 3: Hyperbolic mapping - *
"pixel calibration n"Integer Number of parameters
"pixel calibration unit"String Symbol or description of unit
"pixel calibration parameters"double[]  
"gif disposal method"IntegerSee GIF89a Graphic Control Extension specification
"gif user input flag"IntegerSee GIF89a Graphic Control Extension specification
"gif delay time"IntegerSee GIF89a Graphic Control Extension specification
"transparency"java.awt.ColorTransparent color (4)
"transparency low bytes"java.awt.ColorThe low (least significant) bytes of a 16-bit transparency color (4)
"transparency size"IntegerThe number of palette entries with transparency information (5)
- *
- * - *
4 Grayscale or truecolor images only
- * 5 Indexed-color images only
- - *

- * In addition, certain common (but still optional) text chunks - * are available through the getProperty interface:

- *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
NameTypeDescription
"title"TextChunkShort (one line) title or caption for image
"author"TextChunkName of image's creator
"description"TextChunkDescription of image (possibly long)
"copyright"TextChunkCopyright notice
"creation time"TextChunkTime of original image creation
"software"TextChunkSoftware used to create the image
"disclaimer"TextChunkLegal disclaimer
"warning"TextChunkWarning of nature of content
"source"TextChunkDevice used to create the image
"comment"TextChunkMiscellaneous comment
- - * @see #getWidth - * @see #getHeight - * @see #getInterlaceType - * @see #getColorType - * @see #getTextChunk - * @see #getBackgroundColor - * @param name a property name - * @return the value of the named property. - */ - public Object getProperty(String name) - throws IOException - { - readToData(); - return data.properties.get(name); - } - - /** - * Returns an Enumeration of the available properties. - * @see #getProperty - */ - public Enumeration getProperties() - throws IOException - { - readToData(); - return data.properties.keys(); - } - - /** - * Ensures that the entire PNG file has been read. No exceptions - * are thrown; errors are available by calling {@link #getErrors}. - *

- * Note: The consumer/producer interface automatically - * reads the entire PNG file. It usually is not necessary to call - * {@link #getEverything} unless you do not need the actual - * image data. - */ - public void getEverything() - { - startProduction(new DummyImageConsumer()); - } - - /** - * Alternative to {@link #getEverything()} which can throw - * a fatal error if one was detected during the decoding process. - * @param throwFatalError if true, any fatal error will be thrown after - * attempting to decode the image - */ - public void getEverything(boolean throwFatalError) - throws IOException - { - startProduction(new DummyImageConsumer()); - if (hasFatalError()) - throw (IOException)errorList.elementAt(errorList.size() - 1); - } - - /** - * Check if the specified chunk type appears at least once in this image. - *

- * Note: This method will only reflect chunks seen up to the - * beginning of the image data unless the image data has already - * been read, either through the consumer/producer interface or by - * calling {@link #getEverything}. - * @param type the PNG chunk name, for example "tRNS". - */ - public boolean hasChunk(String type) - throws IOException - { - readToData(); - return data.chunks.get(new Integer(Chunk.stringToType(type))) != null; - } - - /** - * Register a {@link ChunkHandler} to handle a user defined - * chunk type. - *

- * The chunk type must be four characters, ancillary (lowercase first letter), - * and may not already be registered. You may register one of the supported - * ancillary chunk types (except tRNS) to override the standard behavior. - * @param handler object to send chunk data to - * @param type chunk type - */ - public static void registerChunk(ChunkHandler handler, String type) - throws PngException - { - if (type.length() < 4) { - throw new PngException("Invalid chunk type length."); - } - - int type_int = Chunk.stringToType(type); - - if (prototypes.containsKey(new Integer(type_int))) { - throw new PngException("Chunk type already registered."); - } - if ((type_int & 0x20000000) == 0) { - throw new PngException("Chunk must be ancillary."); - } - - registerChunk(new UserChunk(handler, type_int)); - } - - /** - * Returns an Enumeration of the available suggested palette names. - * @see #getSuggestedPalette - */ - public Enumeration getSuggestedPalettes() - throws IOException - { - readToData(); - return data.palettes.keys(); - } - - /** - * Returns the suggested palette (sPLT chunk) specified by the - * palette name. - * @see #getSuggestedPalette - * @param name the name of the suggested palette - * @return [r,g,b,alpha,freq][entry], or null if not present. - */ - public int[][] getSuggestedPalette(String name) - throws IOException - { - readToData(); - return (int[][])data.palettes.get(name); - } - - /** - * Returns the specified text chunk. - *

- * Note: Text chunks may appear anywhere in the file. This - * method will only read up to the beginning of the image data - * unless the image data has already been read, either through the - * consumer/producer interface or by calling - * {@link #getEverything}. - * @see #getTextChunks - * @see #getProperty - * @param key the key of the desired chunk - * @return the text chunk, or null if not present. - */ - public TextChunk getTextChunk(String key) - throws IOException - { - readToData(); - return (TextChunk)data.textChunks.get(key); - } - - /** - * Returns the keys of all known text chunks. - *

- * Note: Text chunks may appear anywhere in the file. This - * method will only read up to the beginning of the image data - * unless the image data has already been read, either through the - * consumer/producer interface or by calling - * {@link #getEverything}. - * @see #getTextChunk - * @return an Enumeration of the keys of text chunks read so far. - */ - public Enumeration getTextChunks() - throws IOException - { - readToData(); - return data.textChunks.elements(); - } - - /** - * Returns all known GIF Application Extensions. - *

- * Note: GIF Application Extensions may appear anywhere in - * the file. This method will only read up to the beginning of the - * image data unless the image data has already been read, either - * through the consumer/producer interface or by calling - * {@link #getEverything}. - * @return an Enumeration of all GifExtension objects read so far. - * @see GifExtension - */ - public Enumeration getGifExtensions() - throws IOException - { - readToData(); - return data.gifExtensions.elements(); - } - - /** - * Readies this PngImage to be flushed after the next image - * production, to free memory. - *

- * After flushing, you may only call the {@link #getErrors} - * and {@link #hasErrors} methods on this object. The pixel - * data will no longer be available through the consumer/producer - * interface. - *

- * Note: Using a PixelGrabber object on an Image produced - * by this PngImage object will ask for a second production of the - * pixel data, which will fail if the object has been flushed. - * @param useFlush whether to flush after the next production; default is false - */ - public void setFlushAfterNextProduction(boolean useFlush) - { - data.useFlush = useFlush; - } - - /** - * Set the internal pixel buffer to use when decoding the image. - * A buffer of size (width * height) is normally automatically allocated - * if either the image is progressive or {@link #setFlushAfterNextProduction} has - * not been set. For performance or memory use issues you may supply your - * own buffer with this method. The pixels are stored in 0xAARRGGBB - * format. - * @param pixels the pixel buffer to use; size must be at least (width * height) - * @throws IllegalArgumentException if the pixel buffer is too short - * @throws IllegalStateException if this PngImage has been flushed. - */ - public void setBuffer(int[] pixels) - throws IOException - { - if (data == null) - throw new IllegalStateException("Object has been flushed."); - int size = getWidth() * getHeight(); - if (pixels.length < size) - throw new IllegalArgumentException("Buffer size must be at least " + size + " (W * H)"); - data.pixels = pixels; - } - - /////////////////// end public //////////////////////// - - private void flush() - { - if (data != null) { - try { - if (data.close) - data.in_idat.close(); - } catch (IOException e) { - // TODO: ignore? - } - data = null; - } - } - - static { - registerChunk(new Chunk_IHDR()); - registerChunk(new Chunk_PLTE()); - registerChunk(new Chunk_IDAT()); - registerChunk(new Chunk_IEND()); - registerChunk(new Chunk_tRNS()); - } - - private synchronized void readToData() - throws IOException - { - try { - if (data == null) { - throw new EOFException("Object has been flushed."); - } - data.in_idat.readToData(); - } catch (PngException e) { - addError(e); - throw e; - } - } - - private static void registerChunk(Chunk proto) - { - prototypes.put(new Integer(proto.type), proto); - } - - /* package */ static Chunk getRegisteredChunk(int type) - { - Integer type_obj = new Integer(type); - if (prototypes.containsKey(type_obj)) { - return ((Chunk)prototypes.get(type_obj)).copy(); - } else { - try { - String clsName = - "com.sixlegs.image.png.Chunk_" + Chunk.typeToString(type); - registerChunk((Chunk)Class.forName(clsName).newInstance()); - return getRegisteredChunk(type); - } catch (Exception e) { - return new Chunk(type); - } - } - } - - /* package */ Chunk getChunk(int type) - { - return (Chunk)data.chunks.get(new Integer(type)); - } - - /* package */ void putChunk(int type, Chunk c) - { - data.chunks.put(new Integer(type), c); - } - - /* package */ void addError(IOException e) - { - if (errorList == null) { - errorList = new Vector(); - } - errorList.addElement(e); - } - - /* package */ void fillGammaTable() - { - try { - long file_gamma = ((Long)getProperty("gamma")).longValue(); - int max = (data.header.paletteUsed ? 0xFF : (1 << data.header.outputDepth) - 1); - double decoding_exponent = - (USER_EXPONENT * 100000d / (file_gamma * DISPLAY_EXPONENT)); - for (int i = 0; i <= max; i++) { - int v = (int)(Math.pow((double)i / max, decoding_exponent) * 0xFF); - if (!data.header.colorUsed) { - data.gammaTable[i] = v | v << 8 | v << 16; - } else { - data.gammaTable[i] = v; - } - } - if (data.palette != null) data.palette.calculate(); - } catch (IOException e) { } - } - - private synchronized void produceHelper(ImageConsumer[] ics) - { - try { - readToData(); - for (int i = 0; i < ics.length; i++) { - ics[i].setDimensions(data.header.width, data.header.height); - ics[i].setProperties(data.properties); - ics[i].setColorModel(data.header.model); - if (data.produceFailed) ics[i].imageComplete(ImageConsumer.IMAGEERROR); - } - if (data.produceFailed) return; - if (!data.produced) { - firstProduction(ics); - } else { - setHints(ics); - for (int i = 0; i < ics.length; i++) { - ics[i].setPixels(0, - 0, - data.header.width, - data.header.height, - data.header.model, - data.pixels, - 0, - data.header.width); - ics[i].imageComplete(ImageConsumer.STATICIMAGEDONE); - } - } - } catch (IOException e) { - data.produceFailed = true; - addError(e); - for (int i = 0; i < ics.length; i++) { - ics[i].imageComplete(ImageConsumer.IMAGEERROR); - } - } - if (data.useFlush) flush(); - } - - private void firstProduction(ImageConsumer[] ics) - throws IOException - { - data.produced = true; - UnfilterInputStream in_filter - = new UnfilterInputStream(this, data.in_idat); - InputStream is = - new BufferedInputStream(in_filter, BUFFER_SIZE); - PixelReader pis = - new PixelReader(this, is); - - setHints(ics); - - if (data.header.interlace == INTERLACE_TYPE_NONE) { - // this is just for optimization - // omitting it will cause NullInterlacer to be used - produceNonInterlaced(ics, pis); - } else { - produceInterlaced(ics, pis); - } - - for (int i = 0; i < ics.length; i++) { - ics[i].imageComplete(ImageConsumer.STATICIMAGEDONE); - } - } - - private void setHints(ImageConsumer[] ics) - { - for (int i = 0; i < ics.length; i++) { - if (progressive && - data.pixels == null && - (data.header.interlace != INTERLACE_TYPE_NONE)) { - ics[i].setHints(ImageConsumer.RANDOMPIXELORDER); - } else { - ics[i].setHints(ImageConsumer.TOPDOWNLEFTRIGHT | - ImageConsumer.SINGLEPASS | - ImageConsumer.SINGLEFRAME | - ImageConsumer.COMPLETESCANLINES); - } - } - } - - private void produceNonInterlaced(ImageConsumer[] ics, PixelReader pis) - throws IOException - { - int w = data.header.width, h = data.header.height; - - // if we're going to flush, don't bother saving pixel data - if (!data.useFlush && data.pixels == null) - data.pixels = new int[w * h]; - - int[] rowbuf = new int[w + 8]; - int pixelsWidth = w; - int extra = w % pis.fillSize; - if (extra > 0) pixelsWidth += (pis.fillSize - extra); - for (int y = 0; y < h; y++) { - pis.read(rowbuf, 0, pixelsWidth); - if (data.pixels != null) { - System.arraycopy(rowbuf, 0, data.pixels, w * y, w); - } - for (int i = 0; i < ics.length; i++) { - ics[i].setPixels(0, y, w, 1, data.header.model, rowbuf, 0, pixelsWidth); - } - } - } - - private void produceInterlaced(ImageConsumer[] ics, PixelReader pis) - throws IOException - { - int w = data.header.width, h = data.header.height; - if (data.pixels == null) - data.pixels = new int[w * h]; - int[] rowbuf = new int[w + 8]; - - int numPasses = data.header.interlacer.numPasses(); - Interlacer lace = data.header.interlacer; - - for (int pass = 0; pass < numPasses; pass++) { - int passWidth = lace.getPassWidth(pass); - int extra = passWidth % pis.fillSize; - if (extra > 0) passWidth += (pis.fillSize - extra); - - int blockWidth = (progressive ? lace.getBlockWidth(pass) : 1); - int blockHeight = (progressive ? lace.getBlockHeight(pass) : 1); - int rowIncrement = lace.getSpacingY(pass); - int colIncrement = lace.getSpacingX(pass); - int offIncrement = rowIncrement * w; - int colStart = lace.getOffsetX(pass); - int row = lace.getOffsetY(pass); - int off = row * w; - - while (row < h) { - pis.read(rowbuf, 0, passWidth); - int col = colStart; - int x = 0; - while (col < w) { - int bw = Math.min(blockWidth, w - col); - int bh = Math.min(blockHeight, h - row); - int poff = off + col; - int pix = rowbuf[x++]; - while (bh-- > 0) { - int poffend = poff + bw; - while (poff < poffend) { - data.pixels[poff++] = pix; - } - poff += w - bw; - } - col += colIncrement; - } - off += offIncrement; - row += rowIncrement; - } - if (progressive) { - for (int i = 0; i < ics.length; i++) { - ics[i].setPixels(0, 0, w, h, data.header.model, data.pixels, 0, w); - } - } - } - if (!progressive) { - for (int i = 0; i < ics.length; i++) { - ics[i].setPixels(0, 0, w, h, data.header.model, data.pixels, 0, w); - } - } - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/TextChunk.java b/javapng/src/main/com/sixlegs/image/png/TextChunk.java deleted file mode 100644 index 333a04b..0000000 --- a/javapng/src/main/com/sixlegs/image/png/TextChunk.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -/** - * Common interface to all PNG text chunks (tEXt, zTXt, iTXt). - * @see PngImage#getTextChunk - * @see PngImage#getProperty - */ -public interface TextChunk -{ - /** - * Returns the Latin-1 [ISO-8859-1] encoded keyword - * of this TextChunk. - */ - String getKeyword(); - - /** - * Returns a translation of the keyword into the language - * used by this TextChunk, or null if unspecified. - */ - String getTranslatedKeyword(); - - /** - * Returns the language [RFC-1766] used by the translated - * keyword and the text, or null if unspecified. - */ - String getLanguage(); - - /** - * Returns the text of this TextChunk. - */ - String getText(); - - /** - * Returns the original chunk type of this TextChunk: "tEXt", - * "zTXt", or "iTXt". - */ - String getChunkType(); -} diff --git a/javapng/src/main/com/sixlegs/image/png/UnfilterInputStream.java b/javapng/src/main/com/sixlegs/image/png/UnfilterInputStream.java deleted file mode 100644 index f3f1494..0000000 --- a/javapng/src/main/com/sixlegs/image/png/UnfilterInputStream.java +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.Inflater; -import java.util.zip.InflaterInputStream; - -final class UnfilterInputStream -extends InputStream -{ - final private Chunk_IHDR header; - final private int rowSize; - final private int bpp; - - final private InflaterInputStream infstr; - final private byte[] prev; - final private byte[] cur; - - private int nextPass; - private int rowsLeftInPass; - private int bytesPerRow; - private int pullSize; - private int xc, xp, xPtr; - - UnfilterInputStream(PngImage img, InputStream s) - { - header = img.data.header; - infstr = new InflaterInputStream(s, new Inflater(), PngImage.BUFFER_SIZE); - bpp = Math.max(1, header.depth * header.samples / 8); - int maxPassWidth = header.interlacer.getMaxPassWidth(); - int maxBytesPerRow = getByteWidth(maxPassWidth); - rowSize = maxBytesPerRow + bpp; - prev = new byte[rowSize]; - cur = new byte[rowSize]; - for (int i = 0; i < rowSize; i++) cur[i] = 0; - } - - private int getByteWidth(int pixels) - { - if (header.samples == 1) { - int dppb = 16 / header.depth; // == 2 * pixels-per-byte - int w2 = pixels * 2; - return (w2 % dppb == 0 ? w2 / dppb : (w2 + dppb - (w2 % dppb)) / dppb); - } else { - return pixels * header.samples * header.depth / 8; - } - } - - private int readRow () - throws IOException - { - if (rowsLeftInPass == 0) { - while (rowsLeftInPass == 0 || bytesPerRow == 0) { - if (nextPass >= header.interlacer.numPasses()) return -1; - rowsLeftInPass = header.interlacer.getPassHeight(nextPass); - bytesPerRow = getByteWidth(header.interlacer.getPassWidth(nextPass)); - nextPass++; - } - pullSize = bytesPerRow + bpp; - for (int i = 0; i < pullSize; i++) prev[i] = 0; - } - rowsLeftInPass--; - - int filterType = infstr.read(); - if (filterType == -1) - return -1; - if (filterType > 4 || filterType < 0) - throw new PngException("Bad filter type: " + filterType); - int needed = bytesPerRow; - while (needed > 0) { - int r = infstr.read(cur, bytesPerRow - needed + bpp, needed); - if (r == -1) return -1; - needed -= r; - } - - // TODO: add support for FILTER_TYPE_INTRAPIXEL - - switch (filterType) { - case 0: // None - break; - case 1: // Sub - for (xc = bpp, xp = 0; xc < rowSize; xc++, xp++) { - cur[xc] = (byte)(cur[xc] + cur[xp]); - } - break; - case 2: // Up - for (xc = bpp, xp = 0; xc < rowSize; xc++, xp++) { - cur[xc] = (byte)(cur[xc] + prev[xc]); - } - break; - case 3: // Average - for (xc = bpp, xp = 0; xc < rowSize; xc++, xp++) { - cur[xc] = (byte)(cur[xc] + ((0xFF & cur[xp]) + (0xFF & prev[xc])) / 2); - } - break; - case 4: // Paeth - for (xc = bpp, xp = 0; xc < rowSize; xc++, xp++) { - cur[xc] = (byte)(cur[xc] + Paeth(cur[xp], prev[xc], prev[xp])); - } - break; - default: - throw new PngException("unrecognized filter type " + filterType); - } - - System.arraycopy(cur, 0, prev, 0, rowSize); - return 0; - } - - private int Paeth(byte L, byte u, byte nw) - { - int a = 0xFF & L; // inline byte->int - int b = 0xFF & u; - int c = 0xFF & nw; - int p = a + b - c; - int pa = p - a; if (pa < 0) pa = -pa; // inline Math.abs - int pb = p - b; if (pb < 0) pb = -pb; - int pc = p - c; if (pc < 0) pc = -pc; - if (pa <= pb && pa <= pc) return a; - if (pb <= pc) return b; - return c; - } - - private byte[] _b = new byte[1]; - - public int read() - throws IOException - { - return read(_b, 0, 1) > 0 ? _b[0] & 0xff : -1; - } - - public int read(byte[] b, int off, int len) - throws IOException - { - int count = 0; - while (len > 0) { - if (xPtr == 0) { - if (readRow() == -1) return ( count == 0 ? -1 : count ); - xPtr = bpp; - } - int L = Math.min(len, pullSize - xPtr); - System.arraycopy(cur, xPtr, b, off, L); - count += L; - xPtr = (xPtr + L) % pullSize; - off += L; - len -= L; - } - return count; - } - - public void close() - throws IOException - { - infstr.close(); - } -} diff --git a/javapng/src/main/com/sixlegs/image/png/UserChunk.java b/javapng/src/main/com/sixlegs/image/png/UserChunk.java deleted file mode 100644 index 8400c38..0000000 --- a/javapng/src/main/com/sixlegs/image/png/UserChunk.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 1998-2004 Chris Nokleberg -// Please see included LICENSE.TXT - -package com.sixlegs.image.png; - -import java.io.IOException; - -final class UserChunk -extends Chunk -{ - private ChunkHandler handler; - - UserChunk(ChunkHandler h, int type) - { - super(type); - handler = h; - } - - protected void readData() - throws IOException - { - byte[] bytes = new byte[length]; - in_data.read(bytes, 0, length); - handler.handleChunk(typeToString(type), bytes); - } -} diff --git a/javapng/src/test/com/sixlegs/image/png/DataTest.java b/javapng/src/test/com/sixlegs/image/png/DataTest.java deleted file mode 100644 index 4603ed4..0000000 --- a/javapng/src/test/com/sixlegs/image/png/DataTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.sixlegs.image.png; - -import java.io.*; -import java.security.MessageDigest; -import junit.framework.*; -import java.awt.image.ColorModel; - -public class DataTest -extends TestCase -{ - public void testImages() - throws Exception - { - int[] buffer = new int[800 * 600]; // big enough to handle biggest image - final MessageDigest md5 = MessageDigest.getInstance("MD5"); - BufferedReader r = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/images.txt"))); - String line; - boolean fail = false; - while ((line = r.readLine()) != null) { - int space = line.indexOf(' '); - String image = line.substring(0, space).trim(); - String result = line.substring(space + 1).trim(); - try { - InputStream in = getClass().getResourceAsStream(image); - if (in == null) - fail("Cannot find image \"" + image + "\""); - PngImage png = new PngImage(in); - png.setBuffer(buffer); - png.getEverything(true); - byte[] pixbuf = new byte[4]; - for (int i = 0, size = png.getWidth() * png.getHeight(); i < size; i++) { - int pixel = buffer[i]; - pixbuf[3] = (byte)(0xFF & pixel); - pixbuf[2] = (byte)(0xFF & (pixel >>> 8)); - pixbuf[1] = (byte)(0xFF & (pixel >>> 16)); - pixbuf[0] = (byte)(0xFF & (pixel >>> 24)); - md5.update(pixbuf); - } - String hash = toHexString(md5.digest()); - if (!result.equals(hash)) { - System.err.println("Expected digest 0x" + result + " for image " + image + ", got 0x" + hash); - fail = true; - } - } catch (Exception e) { - if (!result.equals(e.getMessage())) { - System.err.println("Caught exception while processing image " + image + ":"); - e.printStackTrace(System.err); - fail = true; - } - } - } - if (fail) - fail("Failures detected."); - } - - private static String toHexString(byte[] b) - { - StringBuffer hex = new StringBuffer(2 * b.length); - for (int i = 0; i < b.length; i++) { - byte n = b[i]; - if (n >= 0 && n <= 15) - hex.append("0"); - hex.append(Integer.toHexString(0xFF & n)); - } - return hex.toString().toUpperCase(); - } - - public DataTest(String name) - { - super(name); - } - - public static Test suite() - { - return new TestSuite(DataTest.class); - } - - public static void main(String args[]) - { - junit.textui.TestRunner.run(suite()); - } -} diff --git a/javapng/src/test/com/sixlegs/image/png/ImageConsumerAdapter.java b/javapng/src/test/com/sixlegs/image/png/ImageConsumerAdapter.java deleted file mode 100644 index a0a27ac..0000000 --- a/javapng/src/test/com/sixlegs/image/png/ImageConsumerAdapter.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.sixlegs.image.png; - -import java.awt.image.*; -import java.util.Hashtable; - -abstract class ImageConsumerAdapter -implements ImageConsumer -{ - protected ImageConsumerAdapter() - { - } - - public void imageComplete(int status) - { - } - - public void setColorModel(ColorModel model) - { - } - - public void setDimensions(int width, int height) - { - } - - public void setHints(int hintflags) - { - } - - public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize) - { - } - - public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize) - { - } - - public void setProperties(Hashtable props) - { - } -} diff --git a/javapng/src/test/com/sixlegs/image/png/IoTest.java b/javapng/src/test/com/sixlegs/image/png/IoTest.java deleted file mode 100644 index 89d2cd9..0000000 --- a/javapng/src/test/com/sixlegs/image/png/IoTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.sixlegs.image.png; - -import java.io.*; -import junit.framework.*; - -public class IoTest -extends TestCase -{ - public void testConcatenatedImages() - throws Exception - { - InputStream in = getClass().getResourceAsStream("/images/misc/concat.dat"); - PngImage p1 = new PngImage(in, false); - p1.getEverything(); - PngImage p2 = new PngImage(in, false); - p2.getEverything(); - assertEquals(32, p1.getWidth()); - assertEquals(32, p2.getWidth()); - } - - public IoTest(String name) - { - super(name); - } - - public static Test suite() - { - return new TestSuite(IoTest.class); - } - - public static void main(String args[]) - { - junit.textui.TestRunner.run(suite()); - } -} diff --git a/javapng/src/test/images.txt b/javapng/src/test/images.txt deleted file mode 100644 index 9595c94..0000000 --- a/javapng/src/test/images.txt +++ /dev/null @@ -1,163 +0,0 @@ -/images/misc/AlphaSnakes8.png 85425BB6F0742F4058C0BA199D13C6B4 -/images/misc/cc1.png 8D25B4666CA708008944CE2BD4342561 -/images/misc/goldhill.png FCEDA12F78ED26361F38291E5682FF27 -/images/misc/manhat.png 956F61BC8D7F390F99A53FCFF23A203A -/images/misc/pass-1.png 171B7ACB142DC06414E1E73B1F9433A0 -/images/misc/penguin.png 6633AE00240FDC9E75557CA35C1FBA00 -/images/misc/u_horn.111.png F40352E49BC8DAA97216D0A02F0BEA61 -/images/suite/basi0g01.png 52DCC1EDC03AD14490A995A355BC651A -/images/suite/basi0g02.png 3E4C0C61B91BC77665542AAAA4464690 -/images/suite/basi0g04.png 2469F38C91B70CC1D678255F89B4E26A -/images/suite/basi0g08.png DCF7668CFC3FED4546A54B9C4540B721 -/images/suite/basi0g16.png D20521757AD045AC8D58449968E5C22B -/images/suite/basi2c08.png 1F4493FB45D9E2DD387D20347D17A080 -/images/suite/basi2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/basi3p01.png A6B8F65E43A2E870BFCA245B6ED6DBAE -/images/suite/basi3p02.png AC30DACF7E761B4371E7E6EEE54F53B1 -/images/suite/basi3p04.png 9D6CA1678AACDCC0817D96D99A8A5C50 -/images/suite/basi3p08.png 5599C92EEAA21FEB529583179FA3A6CE -/images/suite/basi4a08.png 733B3CE3CC6042BF530F16A15A57A5CD -/images/suite/basi4a16.png 4D8C1DE8B338AE0F6232A68054157698 -/images/suite/basi6a08.png 8280F6DBDCF42C4C33D6EA57DF7709AE -/images/suite/basi6a16.png 8E287E7C8846D59CFB8C094440221F69 -/images/suite/basn0g01.png 52DCC1EDC03AD14490A995A355BC651A -/images/suite/basn0g02.png 3E4C0C61B91BC77665542AAAA4464690 -/images/suite/basn0g04.png 2469F38C91B70CC1D678255F89B4E26A -/images/suite/basn0g08.png DCF7668CFC3FED4546A54B9C4540B721 -/images/suite/basn0g16.png D20521757AD045AC8D58449968E5C22B -/images/suite/basn2c08.png 1F4493FB45D9E2DD387D20347D17A080 -/images/suite/basn2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/basn3p01.png A6B8F65E43A2E870BFCA245B6ED6DBAE -/images/suite/basn3p02.png AC30DACF7E761B4371E7E6EEE54F53B1 -/images/suite/basn3p04.png 9D6CA1678AACDCC0817D96D99A8A5C50 -/images/suite/basn3p08.png 5599C92EEAA21FEB529583179FA3A6CE -/images/suite/basn4a08.png 733B3CE3CC6042BF530F16A15A57A5CD -/images/suite/basn4a16.png 4D8C1DE8B338AE0F6232A68054157698 -/images/suite/basn6a08.png 8280F6DBDCF42C4C33D6EA57DF7709AE -/images/suite/basn6a16.png 8E287E7C8846D59CFB8C094440221F69 -/images/suite/bgai4a08.png 733B3CE3CC6042BF530F16A15A57A5CD -/images/suite/bgai4a16.png 4D8C1DE8B338AE0F6232A68054157698 -/images/suite/bgan6a08.png 8280F6DBDCF42C4C33D6EA57DF7709AE -/images/suite/bgan6a16.png 8E287E7C8846D59CFB8C094440221F69 -/images/suite/bgbn4a08.png 733B3CE3CC6042BF530F16A15A57A5CD -/images/suite/bggn4a16.png 4D8C1DE8B338AE0F6232A68054157698 -/images/suite/bgwn6a08.png 8280F6DBDCF42C4C33D6EA57DF7709AE -/images/suite/bgyn6a16.png 8E287E7C8846D59CFB8C094440221F69 -/images/suite/ccwn2c08.png F1B0DBD1A2C2B9DB64689670524B4BC2 -/images/suite/ccwn3p08.png 60FA33F0239E74186D4B04942321140F -/images/suite/cdfn2c08.png A5BF204014F9A935E5CE4355F92AD23A -/images/suite/cdhn2c08.png F9643B1C319C9DFF9BBDAE57359BD1E4 -/images/suite/cdsn2c08.png 3C03B1292F0270BA6BF390056FA9CEEA -/images/suite/cdun2c08.png 0EA9142114301109E7ABCB5DB8F9CBB1 -/images/suite/ch1n3p04.png 9D6CA1678AACDCC0817D96D99A8A5C50 -/images/suite/ch2n3p08.png 5599C92EEAA21FEB529583179FA3A6CE -/images/suite/cm0n0g04.png DDB600831172C2B51B784A7E27E40E39 -/images/suite/cm7n0g04.png DDB600831172C2B51B784A7E27E40E39 -/images/suite/cm9n0g04.png DDB600831172C2B51B784A7E27E40E39 -/images/suite/cs3n2c16.png 3D92A9722CDCBFE23D2FA81B67AA9287 -/images/suite/cs3n3p08.png 37CC2BCBCE2BA698FE3FA75C92A2969D -/images/suite/cs5n2c08.png 01FCE374F94F1909EC5876DE53F34303 -/images/suite/cs5n3p08.png 3DB1D6C7DEF347303C20E5518111D48E -/images/suite/cs8n2c08.png 3D92A9722CDCBFE23D2FA81B67AA9287 -/images/suite/cs8n3p08.png BCE251DCFB93815526377FCFB976B44D -/images/suite/ct0n0g04.png DDB600831172C2B51B784A7E27E40E39 -/images/suite/ct1n0g04.png DDB600831172C2B51B784A7E27E40E39 -/images/suite/ctzn0g04.png DDB600831172C2B51B784A7E27E40E39 -/images/suite/f00n0g08.png B5D50F2531ADF15D66521D891CB04929 -/images/suite/f00n2c08.png 346FA710E52871CB82DCC1E17305A9F5 -/images/suite/f01n0g08.png 951FD634381BE727836F05C261714F91 -/images/suite/f01n2c08.png 7452A9BD9890241C65FBA60677BC6916 -/images/suite/f02n0g08.png ED4AC585455A6F97870CEF9EF87BCA20 -/images/suite/f02n2c08.png B12E1D7488737605481D666D137D672B -/images/suite/f03n0g08.png 646F9A5A097D86B26539DAB6D0B07D35 -/images/suite/f03n2c08.png 7C1F11218C12BE0B89F69A2D7FCEA077 -/images/suite/f04n0g08.png 4AAEE0B4EE398F34B33641F0E877F3D4 -/images/suite/f04n2c08.png E466A5142AEB006A3129E0B5CFF40409 -/images/suite/g03n0g16.png F2D3251B28B0B579F708F98EC65798C6 -/images/suite/g03n2c08.png F2BB6E3684902B828C1813EE5124AC2C -/images/suite/g03n3p04.png 72E8E2CB98FE29E6A76031080B01BEBC -/images/suite/g04n0g16.png CFA765BF8C6883E897D64619AF9E99F5 -/images/suite/g04n2c08.png 67E150B1CAFCF29C576A4BAF83715F5D -/images/suite/g04n3p04.png 4382E05E9A3033B5E5F44DCFE68E020A -/images/suite/g05n0g16.png F792AD38A7FFC5DFF40F6606B6328E62 -/images/suite/g05n2c08.png 7719E5D8223E8E336E04A953F1643F52 -/images/suite/g05n3p04.png A52183AA92084DA937D9C35733875390 -/images/suite/g07n0g16.png 9ADCC17C5D2479B5A20BB3D161CAD2D3 -/images/suite/g07n2c08.png B09054E43668520F4FD11CA3251F716C -/images/suite/g07n3p04.png FFCA4FC0CC0656771FFF37239EDF9284 -/images/suite/g10n0g16.png 55E3030CF506D8EBDEB8E8EA2075DC78 -/images/suite/g10n2c08.png C5AD3E5293463E8FEB87B10DC74FCCBF -/images/suite/g10n3p04.png 4C8779FF6BEC68A0E91F6D6BB560C2CD -/images/suite/g25n0g16.png AFD78569ED90C3C656D3241F7BB8E070 -/images/suite/g25n2c08.png F34202C404945F7003F4902376E636B5 -/images/suite/g25n3p04.png FA80F1632245854028CB748F8AAC73FF -/images/suite/oi1n0g16.png D20521757AD045AC8D58449968E5C22B -/images/suite/oi1n2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/oi2n0g16.png D20521757AD045AC8D58449968E5C22B -/images/suite/oi2n2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/oi4n0g16.png D20521757AD045AC8D58449968E5C22B -/images/suite/oi4n2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/oi9n0g16.png D20521757AD045AC8D58449968E5C22B -/images/suite/oi9n2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/pp0n2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/pp0n6a08.png F9CAFD4127693894D693DCDBDCE90E1B -/images/suite/ps1n0g08.png DCF7668CFC3FED4546A54B9C4540B721 -/images/suite/ps1n2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/ps2n0g08.png DCF7668CFC3FED4546A54B9C4540B721 -/images/suite/ps2n2c16.png 216FE65E5E4803D62EC466E0001D104F -/images/suite/s01i3p01.png F1D3FF8443297732862DF21DC4E57262 -/images/suite/s02i3p01.png 4AE71336E44BF9BF79D2752E234818A5 -/images/suite/s03i3p01.png D631124FF1CEB67583CF56E9E246D0A4 -/images/suite/s04i3p01.png 672F2D8855C598D499D8E0C280F7248B -/images/suite/s05i3p02.png 26FAB810B90596AD2BEAD3AF0ADBE1C8 -/images/suite/s06i3p02.png 86B86FBC5305AA7521B13577992056A0 -/images/suite/s07i3p02.png D7FACD9B82E326FC741A58767D50E17E -/images/suite/s08i3p02.png C11CB19496ECA2A50C4566F23D2E9521 -/images/suite/s09i3p02.png D42CC9E99ADB29C613CDD1AF5F5D2575 -/images/suite/s32i3p04.png BB63D2BC7A63CA9D729CDBC51B59B7F7 -/images/suite/s33i3p04.png 5DDCBE70840DBCF35053AD06CA338C0F -/images/suite/s34i3p04.png 75E8DBD2816FA79841BB4BB2A8A282CF -/images/suite/s35i3p04.png 93D50C851C3CD407F3C26768B06CF544 -/images/suite/s36i3p04.png DA785BCD9F05E68CC15CB0F5DC88FC72 -/images/suite/s37i3p04.png 2A1D12DE22B3759A76F2A03BBB8E94B0 -/images/suite/s38i3p04.png 8ECFEDD78A0A6AE12653285D7DF899E6 -/images/suite/s39i3p04.png 19059958D76E733D7615445C46AC3F2C -/images/suite/s40i3p04.png 28498CDC0330269BB186429D2D55B093 -/images/suite/s01n3p01.png F1D3FF8443297732862DF21DC4E57262 -/images/suite/s02n3p01.png 4AE71336E44BF9BF79D2752E234818A5 -/images/suite/s03n3p01.png D631124FF1CEB67583CF56E9E246D0A4 -/images/suite/s04n3p01.png 672F2D8855C598D499D8E0C280F7248B -/images/suite/s05n3p02.png 26FAB810B90596AD2BEAD3AF0ADBE1C8 -/images/suite/s06n3p02.png 86B86FBC5305AA7521B13577992056A0 -/images/suite/s07n3p02.png D7FACD9B82E326FC741A58767D50E17E -/images/suite/s08n3p02.png C11CB19496ECA2A50C4566F23D2E9521 -/images/suite/s09n3p02.png D42CC9E99ADB29C613CDD1AF5F5D2575 -/images/suite/s32n3p04.png BB63D2BC7A63CA9D729CDBC51B59B7F7 -/images/suite/s33n3p04.png 5DDCBE70840DBCF35053AD06CA338C0F -/images/suite/s34n3p04.png 75E8DBD2816FA79841BB4BB2A8A282CF -/images/suite/s35n3p04.png 93D50C851C3CD407F3C26768B06CF544 -/images/suite/s36n3p04.png DA785BCD9F05E68CC15CB0F5DC88FC72 -/images/suite/s37n3p04.png 2A1D12DE22B3759A76F2A03BBB8E94B0 -/images/suite/s38n3p04.png 8ECFEDD78A0A6AE12653285D7DF899E6 -/images/suite/s39n3p04.png 19059958D76E733D7615445C46AC3F2C -/images/suite/s40n3p04.png 28498CDC0330269BB186429D2D55B093 -/images/suite/tbbn1g04.png 9DF780E29FEB501146838BFDF0FA07D8 -/images/suite/tbbn2c16.png E861ACBE0C8E5C94A00255E00069469A -/images/suite/tbbn3p08.png D569136E00AD6677C365E1CF343F7424 -/images/suite/tbgn2c16.png E861ACBE0C8E5C94A00255E00069469A -/images/suite/tbgn3p08.png D569136E00AD6677C365E1CF343F7424 -/images/suite/tbrn2c08.png E861ACBE0C8E5C94A00255E00069469A -/images/suite/tbwn1g16.png DAD5F585B62FE3FA0FBAA805C5CD7998 -/images/suite/tbwn3p08.png D569136E00AD6677C365E1CF343F7424 -/images/suite/tbyn3p08.png D569136E00AD6677C365E1CF343F7424 -/images/suite/tp0n1g08.png DAD5F585B62FE3FA0FBAA805C5CD7998 -/images/suite/tp0n2c08.png AFA1AA0F68806DFF6836D3D5A6F3F939 -/images/suite/tp0n3p08.png D50495CB12701A07E2FD2768514AD488 -/images/suite/tp1n3p08.png D569136E00AD6677C365E1CF343F7424 -/images/suite/x00n0g01.png Bad image size: 0x0 -/images/suite/xcrn0g04.png Improper signature -/images/suite/xlfn0g04.png Improper signature -/images/suite/z00n2c08.png 253CE9CAB7D15E0F334474E8E704BCCC -/images/suite/z03n2c08.png 253CE9CAB7D15E0F334474E8E704BCCC -/images/suite/z06n2c08.png 253CE9CAB7D15E0F334474E8E704BCCC -/images/suite/z09n2c08.png 253CE9CAB7D15E0F334474E8E704BCCC diff --git a/javapng/src/test/images/misc/AlphaSnakes8.png b/javapng/src/test/images/misc/AlphaSnakes8.png deleted file mode 100644 index b5109a4..0000000 Binary files a/javapng/src/test/images/misc/AlphaSnakes8.png and /dev/null differ diff --git a/javapng/src/test/images/misc/cc1.png b/javapng/src/test/images/misc/cc1.png deleted file mode 100644 index c0228dd..0000000 Binary files a/javapng/src/test/images/misc/cc1.png and /dev/null differ diff --git a/javapng/src/test/images/misc/concat.dat b/javapng/src/test/images/misc/concat.dat deleted file mode 100644 index da22042..0000000 Binary files a/javapng/src/test/images/misc/concat.dat and /dev/null differ diff --git a/javapng/src/test/images/misc/goldhill.png b/javapng/src/test/images/misc/goldhill.png deleted file mode 100644 index 624a4c9..0000000 Binary files a/javapng/src/test/images/misc/goldhill.png and /dev/null differ diff --git a/javapng/src/test/images/misc/manhat.png b/javapng/src/test/images/misc/manhat.png deleted file mode 100644 index 8214f6a..0000000 Binary files a/javapng/src/test/images/misc/manhat.png and /dev/null differ diff --git a/javapng/src/test/images/misc/pass-1.png b/javapng/src/test/images/misc/pass-1.png deleted file mode 100644 index 43aa1bb..0000000 Binary files a/javapng/src/test/images/misc/pass-1.png and /dev/null differ diff --git a/javapng/src/test/images/misc/penguin.png b/javapng/src/test/images/misc/penguin.png deleted file mode 100644 index 329e854..0000000 Binary files a/javapng/src/test/images/misc/penguin.png and /dev/null differ diff --git a/javapng/src/test/images/misc/u_horn.111.png b/javapng/src/test/images/misc/u_horn.111.png deleted file mode 100644 index 7dd899e..0000000 Binary files a/javapng/src/test/images/misc/u_horn.111.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi0g01.png b/javapng/src/test/images/suite/basi0g01.png deleted file mode 100644 index 556fa72..0000000 Binary files a/javapng/src/test/images/suite/basi0g01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi0g02.png b/javapng/src/test/images/suite/basi0g02.png deleted file mode 100644 index ce09821..0000000 Binary files a/javapng/src/test/images/suite/basi0g02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi0g04.png b/javapng/src/test/images/suite/basi0g04.png deleted file mode 100644 index 3853273..0000000 Binary files a/javapng/src/test/images/suite/basi0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi0g08.png b/javapng/src/test/images/suite/basi0g08.png deleted file mode 100644 index faed8be..0000000 Binary files a/javapng/src/test/images/suite/basi0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi0g16.png b/javapng/src/test/images/suite/basi0g16.png deleted file mode 100644 index a9f2816..0000000 Binary files a/javapng/src/test/images/suite/basi0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi2c08.png b/javapng/src/test/images/suite/basi2c08.png deleted file mode 100644 index 2aab44d..0000000 Binary files a/javapng/src/test/images/suite/basi2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi2c16.png b/javapng/src/test/images/suite/basi2c16.png deleted file mode 100644 index cd7e50f..0000000 Binary files a/javapng/src/test/images/suite/basi2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi3p01.png b/javapng/src/test/images/suite/basi3p01.png deleted file mode 100644 index 00a7cea..0000000 Binary files a/javapng/src/test/images/suite/basi3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi3p02.png b/javapng/src/test/images/suite/basi3p02.png deleted file mode 100644 index bb16b44..0000000 Binary files a/javapng/src/test/images/suite/basi3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi3p04.png b/javapng/src/test/images/suite/basi3p04.png deleted file mode 100644 index b4e888e..0000000 Binary files a/javapng/src/test/images/suite/basi3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi3p08.png b/javapng/src/test/images/suite/basi3p08.png deleted file mode 100644 index 50a6d1c..0000000 Binary files a/javapng/src/test/images/suite/basi3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi4a08.png b/javapng/src/test/images/suite/basi4a08.png deleted file mode 100644 index 398132b..0000000 Binary files a/javapng/src/test/images/suite/basi4a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi4a16.png b/javapng/src/test/images/suite/basi4a16.png deleted file mode 100644 index 51192e7..0000000 Binary files a/javapng/src/test/images/suite/basi4a16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi6a08.png b/javapng/src/test/images/suite/basi6a08.png deleted file mode 100644 index aecb32e..0000000 Binary files a/javapng/src/test/images/suite/basi6a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basi6a16.png b/javapng/src/test/images/suite/basi6a16.png deleted file mode 100644 index 4181533..0000000 Binary files a/javapng/src/test/images/suite/basi6a16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn0g01.png b/javapng/src/test/images/suite/basn0g01.png deleted file mode 100644 index 1d72242..0000000 Binary files a/javapng/src/test/images/suite/basn0g01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn0g02.png b/javapng/src/test/images/suite/basn0g02.png deleted file mode 100644 index 5083324..0000000 Binary files a/javapng/src/test/images/suite/basn0g02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn0g04.png b/javapng/src/test/images/suite/basn0g04.png deleted file mode 100644 index 0bf3687..0000000 Binary files a/javapng/src/test/images/suite/basn0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn0g08.png b/javapng/src/test/images/suite/basn0g08.png deleted file mode 100644 index 23c8237..0000000 Binary files a/javapng/src/test/images/suite/basn0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn0g16.png b/javapng/src/test/images/suite/basn0g16.png deleted file mode 100644 index e7c82f7..0000000 Binary files a/javapng/src/test/images/suite/basn0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn2c08.png b/javapng/src/test/images/suite/basn2c08.png deleted file mode 100644 index db5ad15..0000000 Binary files a/javapng/src/test/images/suite/basn2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn2c16.png b/javapng/src/test/images/suite/basn2c16.png deleted file mode 100644 index 50c1cb9..0000000 Binary files a/javapng/src/test/images/suite/basn2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn3p01.png b/javapng/src/test/images/suite/basn3p01.png deleted file mode 100644 index b145c2b..0000000 Binary files a/javapng/src/test/images/suite/basn3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn3p02.png b/javapng/src/test/images/suite/basn3p02.png deleted file mode 100644 index 8985b3d..0000000 Binary files a/javapng/src/test/images/suite/basn3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn3p04.png b/javapng/src/test/images/suite/basn3p04.png deleted file mode 100644 index 0fbf9e8..0000000 Binary files a/javapng/src/test/images/suite/basn3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn3p08.png b/javapng/src/test/images/suite/basn3p08.png deleted file mode 100644 index 0ddad07..0000000 Binary files a/javapng/src/test/images/suite/basn3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn4a08.png b/javapng/src/test/images/suite/basn4a08.png deleted file mode 100644 index 3e13052..0000000 Binary files a/javapng/src/test/images/suite/basn4a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn4a16.png b/javapng/src/test/images/suite/basn4a16.png deleted file mode 100644 index 8243644..0000000 Binary files a/javapng/src/test/images/suite/basn4a16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn6a08.png b/javapng/src/test/images/suite/basn6a08.png deleted file mode 100644 index e608738..0000000 Binary files a/javapng/src/test/images/suite/basn6a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/basn6a16.png b/javapng/src/test/images/suite/basn6a16.png deleted file mode 100644 index 984a995..0000000 Binary files a/javapng/src/test/images/suite/basn6a16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/bgai4a08.png b/javapng/src/test/images/suite/bgai4a08.png deleted file mode 100644 index 398132b..0000000 Binary files a/javapng/src/test/images/suite/bgai4a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/bgai4a16.png b/javapng/src/test/images/suite/bgai4a16.png deleted file mode 100644 index 51192e7..0000000 Binary files a/javapng/src/test/images/suite/bgai4a16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/bgan6a08.png b/javapng/src/test/images/suite/bgan6a08.png deleted file mode 100644 index e608738..0000000 Binary files a/javapng/src/test/images/suite/bgan6a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/bgan6a16.png b/javapng/src/test/images/suite/bgan6a16.png deleted file mode 100644 index 984a995..0000000 Binary files a/javapng/src/test/images/suite/bgan6a16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/bgbn4a08.png b/javapng/src/test/images/suite/bgbn4a08.png deleted file mode 100644 index 7cbefc3..0000000 Binary files a/javapng/src/test/images/suite/bgbn4a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/bggn4a16.png b/javapng/src/test/images/suite/bggn4a16.png deleted file mode 100644 index 13fd85b..0000000 Binary files a/javapng/src/test/images/suite/bggn4a16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/bgwn6a08.png b/javapng/src/test/images/suite/bgwn6a08.png deleted file mode 100644 index a67ff20..0000000 Binary files a/javapng/src/test/images/suite/bgwn6a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/bgyn6a16.png b/javapng/src/test/images/suite/bgyn6a16.png deleted file mode 100644 index ae3e9be..0000000 Binary files a/javapng/src/test/images/suite/bgyn6a16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ccwn2c08.png b/javapng/src/test/images/suite/ccwn2c08.png deleted file mode 100644 index 47c2481..0000000 Binary files a/javapng/src/test/images/suite/ccwn2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ccwn3p08.png b/javapng/src/test/images/suite/ccwn3p08.png deleted file mode 100644 index 8bb2c10..0000000 Binary files a/javapng/src/test/images/suite/ccwn3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cdfn2c08.png b/javapng/src/test/images/suite/cdfn2c08.png deleted file mode 100644 index 559e526..0000000 Binary files a/javapng/src/test/images/suite/cdfn2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cdhn2c08.png b/javapng/src/test/images/suite/cdhn2c08.png deleted file mode 100644 index 3e07e8e..0000000 Binary files a/javapng/src/test/images/suite/cdhn2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cdsn2c08.png b/javapng/src/test/images/suite/cdsn2c08.png deleted file mode 100644 index 076c32c..0000000 Binary files a/javapng/src/test/images/suite/cdsn2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cdun2c08.png b/javapng/src/test/images/suite/cdun2c08.png deleted file mode 100644 index 846033b..0000000 Binary files a/javapng/src/test/images/suite/cdun2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ch1n3p04.png b/javapng/src/test/images/suite/ch1n3p04.png deleted file mode 100644 index 17cd12d..0000000 Binary files a/javapng/src/test/images/suite/ch1n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ch2n3p08.png b/javapng/src/test/images/suite/ch2n3p08.png deleted file mode 100644 index 25c1798..0000000 Binary files a/javapng/src/test/images/suite/ch2n3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cm0n0g04.png b/javapng/src/test/images/suite/cm0n0g04.png deleted file mode 100644 index 9fba5db..0000000 Binary files a/javapng/src/test/images/suite/cm0n0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cm7n0g04.png b/javapng/src/test/images/suite/cm7n0g04.png deleted file mode 100644 index f7dc46e..0000000 Binary files a/javapng/src/test/images/suite/cm7n0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cm9n0g04.png b/javapng/src/test/images/suite/cm9n0g04.png deleted file mode 100644 index dd70911..0000000 Binary files a/javapng/src/test/images/suite/cm9n0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cs3n2c16.png b/javapng/src/test/images/suite/cs3n2c16.png deleted file mode 100644 index bf5fd20..0000000 Binary files a/javapng/src/test/images/suite/cs3n2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cs3n3p08.png b/javapng/src/test/images/suite/cs3n3p08.png deleted file mode 100644 index f4a6623..0000000 Binary files a/javapng/src/test/images/suite/cs3n3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cs5n2c08.png b/javapng/src/test/images/suite/cs5n2c08.png deleted file mode 100644 index 40f947c..0000000 Binary files a/javapng/src/test/images/suite/cs5n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cs5n3p08.png b/javapng/src/test/images/suite/cs5n3p08.png deleted file mode 100644 index dfd6e6e..0000000 Binary files a/javapng/src/test/images/suite/cs5n3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cs8n2c08.png b/javapng/src/test/images/suite/cs8n2c08.png deleted file mode 100644 index 8e01d32..0000000 Binary files a/javapng/src/test/images/suite/cs8n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/cs8n3p08.png b/javapng/src/test/images/suite/cs8n3p08.png deleted file mode 100644 index a44066e..0000000 Binary files a/javapng/src/test/images/suite/cs8n3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ct0n0g04.png b/javapng/src/test/images/suite/ct0n0g04.png deleted file mode 100644 index 40d1e06..0000000 Binary files a/javapng/src/test/images/suite/ct0n0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ct1n0g04.png b/javapng/src/test/images/suite/ct1n0g04.png deleted file mode 100644 index 3ba110a..0000000 Binary files a/javapng/src/test/images/suite/ct1n0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ctzn0g04.png b/javapng/src/test/images/suite/ctzn0g04.png deleted file mode 100644 index b4401c9..0000000 Binary files a/javapng/src/test/images/suite/ctzn0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f00n0g08.png b/javapng/src/test/images/suite/f00n0g08.png deleted file mode 100644 index 45a0075..0000000 Binary files a/javapng/src/test/images/suite/f00n0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f00n2c08.png b/javapng/src/test/images/suite/f00n2c08.png deleted file mode 100644 index d6a1fff..0000000 Binary files a/javapng/src/test/images/suite/f00n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f01n0g08.png b/javapng/src/test/images/suite/f01n0g08.png deleted file mode 100644 index 4a1107b..0000000 Binary files a/javapng/src/test/images/suite/f01n0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f01n2c08.png b/javapng/src/test/images/suite/f01n2c08.png deleted file mode 100644 index 26fee95..0000000 Binary files a/javapng/src/test/images/suite/f01n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f02n0g08.png b/javapng/src/test/images/suite/f02n0g08.png deleted file mode 100644 index bfe410c..0000000 Binary files a/javapng/src/test/images/suite/f02n0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f02n2c08.png b/javapng/src/test/images/suite/f02n2c08.png deleted file mode 100644 index e590f12..0000000 Binary files a/javapng/src/test/images/suite/f02n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f03n0g08.png b/javapng/src/test/images/suite/f03n0g08.png deleted file mode 100644 index ed01e29..0000000 Binary files a/javapng/src/test/images/suite/f03n0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f03n2c08.png b/javapng/src/test/images/suite/f03n2c08.png deleted file mode 100644 index 7581150..0000000 Binary files a/javapng/src/test/images/suite/f03n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f04n0g08.png b/javapng/src/test/images/suite/f04n0g08.png deleted file mode 100644 index 663fdae..0000000 Binary files a/javapng/src/test/images/suite/f04n0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/f04n2c08.png b/javapng/src/test/images/suite/f04n2c08.png deleted file mode 100644 index 3c8b511..0000000 Binary files a/javapng/src/test/images/suite/f04n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g03n0g16.png b/javapng/src/test/images/suite/g03n0g16.png deleted file mode 100644 index 41083ca..0000000 Binary files a/javapng/src/test/images/suite/g03n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g03n2c08.png b/javapng/src/test/images/suite/g03n2c08.png deleted file mode 100644 index a9354db..0000000 Binary files a/javapng/src/test/images/suite/g03n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g03n3p04.png b/javapng/src/test/images/suite/g03n3p04.png deleted file mode 100644 index 60396c9..0000000 Binary files a/javapng/src/test/images/suite/g03n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g04n0g16.png b/javapng/src/test/images/suite/g04n0g16.png deleted file mode 100644 index 32395b7..0000000 Binary files a/javapng/src/test/images/suite/g04n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g04n2c08.png b/javapng/src/test/images/suite/g04n2c08.png deleted file mode 100644 index a652b0c..0000000 Binary files a/javapng/src/test/images/suite/g04n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g04n3p04.png b/javapng/src/test/images/suite/g04n3p04.png deleted file mode 100644 index 5661cc3..0000000 Binary files a/javapng/src/test/images/suite/g04n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g05n0g16.png b/javapng/src/test/images/suite/g05n0g16.png deleted file mode 100644 index 70b37f0..0000000 Binary files a/javapng/src/test/images/suite/g05n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g05n2c08.png b/javapng/src/test/images/suite/g05n2c08.png deleted file mode 100644 index 932c136..0000000 Binary files a/javapng/src/test/images/suite/g05n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g05n3p04.png b/javapng/src/test/images/suite/g05n3p04.png deleted file mode 100644 index 9619930..0000000 Binary files a/javapng/src/test/images/suite/g05n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g07n0g16.png b/javapng/src/test/images/suite/g07n0g16.png deleted file mode 100644 index d6a47c2..0000000 Binary files a/javapng/src/test/images/suite/g07n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g07n2c08.png b/javapng/src/test/images/suite/g07n2c08.png deleted file mode 100644 index 5973464..0000000 Binary files a/javapng/src/test/images/suite/g07n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g07n3p04.png b/javapng/src/test/images/suite/g07n3p04.png deleted file mode 100644 index c73fb61..0000000 Binary files a/javapng/src/test/images/suite/g07n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g10n0g16.png b/javapng/src/test/images/suite/g10n0g16.png deleted file mode 100644 index 85f2c95..0000000 Binary files a/javapng/src/test/images/suite/g10n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g10n2c08.png b/javapng/src/test/images/suite/g10n2c08.png deleted file mode 100644 index b303997..0000000 Binary files a/javapng/src/test/images/suite/g10n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g10n3p04.png b/javapng/src/test/images/suite/g10n3p04.png deleted file mode 100644 index 1b6a6be..0000000 Binary files a/javapng/src/test/images/suite/g10n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g25n0g16.png b/javapng/src/test/images/suite/g25n0g16.png deleted file mode 100644 index a9f6787..0000000 Binary files a/javapng/src/test/images/suite/g25n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g25n2c08.png b/javapng/src/test/images/suite/g25n2c08.png deleted file mode 100644 index 03f505a..0000000 Binary files a/javapng/src/test/images/suite/g25n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/g25n3p04.png b/javapng/src/test/images/suite/g25n3p04.png deleted file mode 100644 index 4f943c6..0000000 Binary files a/javapng/src/test/images/suite/g25n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/oi1n0g16.png b/javapng/src/test/images/suite/oi1n0g16.png deleted file mode 100644 index e7c82f7..0000000 Binary files a/javapng/src/test/images/suite/oi1n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/oi1n2c16.png b/javapng/src/test/images/suite/oi1n2c16.png deleted file mode 100644 index 50c1cb9..0000000 Binary files a/javapng/src/test/images/suite/oi1n2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/oi2n0g16.png b/javapng/src/test/images/suite/oi2n0g16.png deleted file mode 100644 index 14d64c5..0000000 Binary files a/javapng/src/test/images/suite/oi2n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/oi2n2c16.png b/javapng/src/test/images/suite/oi2n2c16.png deleted file mode 100644 index 4c2e3e3..0000000 Binary files a/javapng/src/test/images/suite/oi2n2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/oi4n0g16.png b/javapng/src/test/images/suite/oi4n0g16.png deleted file mode 100644 index 69e73ed..0000000 Binary files a/javapng/src/test/images/suite/oi4n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/oi4n2c16.png b/javapng/src/test/images/suite/oi4n2c16.png deleted file mode 100644 index 93691e3..0000000 Binary files a/javapng/src/test/images/suite/oi4n2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/oi9n0g16.png b/javapng/src/test/images/suite/oi9n0g16.png deleted file mode 100644 index 9248413..0000000 Binary files a/javapng/src/test/images/suite/oi9n0g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/oi9n2c16.png b/javapng/src/test/images/suite/oi9n2c16.png deleted file mode 100644 index f0512e4..0000000 Binary files a/javapng/src/test/images/suite/oi9n2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/pp0n2c16.png b/javapng/src/test/images/suite/pp0n2c16.png deleted file mode 100644 index 8f2aad7..0000000 Binary files a/javapng/src/test/images/suite/pp0n2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/pp0n6a08.png b/javapng/src/test/images/suite/pp0n6a08.png deleted file mode 100644 index 4ed7a30..0000000 Binary files a/javapng/src/test/images/suite/pp0n6a08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ps1n0g08.png b/javapng/src/test/images/suite/ps1n0g08.png deleted file mode 100644 index 2053df2..0000000 Binary files a/javapng/src/test/images/suite/ps1n0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ps1n2c16.png b/javapng/src/test/images/suite/ps1n2c16.png deleted file mode 100644 index b03ecfc..0000000 Binary files a/javapng/src/test/images/suite/ps1n2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ps2n0g08.png b/javapng/src/test/images/suite/ps2n0g08.png deleted file mode 100644 index beeab8f..0000000 Binary files a/javapng/src/test/images/suite/ps2n0g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/ps2n2c16.png b/javapng/src/test/images/suite/ps2n2c16.png deleted file mode 100644 index c256f90..0000000 Binary files a/javapng/src/test/images/suite/ps2n2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s01i3p01.png b/javapng/src/test/images/suite/s01i3p01.png deleted file mode 100644 index 6c0fad1..0000000 Binary files a/javapng/src/test/images/suite/s01i3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s01n3p01.png b/javapng/src/test/images/suite/s01n3p01.png deleted file mode 100644 index cb2c8c7..0000000 Binary files a/javapng/src/test/images/suite/s01n3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s02i3p01.png b/javapng/src/test/images/suite/s02i3p01.png deleted file mode 100644 index 2defaed..0000000 Binary files a/javapng/src/test/images/suite/s02i3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s02n3p01.png b/javapng/src/test/images/suite/s02n3p01.png deleted file mode 100644 index 2b1b669..0000000 Binary files a/javapng/src/test/images/suite/s02n3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s03i3p01.png b/javapng/src/test/images/suite/s03i3p01.png deleted file mode 100644 index c23fdc4..0000000 Binary files a/javapng/src/test/images/suite/s03i3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s03n3p01.png b/javapng/src/test/images/suite/s03n3p01.png deleted file mode 100644 index 6d96ee4..0000000 Binary files a/javapng/src/test/images/suite/s03n3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s04i3p01.png b/javapng/src/test/images/suite/s04i3p01.png deleted file mode 100644 index 0e710c2..0000000 Binary files a/javapng/src/test/images/suite/s04i3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s04n3p01.png b/javapng/src/test/images/suite/s04n3p01.png deleted file mode 100644 index 956396c..0000000 Binary files a/javapng/src/test/images/suite/s04n3p01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s05i3p02.png b/javapng/src/test/images/suite/s05i3p02.png deleted file mode 100644 index d14cbd3..0000000 Binary files a/javapng/src/test/images/suite/s05i3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s05n3p02.png b/javapng/src/test/images/suite/s05n3p02.png deleted file mode 100644 index bf940f0..0000000 Binary files a/javapng/src/test/images/suite/s05n3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s06i3p02.png b/javapng/src/test/images/suite/s06i3p02.png deleted file mode 100644 index 456ada3..0000000 Binary files a/javapng/src/test/images/suite/s06i3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s06n3p02.png b/javapng/src/test/images/suite/s06n3p02.png deleted file mode 100644 index 501064d..0000000 Binary files a/javapng/src/test/images/suite/s06n3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s07i3p02.png b/javapng/src/test/images/suite/s07i3p02.png deleted file mode 100644 index 44b66ba..0000000 Binary files a/javapng/src/test/images/suite/s07i3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s07n3p02.png b/javapng/src/test/images/suite/s07n3p02.png deleted file mode 100644 index 6a58259..0000000 Binary files a/javapng/src/test/images/suite/s07n3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s08i3p02.png b/javapng/src/test/images/suite/s08i3p02.png deleted file mode 100644 index acf74f3..0000000 Binary files a/javapng/src/test/images/suite/s08i3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s08n3p02.png b/javapng/src/test/images/suite/s08n3p02.png deleted file mode 100644 index b7094e1..0000000 Binary files a/javapng/src/test/images/suite/s08n3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s09i3p02.png b/javapng/src/test/images/suite/s09i3p02.png deleted file mode 100644 index 0bfae8e..0000000 Binary files a/javapng/src/test/images/suite/s09i3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s09n3p02.png b/javapng/src/test/images/suite/s09n3p02.png deleted file mode 100644 index 711ab82..0000000 Binary files a/javapng/src/test/images/suite/s09n3p02.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s32i3p04.png b/javapng/src/test/images/suite/s32i3p04.png deleted file mode 100644 index 0841910..0000000 Binary files a/javapng/src/test/images/suite/s32i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s32n3p04.png b/javapng/src/test/images/suite/s32n3p04.png deleted file mode 100644 index fa58e3e..0000000 Binary files a/javapng/src/test/images/suite/s32n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s33i3p04.png b/javapng/src/test/images/suite/s33i3p04.png deleted file mode 100644 index ab0dc14..0000000 Binary files a/javapng/src/test/images/suite/s33i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s33n3p04.png b/javapng/src/test/images/suite/s33n3p04.png deleted file mode 100644 index 764f1a3..0000000 Binary files a/javapng/src/test/images/suite/s33n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s34i3p04.png b/javapng/src/test/images/suite/s34i3p04.png deleted file mode 100644 index bd99039..0000000 Binary files a/javapng/src/test/images/suite/s34i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s34n3p04.png b/javapng/src/test/images/suite/s34n3p04.png deleted file mode 100644 index 9cbc68b..0000000 Binary files a/javapng/src/test/images/suite/s34n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s35i3p04.png b/javapng/src/test/images/suite/s35i3p04.png deleted file mode 100644 index e2a5e0a..0000000 Binary files a/javapng/src/test/images/suite/s35i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s35n3p04.png b/javapng/src/test/images/suite/s35n3p04.png deleted file mode 100644 index 90b892e..0000000 Binary files a/javapng/src/test/images/suite/s35n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s36i3p04.png b/javapng/src/test/images/suite/s36i3p04.png deleted file mode 100644 index eb61b6f..0000000 Binary files a/javapng/src/test/images/suite/s36i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s36n3p04.png b/javapng/src/test/images/suite/s36n3p04.png deleted file mode 100644 index b38d179..0000000 Binary files a/javapng/src/test/images/suite/s36n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s37i3p04.png b/javapng/src/test/images/suite/s37i3p04.png deleted file mode 100644 index 6e2b1e9..0000000 Binary files a/javapng/src/test/images/suite/s37i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s37n3p04.png b/javapng/src/test/images/suite/s37n3p04.png deleted file mode 100644 index 4d3054d..0000000 Binary files a/javapng/src/test/images/suite/s37n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s38i3p04.png b/javapng/src/test/images/suite/s38i3p04.png deleted file mode 100644 index a0a8a14..0000000 Binary files a/javapng/src/test/images/suite/s38i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s38n3p04.png b/javapng/src/test/images/suite/s38n3p04.png deleted file mode 100644 index 1233ed0..0000000 Binary files a/javapng/src/test/images/suite/s38n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s39i3p04.png b/javapng/src/test/images/suite/s39i3p04.png deleted file mode 100644 index 04fee93..0000000 Binary files a/javapng/src/test/images/suite/s39i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s39n3p04.png b/javapng/src/test/images/suite/s39n3p04.png deleted file mode 100644 index c750100..0000000 Binary files a/javapng/src/test/images/suite/s39n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s40i3p04.png b/javapng/src/test/images/suite/s40i3p04.png deleted file mode 100644 index 68f358b..0000000 Binary files a/javapng/src/test/images/suite/s40i3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/s40n3p04.png b/javapng/src/test/images/suite/s40n3p04.png deleted file mode 100644 index 864b6b9..0000000 Binary files a/javapng/src/test/images/suite/s40n3p04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbbn1g04.png b/javapng/src/test/images/suite/tbbn1g04.png deleted file mode 100644 index fc80020..0000000 Binary files a/javapng/src/test/images/suite/tbbn1g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbbn2c16.png b/javapng/src/test/images/suite/tbbn2c16.png deleted file mode 100644 index 5abfbbb..0000000 Binary files a/javapng/src/test/images/suite/tbbn2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbbn3p08.png b/javapng/src/test/images/suite/tbbn3p08.png deleted file mode 100644 index 4210d16..0000000 Binary files a/javapng/src/test/images/suite/tbbn3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbgn2c16.png b/javapng/src/test/images/suite/tbgn2c16.png deleted file mode 100644 index 236c81d..0000000 Binary files a/javapng/src/test/images/suite/tbgn2c16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbgn3p08.png b/javapng/src/test/images/suite/tbgn3p08.png deleted file mode 100644 index 42db232..0000000 Binary files a/javapng/src/test/images/suite/tbgn3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbrn2c08.png b/javapng/src/test/images/suite/tbrn2c08.png deleted file mode 100644 index 8c21474..0000000 Binary files a/javapng/src/test/images/suite/tbrn2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbwn1g16.png b/javapng/src/test/images/suite/tbwn1g16.png deleted file mode 100644 index dba2cbb..0000000 Binary files a/javapng/src/test/images/suite/tbwn1g16.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbwn3p08.png b/javapng/src/test/images/suite/tbwn3p08.png deleted file mode 100644 index 7922135..0000000 Binary files a/javapng/src/test/images/suite/tbwn3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tbyn3p08.png b/javapng/src/test/images/suite/tbyn3p08.png deleted file mode 100644 index 5b2c6cb..0000000 Binary files a/javapng/src/test/images/suite/tbyn3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tp0n1g08.png b/javapng/src/test/images/suite/tp0n1g08.png deleted file mode 100644 index caad31d..0000000 Binary files a/javapng/src/test/images/suite/tp0n1g08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tp0n2c08.png b/javapng/src/test/images/suite/tp0n2c08.png deleted file mode 100644 index f26be44..0000000 Binary files a/javapng/src/test/images/suite/tp0n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tp0n3p08.png b/javapng/src/test/images/suite/tp0n3p08.png deleted file mode 100644 index 4d6cf9e..0000000 Binary files a/javapng/src/test/images/suite/tp0n3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/tp1n3p08.png b/javapng/src/test/images/suite/tp1n3p08.png deleted file mode 100644 index 6c5fd6e..0000000 Binary files a/javapng/src/test/images/suite/tp1n3p08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/x00n0g01.png b/javapng/src/test/images/suite/x00n0g01.png deleted file mode 100644 index db3a5fd..0000000 Binary files a/javapng/src/test/images/suite/x00n0g01.png and /dev/null differ diff --git a/javapng/src/test/images/suite/xcrn0g04.png b/javapng/src/test/images/suite/xcrn0g04.png deleted file mode 100644 index 5bce9f3..0000000 Binary files a/javapng/src/test/images/suite/xcrn0g04.png and /dev/null differ diff --git a/javapng/src/test/images/suite/xlfn0g04.png b/javapng/src/test/images/suite/xlfn0g04.png deleted file mode 100644 index 1fd104b..0000000 --- a/javapng/src/test/images/suite/xlfn0g04.png +++ /dev/null @@ -1,13 +0,0 @@ -PNG - - - - - -IHDR )IDATx] -0 P*@# - -#T10lPF`ؠF=IQ*u`%qk -H񚈩mߟ э=,fOK - -t(F ;P{xp]9/p*$(*yՃ@C  cqNU#)11.rf0gh(tEkIENDB` \ No newline at end of file diff --git a/javapng/src/test/images/suite/z00n2c08.png b/javapng/src/test/images/suite/z00n2c08.png deleted file mode 100644 index 7669eb8..0000000 Binary files a/javapng/src/test/images/suite/z00n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/z03n2c08.png b/javapng/src/test/images/suite/z03n2c08.png deleted file mode 100644 index bfb10de..0000000 Binary files a/javapng/src/test/images/suite/z03n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/z06n2c08.png b/javapng/src/test/images/suite/z06n2c08.png deleted file mode 100644 index b90ebc1..0000000 Binary files a/javapng/src/test/images/suite/z06n2c08.png and /dev/null differ diff --git a/javapng/src/test/images/suite/z09n2c08.png b/javapng/src/test/images/suite/z09n2c08.png deleted file mode 100644 index 5f191a7..0000000 Binary files a/javapng/src/test/images/suite/z09n2c08.png and /dev/null differ diff --git a/javapng2/COPYING b/javapng2/COPYING deleted file mode 100644 index 93796b6..0000000 --- a/javapng2/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/javapng2/LICENSE b/javapng2/LICENSE deleted file mode 100644 index e23f7a2..0000000 --- a/javapng2/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -The software in this package is distributed under the GNU General Public -License (with a special exception described below). - -A copy of GNU General Public License (GPL) is included in this distribution, -in the file COPYING. If you do not have the source code, it is available at: - - http://www.sixlegs.com/software/png/ - - Linking this library statically or dynamically with other modules is - making a combined work based on this library. Thus, the terms and - conditions of the GNU General Public License cover the whole - combination. - - As a special exception, the copyright holders of this library give you - permission to link this library with independent modules to produce an - executable, regardless of the license terms of these independent - modules, and to copy and distribute the resulting executable under - terms of your choice, provided that you also meet, for each linked - independent module, the terms and conditions of the license of that - module. An independent module is a module which is not derived from - or based on this library. If you modify this library, you may extend - this exception to your version of the library, but you are not - obligated to do so. If you do not wish to do so, delete this - exception statement from your version. diff --git a/javapng2/README b/javapng2/README deleted file mode 100644 index bea1752..0000000 --- a/javapng2/README +++ /dev/null @@ -1,40 +0,0 @@ -Copyright (C) 1998-2008 Chris Nokleberg -All rights reserved. - -README - Sixlegs Java PNG Decoder - -Features - - Supports all valid bit depths (grayscale/color), interlacing, paletted - images, alpha channel/transparency, gamma correction, access to all - standard chunks, private chunk handling, and progressive display. - -Getting Started - - After including the javapng jar file in your classpath, typical usage - is as follows: - - // create a new instance of PngImage - com.sixlegs.png.PngImage png = new com.sixlegs.png.PngImage(); - - // decode a PNG file into a BufferedImage using the read method - java.awt.image.BufferedImage image = - png.read(new java.io.File("test.png")); - - // the PngImage object will now provide access to the metadata - int colorType = png.getColorType(); - -Revision History - - See http://code.google.com/p/javapng/wiki/ChangeLog - -Contact Information - - The latest version of this package is available from: - http://code.google.com/p/javapng/ - - Please let me know about any problems you encounter, or features - that you would find valuable. - - Chris Nokleberg - diff --git a/javapng2/benchmark.txt b/javapng2/benchmark.txt deleted file mode 100644 index f31f0a6..0000000 --- a/javapng2/benchmark.txt +++ /dev/null @@ -1,158 +0,0 @@ -src/test/images/suite/basi0g01.png -src/test/images/suite/basi0g02.png -src/test/images/suite/basi0g04.png -src/test/images/suite/basi0g08.png -src/test/images/suite/basi0g16.png -src/test/images/suite/basi2c08.png -src/test/images/suite/basi2c16.png -src/test/images/suite/basi3p01.png -src/test/images/suite/basi3p02.png -src/test/images/suite/basi3p04.png -src/test/images/suite/basi3p08.png -src/test/images/suite/basi4a08.png -src/test/images/suite/basi4a16.png -src/test/images/suite/basi6a08.png -src/test/images/suite/basi6a16.png -src/test/images/suite/basn0g01.png -src/test/images/suite/basn0g02.png -src/test/images/suite/basn0g04.png -src/test/images/suite/basn0g08.png -src/test/images/suite/basn0g16.png -src/test/images/suite/basn2c08.png -src/test/images/suite/basn2c16.png -src/test/images/suite/basn3p01.png -src/test/images/suite/basn3p02.png -src/test/images/suite/basn3p04.png -src/test/images/suite/basn3p08.png -src/test/images/suite/basn4a08.png -src/test/images/suite/basn4a16.png -src/test/images/suite/basn6a08.png -src/test/images/suite/basn6a16.png -src/test/images/suite/bgai4a08.png -src/test/images/suite/bgai4a16.png -src/test/images/suite/bgan6a08.png -src/test/images/suite/bgan6a16.png -src/test/images/suite/bgbn4a08.png -src/test/images/suite/bggn4a16.png -src/test/images/suite/bgwn6a08.png -src/test/images/suite/bgyn6a16.png -src/test/images/suite/ccwn2c08.png -src/test/images/suite/ccwn3p08.png -src/test/images/suite/cdfn2c08.png -src/test/images/suite/cdhn2c08.png -src/test/images/suite/cdsn2c08.png -src/test/images/suite/cdun2c08.png -src/test/images/suite/ch2n3p08.png -src/test/images/suite/cm0n0g04.png -src/test/images/suite/cm7n0g04.png -src/test/images/suite/cm9n0g04.png -src/test/images/suite/cs3n2c16.png -src/test/images/suite/cs3n3p08.png -src/test/images/suite/cs5n2c08.png -src/test/images/suite/cs5n3p08.png -src/test/images/suite/cs8n2c08.png -src/test/images/suite/cs8n3p08.png -src/test/images/suite/ct0n0g04.png -src/test/images/suite/ct1n0g04.png -src/test/images/suite/ctzn0g04.png -src/test/images/suite/f00n0g08.png -src/test/images/suite/f00n2c08.png -src/test/images/suite/f01n0g08.png -src/test/images/suite/f01n2c08.png -src/test/images/suite/f02n0g08.png -src/test/images/suite/f02n2c08.png -src/test/images/suite/f03n0g08.png -src/test/images/suite/f03n2c08.png -src/test/images/suite/f04n0g08.png -src/test/images/suite/f04n2c08.png -src/test/images/suite/g03n0g16.png -src/test/images/suite/g03n2c08.png -src/test/images/suite/g03n3p04.png -src/test/images/suite/g04n0g16.png -src/test/images/suite/g04n2c08.png -src/test/images/suite/g04n3p04.png -src/test/images/suite/g05n0g16.png -src/test/images/suite/g05n2c08.png -src/test/images/suite/g05n3p04.png -src/test/images/suite/g07n0g16.png -src/test/images/suite/g07n2c08.png -src/test/images/suite/g07n3p04.png -src/test/images/suite/g10n0g16.png -src/test/images/suite/g10n2c08.png -src/test/images/suite/g10n3p04.png -src/test/images/suite/g25n0g16.png -src/test/images/suite/g25n2c08.png -src/test/images/suite/g25n3p04.png -src/test/images/suite/oi1n0g16.png -src/test/images/suite/oi1n2c16.png -src/test/images/suite/oi2n0g16.png -src/test/images/suite/oi2n2c16.png -src/test/images/suite/oi4n0g16.png -src/test/images/suite/oi4n2c16.png -src/test/images/suite/oi9n0g16.png -src/test/images/suite/oi9n2c16.png -src/test/images/suite/pp0n2c16.png -src/test/images/suite/pp0n6a08.png -src/test/images/suite/ps1n0g08.png -src/test/images/suite/ps1n2c16.png -src/test/images/suite/ps2n0g08.png -src/test/images/suite/ps2n2c16.png -src/test/images/suite/s01i3p01.png -src/test/images/suite/s01n3p01.png -src/test/images/suite/s02i3p01.png -src/test/images/suite/s02n3p01.png -src/test/images/suite/s03i3p01.png -src/test/images/suite/s03n3p01.png -src/test/images/suite/s04i3p01.png -src/test/images/suite/s04n3p01.png -src/test/images/suite/s05i3p02.png -src/test/images/suite/s05n3p02.png -src/test/images/suite/s06i3p02.png -src/test/images/suite/s06n3p02.png -src/test/images/suite/s07i3p02.png -src/test/images/suite/s07n3p02.png -src/test/images/suite/s08i3p02.png -src/test/images/suite/s08n3p02.png -src/test/images/suite/s09i3p02.png -src/test/images/suite/s09n3p02.png -src/test/images/suite/s32i3p04.png -src/test/images/suite/s32n3p04.png -src/test/images/suite/s33i3p04.png -src/test/images/suite/s33n3p04.png -src/test/images/suite/s34i3p04.png -src/test/images/suite/s34n3p04.png -src/test/images/suite/s35i3p04.png -src/test/images/suite/s35n3p04.png -src/test/images/suite/s36i3p04.png -src/test/images/suite/s36n3p04.png -src/test/images/suite/s37i3p04.png -src/test/images/suite/s37n3p04.png -src/test/images/suite/s38i3p04.png -src/test/images/suite/s38n3p04.png -src/test/images/suite/s39i3p04.png -src/test/images/suite/s39n3p04.png -src/test/images/suite/s40i3p04.png -src/test/images/suite/s40n3p04.png -src/test/images/suite/tbbn1g04.png -src/test/images/suite/tbbn2c16.png -src/test/images/suite/tbbn3p08.png -src/test/images/suite/tbgn2c16.png -src/test/images/suite/tbgn3p08.png -src/test/images/suite/tbrn2c08.png -src/test/images/suite/tbwn1g16.png -src/test/images/suite/tbwn3p08.png -src/test/images/suite/tbyn3p08.png -src/test/images/suite/tp0n1g08.png -src/test/images/suite/tp0n2c08.png -src/test/images/suite/tp0n3p08.png -src/test/images/suite/z00n2c08.png -src/test/images/suite/z03n2c08.png -src/test/images/suite/z06n2c08.png -src/test/images/suite/z09n2c08.png -src/test/images/misc/anigif.png -src/test/images/misc/cc1.png -src/test/images/misc/manhat.png -src/test/images/misc/penguin.png -src/test/images/misc/ps2n2c16.png -src/test/images/misc/u_horn.111.png -src/test/images/misc/pngtest.png diff --git a/javapng2/build.properties.sample b/javapng2/build.properties.sample deleted file mode 100644 index 5d34b6c..0000000 --- a/javapng2/build.properties.sample +++ /dev/null @@ -1,4 +0,0 @@ -compile.bootclasspath.12 = rt-1.2.2.17.jar -compile.bootclasspath.14 = rt-1.4.2.10.jar -compile.optimize = true -compile.deprecation = false diff --git a/javapng2/build.xml b/javapng2/build.xml deleted file mode 100644 index 3029eac..0000000 --- a/javapng2/build.xml +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - com.sixlegs.png.iio.PngImageReaderSpi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/javapng2/javadoc/allclasses-frame.html b/javapng2/javadoc/allclasses-frame.html deleted file mode 100644 index f99d736..0000000 --- a/javapng2/javadoc/allclasses-frame.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - -All Classes - - - - - - - - - - -All Classes -
- - - - - -
PngConfig -
-PngConfig.Builder -
-PngConstants -
-PngException -
-PngImage -
-SuggestedPalette -
-TextChunk -
-
- - - diff --git a/javapng2/javadoc/allclasses-noframe.html b/javapng2/javadoc/allclasses-noframe.html deleted file mode 100644 index dbd5e19..0000000 --- a/javapng2/javadoc/allclasses-noframe.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - -All Classes - - - - - - - - - - -All Classes -
- - - - - -
PngConfig -
-PngConfig.Builder -
-PngConstants -
-PngException -
-PngImage -
-SuggestedPalette -
-TextChunk -
-
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/PngConfig.Builder.html b/javapng2/javadoc/com/sixlegs/png/PngConfig.Builder.html deleted file mode 100644 index 98e435e..0000000 --- a/javapng2/javadoc/com/sixlegs/png/PngConfig.Builder.html +++ /dev/null @@ -1,530 +0,0 @@ - - - - - - -PngConfig.Builder - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -


- -

- -com.sixlegs.png -
-Class PngConfig.Builder

-
-java.lang.Object
-  extended by com.sixlegs.png.PngConfig.Builder
-
-
-
Enclosing class:
PngConfig
-
-
-
-
public static final class PngConfig.Builder
extends Object
- - -

-Builder class used to construct PngConfig instances. - Each "setter" method returns an reference to the instance to enable - chaining multiple calls. - Call build() to construct a new PngConfig instance - using the current Builder settings. Example: -

PngConfig config = new PngConfig.Builder()
-        .readLimit(PngConfig.READ_EXCEPT_METADATA)
-        .warningsFatal(true)
-        .build();
-

- -

-


- -

- - - - - - - - - - - - - - -
-Constructor Summary
PngConfig.Builder() - -
-          Create a new builder using default values.
PngConfig.Builder(PngConfig cfg) - -
-          Create a builder using values from the given configuration.
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- PngConfigbuild() - -
-          Create a configuration using the current values of this builder.
- PngConfig.BuilderconvertIndexed(boolean convertIndexed) - -
-          Whether to convert images with an indexed color model - (paletted and 1/2/4/8-bit grayscale) to use a component color model.
- PngConfig.BuilderdefaultGamma(float defaultGamma) - -
-          Sets the default gamma value.
- PngConfig.BuilderdisplayExponent(float displayExponent) - -
-          Sets the default display exponent.
- PngConfig.BuildergammaCorrect(boolean gammaCorrect) - -
-          Enables or disables gamma correction.
- PngConfig.Builderprogressive(boolean progressive) - -
-          Enables or disables progressive display for interlaced images.
- PngConfig.BuilderreadLimit(int readLimit) - -
-          Configures how much of the image to read.
- PngConfig.Builderreduce16(boolean reduce16) - -
-          Enables or disables 16-bit reduction.
- PngConfig.BuildersourceRegion(Rectangle sourceRegion) - -
-          Decode only a particular region of the source image.
- PngConfig.BuildersourceSubsampling(int xsub, - int ysub, - int xoff, - int yoff) - -
-          Reduce the size of the decoded image (or source region) by only using - periodic rows and/or columns of the image.
- PngConfig.BuilderwarningsFatal(boolean warningsFatal) - -
-          Configures whether warnings should be treated as fatal errors.
- - - - - - - -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Constructor Detail
- -

-PngConfig.Builder

-
-public PngConfig.Builder()
-
-
Create a new builder using default values. -

-

-
- -

-PngConfig.Builder

-
-public PngConfig.Builder(PngConfig cfg)
-
-
Create a builder using values from the given configuration. -

-

-
Parameters:
cfg - the configuration to copy
-
- - - - - - - - -
-Method Detail
- -

-build

-
-public PngConfig build()
-
-
Create a configuration using the current values of this builder. -

-

-
-
-
-
- -

-reduce16

-
-public PngConfig.Builder reduce16(boolean reduce16)
-
-
Enables or disables 16-bit reduction. If enabled, 16-bit samples are reduced to 8-bit samples by - shifting to the right by 8 bits. Default is true. -

-

-
Parameters:
reduce16 - enable 16-bit reduction
-
-
-
- -

-defaultGamma

-
-public PngConfig.Builder defaultGamma(float defaultGamma)
-
-
Sets the default gamma value. This value is used unless the image - contains an explicit gamma value. Initial value is 1/45455. -

-

-
Parameters:
defaultGamma - the default gamma value
-
-
-
- -

-displayExponent

-
-public PngConfig.Builder displayExponent(float displayExponent)
-
-
Sets the default display exponent. The proper setting depends on monitor and OS gamma lookup - table settings, if any. The default value of 2.2 should - work well with most PC displays. If the operating system has - a gamma lookup table (e.g. Macintosh) the display exponent should be lower. -

-

-
Parameters:
displayExponent - the display exponent
-
-
-
- -

-gammaCorrect

-
-public PngConfig.Builder gammaCorrect(boolean gammaCorrect)
-
-
Enables or disables gamma correction. If enabled, decoded images will be gamma corrected. - Sets to false if your application will perform gamma correctly manually. - Default is true. -

-

-
Parameters:
gammaCorrect - use gamma correction
See Also:
PngImage.getGamma(), -PngImage.getGammaTable()
-
-
-
- -

-progressive

-
-public PngConfig.Builder progressive(boolean progressive)
-
-
Enables or disables progressive display for interlaced images. - If enabled, each received pixel is expanded (replicated) to fill a rectangle - covering the yet-to-be-transmitted pixel positions below and to the right - of the received pixel. This produces a "fade-in" effect as the new image - gradually replaces the old, at the cost of some additional processing time. - Default is false. -

-

-
Parameters:
progressive - use progressive display
See Also:
PngImage.handlePass(java.awt.image.BufferedImage, int)
-
-
-
- -

-readLimit

-
-public PngConfig.Builder readLimit(int readLimit)
-
-
Configures how much of the image to read. Useful when one is interested - in only a portion of the image metadata, and would like to avoid - reading and/or decoding the actual image data. -

-

-
Parameters:
readLimit - READ_ALL,
- READ_HEADER,
- READ_UNTIL_DATA,
- READ_EXCEPT_DATA,
- or READ_EXCEPT_METADATA
-
-
-
- -

-warningsFatal

-
-public PngConfig.Builder warningsFatal(boolean warningsFatal)
-
-
Configures whether warnings should be treated as fatal errors. - All non-fatal PngException exceptions are caught and passed to the PngImage.handleWarning(com.sixlegs.png.PngException) - method. If warnings are configured as fatal, that method will re-throw the - exception, which will abort image processing. Default is false. -

-

-
Parameters:
warningsFatal - true if warnings should be treated as fatal errors
See Also:
PngImage.handleWarning(com.sixlegs.png.PngException)
-
-
-
- -

-sourceRegion

-
-public PngConfig.Builder sourceRegion(Rectangle sourceRegion)
-
-
Decode only a particular region of the source image. See the equivalent - ImageIO method - for full documentation. -

-

-
-
-
-
- -

-sourceSubsampling

-
-public PngConfig.Builder sourceSubsampling(int xsub,
-                                           int ysub,
-                                           int xoff,
-                                           int yoff)
-
-
Reduce the size of the decoded image (or source region) by only using - periodic rows and/or columns of the image. See the equivalent - ImageIO method - for full documentation. -

-

-
-
-
-
- -

-convertIndexed

-
-public PngConfig.Builder convertIndexed(boolean convertIndexed)
-
-
Whether to convert images with an indexed color model - (paletted and 1/2/4/8-bit grayscale) to use a component color model. -

-

-
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/PngConfig.html b/javapng2/javadoc/com/sixlegs/png/PngConfig.html deleted file mode 100644 index 484fdbf..0000000 --- a/javapng2/javadoc/com/sixlegs/png/PngConfig.html +++ /dev/null @@ -1,615 +0,0 @@ - - - - - - -PngConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -com.sixlegs.png -
-Class PngConfig

-
-java.lang.Object
-  extended by com.sixlegs.png.PngConfig
-
-
-
-
public final class PngConfig
extends Object
- - -

-Customizable parameters used by PngImage when decoding an image. - Instances of this class are immutable and can only be constructed - using the PngConfig.Builder inner-class. -

- -

-


- -

- - - - - - - - - - - -
-Nested Class Summary
-static classPngConfig.Builder - -
-          Builder class used to construct PngConfig instances.
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-Field Summary
-static intREAD_ALL - -
-          Read the entire image
-static intREAD_EXCEPT_DATA - -
-          Read the entire image, skipping over the image data
-static intREAD_EXCEPT_METADATA - -
-          Read the entire image, skipping over all non-critical chunks except tRNS and gAMA
-static intREAD_HEADER - -
-          Read only the header chunk
-static intREAD_UNTIL_DATA - -
-          Read all the metadata up to the image data
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- booleangetConvertIndexed() - -
-          Return sthe current indexed image conversion setting.
- floatgetDefaultGamma() - -
-          Returns the current default gamma value.
- floatgetDisplayExponent() - -
-          Returns the current display exponent.
- booleangetGammaCorrect() - -
-          Returns the current gamma correction setting.
- booleangetProgressive() - -
-          Returns the current progressive display setting.
- intgetReadLimit() - -
-          Returns the current read limit setting.
- booleangetReduce16() - -
-          Returns the current 16-bit reduction setting.
- RectanglegetSourceRegion() - -
-          Returns the source region to be used.
- intgetSourceXSubsampling() - -
-          Returns the number of source columns to advance for each pixel.
- intgetSourceYSubsampling() - -
-          Returns the number of rows to advance for each pixel.
- intgetSubsamplingXOffset() - -
-          Returns the horizontal offset of the subsampling grid.
- intgetSubsamplingYOffset() - -
-          Returns the vertical offset of the subsampling grid.
- booleangetWarningsFatal() - -
-          Returns whether warnings are treated as fatal errors.
- - - - - - - -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-READ_ALL

-
-public static final int READ_ALL
-
-
Read the entire image -

-

-
See Also:
Constant Field Values
-
-
- -

-READ_HEADER

-
-public static final int READ_HEADER
-
-
Read only the header chunk -

-

-
See Also:
Constant Field Values
-
-
- -

-READ_UNTIL_DATA

-
-public static final int READ_UNTIL_DATA
-
-
Read all the metadata up to the image data -

-

-
See Also:
Constant Field Values
-
-
- -

-READ_EXCEPT_DATA

-
-public static final int READ_EXCEPT_DATA
-
-
Read the entire image, skipping over the image data -

-

-
See Also:
Constant Field Values
-
-
- -

-READ_EXCEPT_METADATA

-
-public static final int READ_EXCEPT_METADATA
-
-
Read the entire image, skipping over all non-critical chunks except tRNS and gAMA -

-

-
See Also:
Constant Field Values
-
- - - - - - - - -
-Method Detail
- -

-getConvertIndexed

-
-public boolean getConvertIndexed()
-
-
Return sthe current indexed image conversion setting. -

-

-
See Also:
PngConfig.Builder.convertIndexed
-
-
-
- -

-getReduce16

-
-public boolean getReduce16()
-
-
Returns the current 16-bit reduction setting. -

-

-
See Also:
PngConfig.Builder.reduce16
-
-
-
- -

-getDefaultGamma

-
-public float getDefaultGamma()
-
-
Returns the current default gamma value. -

-

-
See Also:
PngConfig.Builder.defaultGamma
-
-
-
- -

-getGammaCorrect

-
-public boolean getGammaCorrect()
-
-
Returns the current gamma correction setting. -

-

-
See Also:
PngConfig.Builder.gammaCorrect
-
-
-
- -

-getProgressive

-
-public boolean getProgressive()
-
-
Returns the current progressive display setting. -

-

-
See Also:
PngConfig.Builder.progressive
-
-
-
- -

-getDisplayExponent

-
-public float getDisplayExponent()
-
-
Returns the current display exponent. -

-

-
See Also:
PngConfig.Builder.displayExponent
-
-
-
- -

-getReadLimit

-
-public int getReadLimit()
-
-
Returns the current read limit setting. -

-

- -
Returns:
one of - READ_ALL,
- READ_HEADER,
- READ_UNTIL_DATA,
- READ_EXCEPT_DATA,
- or READ_EXCEPT_METADATA
See Also:
PngConfig.Builder.readLimit
-
-
-
- -

-getWarningsFatal

-
-public boolean getWarningsFatal()
-
-
Returns whether warnings are treated as fatal errors. -

-

-
See Also:
PngConfig.Builder.warningsFatal
-
-
-
- -

-getSourceRegion

-
-public Rectangle getSourceRegion()
-
-
Returns the source region to be used. -

-

-
See Also:
PngConfig.Builder.sourceRegion
-
-
-
- -

-getSourceXSubsampling

-
-public int getSourceXSubsampling()
-
-
Returns the number of source columns to advance for each pixel. -

-

-
See Also:
PngConfig.Builder.sourceSubsampling(int, int, int, int)
-
-
-
- -

-getSourceYSubsampling

-
-public int getSourceYSubsampling()
-
-
Returns the number of rows to advance for each pixel. -

-

-
See Also:
PngConfig.Builder.sourceSubsampling(int, int, int, int)
-
-
-
- -

-getSubsamplingXOffset

-
-public int getSubsamplingXOffset()
-
-
Returns the horizontal offset of the subsampling grid. -

-

-
See Also:
PngConfig.Builder.sourceSubsampling(int, int, int, int)
-
-
-
- -

-getSubsamplingYOffset

-
-public int getSubsamplingYOffset()
-
-
Returns the vertical offset of the subsampling grid. -

-

-
See Also:
PngConfig.Builder.sourceSubsampling(int, int, int, int)
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/PngConstants.html b/javapng2/javadoc/com/sixlegs/png/PngConstants.html deleted file mode 100644 index e360c38..0000000 --- a/javapng2/javadoc/com/sixlegs/png/PngConstants.html +++ /dev/null @@ -1,2011 +0,0 @@ - - - - - - -PngConstants - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -com.sixlegs.png -
-Class PngConstants

-
-java.lang.Object
-  extended by com.sixlegs.png.PngConstants
-
-
-
-
public abstract class PngConstants
extends Object
- - -

-This interface defines all registered chunk types and provides methods - helper methods to examine them. It also defines all of the keys used in the property map - of a decoded PngImage, and applicable enumerated values. -

- -

-

-
See Also:
PngImage.getProperty(java.lang.String), -PngImage.getProperties()
-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Field Summary
-static StringBACKGROUND - -
-          bKGD: Background samples
-static StringBIT_DEPTH - -
-          IHDR: Bit depth
-static intbKGD - -
-          Background color
-static intcHRM - -
-          Primary chromaticities
-static StringCHROMATICITY - -
-          cHRM: Chromaticity
-static StringCOLOR_TYPE - -
-          IHDR: Color type
-static intCOLOR_TYPE_GRAY - -
-          IHDR: Grayscale color type
-static intCOLOR_TYPE_GRAY_ALPHA - -
-          IHDR: Grayscale+alpha color type
-static intCOLOR_TYPE_PALETTE - -
-          IHDR: Palette color type
-static intCOLOR_TYPE_RGB - -
-          IHDR: RGB color type
-static intCOLOR_TYPE_RGB_ALPHA - -
-          IHDR: RGBA color type
-static StringCOMPRESSION - -
-          IHDR: Compression method
-static intCOMPRESSION_BASE - -
-          IHDR: Deflate/inflate compression
-static StringFILTER - -
-          IHDR: Filter method
-static intFILTER_BASE - -
-          IHDR: Adaptive filtering
-static intgAMA - -
-          Image gamma
-static StringGAMMA - -
-          gAMA: Gamma
-static StringGIF_DELAY_TIME - -
-          gIFg: GIF delay time (hundredths of a second)
-static StringGIF_DISPOSAL_METHOD - -
-          gIFg: GIF disposal method
-static StringGIF_USER_INPUT_FLAG - -
-          gIFg: GIF user input flag
-static intgIFg - -
-          GIF Graphic Control Extension
-static intgIFx - -
-          GIF Application Extension
-static StringHEIGHT - -
-          IHDR: Height
-static inthIST - -
-          Palette histogram
-static StringHISTOGRAM - -
-          hIST: Palette histogram
-static StringICC_PROFILE - -
-          iCCP: ICC profile
-static StringICC_PROFILE_NAME - -
-          iCCP: ICC profile name
-static intiCCP - -
-          Embedded ICC profile
-static intIDAT - -
-          Image data
-static intIEND - -
-          Image trailer
-static intIHDR - -
-          Image header
-static StringINTERLACE - -
-          IHDR: Interlace method
-static intINTERLACE_ADAM7 - -
-          IHDR: Adam7 interlace
-static intINTERLACE_NONE - -
-          IHDR: No interlace
-static intiTXt - -
-          International textual data
-static intoFFs - -
-          Image offset
-static StringPALETTE - -
-          PLTE: Palette entries
-static StringPALETTE_ALPHA - -
-          PLTE: Palette alpha
-static intpCAL - -
-          Calibration of pixel values
-static intpHYs - -
-          Physical pixel dimensions
-static StringPIXEL_HEIGHT - -
-          sCAL: Physical height of pixel
-static StringPIXEL_WIDTH - -
-          sCAL: Physical width of pixel
-static StringPIXELS_PER_UNIT_X - -
-          pHYs: Pixels per unit, X axis
-static StringPIXELS_PER_UNIT_Y - -
-          pHYs: Pixels per unit, Y axis
-static intPLTE - -
-          Palette
-static StringPOSITION_UNIT - -
-          oFFs: Unit for image offset
-static intPOSITION_UNIT_MICROMETER - -
-          oFFs: Unit is the micrometer (10^-6 meter)
-static intPOSITION_UNIT_PIXEL - -
-          oFFs: Unit is the pixel (true dimensions unspecified)
-static StringPOSITION_X - -
-          oFFs: Image X position
-static StringPOSITION_Y - -
-          oFFs: Image Y position
-static StringRENDERING_INTENT - -
-          sRGB: Rendering intent
-static intsBIT - -
-          Significant bits
-static intsCAL - -
-          Physical scale of image subject
-static StringSCALE_UNIT - -
-          sCAL: Unit for physical scale of image subject
-static intSCALE_UNIT_METER - -
-          sCAL: Unit is the meter
-static intSCALE_UNIT_RADIAN - -
-          sCAL: Unit is the radian
-static longSIGNATURE - -
-          Eight byte magic number that begins all PNG images
-static StringSIGNIFICANT_BITS - -
-          sBIT: Significant bits
-static intsPLT - -
-          Suggested palette
-static intsRGB - -
-          Standard RGB color space
-static intSRGB_ABSOLUTE_COLORIMETRIC - -
-          sRGB: Absolute colormetric rendering intent
-static intSRGB_PERCEPTUAL - -
-          sRGB: Perceptual rendering intent
-static intSRGB_RELATIVE_COLORIMETRIC - -
-          sRGB: Relative colorimetric rendering intent
-static intSRGB_SATURATION_PRESERVING - -
-          sRGB: Saturation rendering intent
-static intsTER - -
-          Indicator of Stereo Image
-static StringSTEREO_MODE - -
-          sTER: Indicator of stereo image
-static intSTEREO_MODE_CROSS - -
-          sTER: Cross-fuse layout
-static intSTEREO_MODE_DIVERGING - -
-          sTER: Diverging-fuse layout
-static StringSUGGESTED_PALETTES - -
-          sPLT: List of suggested palettes
-static inttEXt - -
-          Textual data
-static StringTEXT_CHUNKS - -
-          tEXt/zTXt/iTXt: List of text chunks
-static inttIME - -
-          Image last-modification time
-static StringTIME - -
-          tIME: Image last-modification time
-static StringTRANSPARENCY - -
-          tRNS: Transparency samples
-static inttRNS - -
-          Transparency
-static StringUNIT - -
-          pHYs: Unit specifier
-static intUNIT_METER - -
-          pHYs: Unit is the meter
-static intUNIT_UNKNOWN - -
-          pHYs: Unit is unknown
-static StringWIDTH - -
-          IHDR: Width
-static intzTXt - -
-          Compressed textual data
-  - - - - - - - - - - -
-Constructor Summary
PngConstants() - -
-           
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
-static StringgetChunkName(int chunkType) - -
-          Returns the four-character ASCII name corresponding to the given - chunk type.
-static intgetChunkType(String chunkName) - -
-          Returns the chunk type corresponding to the given four-character - ASCII chunk name.
-static booleanisAncillary(int chunkType) - -
-          Returns true if the given chunk type has the ancillary bit set - (the first letter is lowercase).
-static booleanisPrivate(int chunkType) - -
-          Returns true if the given chunk type has the private bit set - (the second letter is lowercase).
-static booleanisReserved(int chunkType) - -
-          Returns true if the given chunk type has the reserved bit set - (the third letter is lowercase).
-static booleanisSafeToCopy(int chunkType) - -
-          Returns true if the given chunk type has the safe-to-copy bit set - (the fourth letter is lowercase).
- - - - - - - -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-SIGNATURE

-
-public static final long SIGNATURE
-
-
Eight byte magic number that begins all PNG images -

-

-
See Also:
Constant Field Values
-
-
- -

-IHDR

-
-public static final int IHDR
-
-
Image header -

-

-
See Also:
Constant Field Values
-
-
- -

-PLTE

-
-public static final int PLTE
-
-
Palette -

-

-
See Also:
Constant Field Values
-
-
- -

-IDAT

-
-public static final int IDAT
-
-
Image data -

-

-
See Also:
Constant Field Values
-
-
- -

-IEND

-
-public static final int IEND
-
-
Image trailer -

-

-
See Also:
Constant Field Values
-
-
- -

-bKGD

-
-public static final int bKGD
-
-
Background color -

-

-
See Also:
Constant Field Values
-
-
- -

-cHRM

-
-public static final int cHRM
-
-
Primary chromaticities -

-

-
See Also:
Constant Field Values
-
-
- -

-gAMA

-
-public static final int gAMA
-
-
Image gamma -

-

-
See Also:
Constant Field Values
-
-
- -

-hIST

-
-public static final int hIST
-
-
Palette histogram -

-

-
See Also:
Constant Field Values
-
-
- -

-iCCP

-
-public static final int iCCP
-
-
Embedded ICC profile -

-

-
See Also:
Constant Field Values
-
-
- -

-iTXt

-
-public static final int iTXt
-
-
International textual data -

-

-
See Also:
Constant Field Values
-
-
- -

-pHYs

-
-public static final int pHYs
-
-
Physical pixel dimensions -

-

-
See Also:
Constant Field Values
-
-
- -

-sBIT

-
-public static final int sBIT
-
-
Significant bits -

-

-
See Also:
Constant Field Values
-
-
- -

-sPLT

-
-public static final int sPLT
-
-
Suggested palette -

-

-
See Also:
Constant Field Values
-
-
- -

-sRGB

-
-public static final int sRGB
-
-
Standard RGB color space -

-

-
See Also:
Constant Field Values
-
-
- -

-tEXt

-
-public static final int tEXt
-
-
Textual data -

-

-
See Also:
Constant Field Values
-
-
- -

-tIME

-
-public static final int tIME
-
-
Image last-modification time -

-

-
See Also:
Constant Field Values
-
-
- -

-tRNS

-
-public static final int tRNS
-
-
Transparency -

-

-
See Also:
Constant Field Values
-
-
- -

-zTXt

-
-public static final int zTXt
-
-
Compressed textual data -

-

-
See Also:
Constant Field Values
-
-
- -

-oFFs

-
-public static final int oFFs
-
-
Image offset -

-

-
See Also:
Constant Field Values
-
-
- -

-pCAL

-
-public static final int pCAL
-
-
Calibration of pixel values -

-

-
See Also:
Constant Field Values
-
-
- -

-sCAL

-
-public static final int sCAL
-
-
Physical scale of image subject -

-

-
See Also:
Constant Field Values
-
-
- -

-gIFg

-
-public static final int gIFg
-
-
GIF Graphic Control Extension -

-

-
See Also:
Constant Field Values
-
-
- -

-gIFx

-
-public static final int gIFx
-
-
GIF Application Extension -

-

-
See Also:
Constant Field Values
-
-
- -

-sTER

-
-public static final int sTER
-
-
Indicator of Stereo Image -

-

-
See Also:
Constant Field Values
-
-
- -

-BIT_DEPTH

-
-public static final String BIT_DEPTH
-
-
IHDR: Bit depth -

-

-
See Also:
Constant Field Values
-
-
- -

-COLOR_TYPE

-
-public static final String COLOR_TYPE
-
-
IHDR: Color type -

-

-
See Also:
Constant Field Values
-
-
- -

-COMPRESSION

-
-public static final String COMPRESSION
-
-
IHDR: Compression method -

-

-
See Also:
Constant Field Values
-
-
- -

-FILTER

-
-public static final String FILTER
-
-
IHDR: Filter method -

-

-
See Also:
Constant Field Values
-
-
- -

-GAMMA

-
-public static final String GAMMA
-
-
gAMA: Gamma -

-

-
See Also:
Constant Field Values
-
-
- -

-WIDTH

-
-public static final String WIDTH
-
-
IHDR: Width -

-

-
See Also:
Constant Field Values
-
-
- -

-HEIGHT

-
-public static final String HEIGHT
-
-
IHDR: Height -

-

-
See Also:
Constant Field Values
-
-
- -

-INTERLACE

-
-public static final String INTERLACE
-
-
IHDR: Interlace method -

-

-
See Also:
Constant Field Values
-
-
- -

-PALETTE

-
-public static final String PALETTE
-
-
PLTE: Palette entries -

-

-
See Also:
Constant Field Values
-
-
- -

-PALETTE_ALPHA

-
-public static final String PALETTE_ALPHA
-
-
PLTE: Palette alpha -

-

-
See Also:
Constant Field Values
-
-
- -

-TRANSPARENCY

-
-public static final String TRANSPARENCY
-
-
tRNS: Transparency samples -

-

-
See Also:
Constant Field Values
-
-
- -

-BACKGROUND

-
-public static final String BACKGROUND
-
-
bKGD: Background samples -

-

-
See Also:
Constant Field Values
-
-
- -

-PIXELS_PER_UNIT_X

-
-public static final String PIXELS_PER_UNIT_X
-
-
pHYs: Pixels per unit, X axis -

-

-
See Also:
Constant Field Values
-
-
- -

-PIXELS_PER_UNIT_Y

-
-public static final String PIXELS_PER_UNIT_Y
-
-
pHYs: Pixels per unit, Y axis -

-

-
See Also:
Constant Field Values
-
-
- -

-RENDERING_INTENT

-
-public static final String RENDERING_INTENT
-
-
sRGB: Rendering intent -

-

-
See Also:
Constant Field Values
-
-
- -

-SIGNIFICANT_BITS

-
-public static final String SIGNIFICANT_BITS
-
-
sBIT: Significant bits -

-

-
See Also:
Constant Field Values
-
-
- -

-TEXT_CHUNKS

-
-public static final String TEXT_CHUNKS
-
-
tEXt/zTXt/iTXt: List of text chunks -

-

-
See Also:
Constant Field Values
-
-
- -

-TIME

-
-public static final String TIME
-
-
tIME: Image last-modification time -

-

-
See Also:
Constant Field Values
-
-
- -

-UNIT

-
-public static final String UNIT
-
-
pHYs: Unit specifier -

-

-
See Also:
Constant Field Values
-
-
- -

-CHROMATICITY

-
-public static final String CHROMATICITY
-
-
cHRM: Chromaticity -

-

-
See Also:
Constant Field Values
-
-
- -

-ICC_PROFILE

-
-public static final String ICC_PROFILE
-
-
iCCP: ICC profile -

-

-
See Also:
Constant Field Values
-
-
- -

-ICC_PROFILE_NAME

-
-public static final String ICC_PROFILE_NAME
-
-
iCCP: ICC profile name -

-

-
See Also:
Constant Field Values
-
-
- -

-HISTOGRAM

-
-public static final String HISTOGRAM
-
-
hIST: Palette histogram -

-

-
See Also:
Constant Field Values
-
-
- -

-SUGGESTED_PALETTES

-
-public static final String SUGGESTED_PALETTES
-
-
sPLT: List of suggested palettes -

-

-
See Also:
Constant Field Values
-
-
- -

-GIF_DISPOSAL_METHOD

-
-public static final String GIF_DISPOSAL_METHOD
-
-
gIFg: GIF disposal method -

-

-
See Also:
Constant Field Values
-
-
- -

-GIF_USER_INPUT_FLAG

-
-public static final String GIF_USER_INPUT_FLAG
-
-
gIFg: GIF user input flag -

-

-
See Also:
Constant Field Values
-
-
- -

-GIF_DELAY_TIME

-
-public static final String GIF_DELAY_TIME
-
-
gIFg: GIF delay time (hundredths of a second) -

-

-
See Also:
Constant Field Values
-
-
- -

-SCALE_UNIT

-
-public static final String SCALE_UNIT
-
-
sCAL: Unit for physical scale of image subject -

-

-
See Also:
Constant Field Values
-
-
- -

-PIXEL_WIDTH

-
-public static final String PIXEL_WIDTH
-
-
sCAL: Physical width of pixel -

-

-
See Also:
Constant Field Values
-
-
- -

-PIXEL_HEIGHT

-
-public static final String PIXEL_HEIGHT
-
-
sCAL: Physical height of pixel -

-

-
See Also:
Constant Field Values
-
-
- -

-POSITION_UNIT

-
-public static final String POSITION_UNIT
-
-
oFFs: Unit for image offset -

-

-
See Also:
Constant Field Values
-
-
- -

-STEREO_MODE

-
-public static final String STEREO_MODE
-
-
sTER: Indicator of stereo image -

-

-
See Also:
Constant Field Values
-
-
- -

-COLOR_TYPE_GRAY

-
-public static final int COLOR_TYPE_GRAY
-
-
IHDR: Grayscale color type -

-

-
See Also:
Constant Field Values
-
-
- -

-COLOR_TYPE_GRAY_ALPHA

-
-public static final int COLOR_TYPE_GRAY_ALPHA
-
-
IHDR: Grayscale+alpha color type -

-

-
See Also:
Constant Field Values
-
-
- -

-COLOR_TYPE_PALETTE

-
-public static final int COLOR_TYPE_PALETTE
-
-
IHDR: Palette color type -

-

-
See Also:
Constant Field Values
-
-
- -

-COLOR_TYPE_RGB

-
-public static final int COLOR_TYPE_RGB
-
-
IHDR: RGB color type -

-

-
See Also:
Constant Field Values
-
-
- -

-COLOR_TYPE_RGB_ALPHA

-
-public static final int COLOR_TYPE_RGB_ALPHA
-
-
IHDR: RGBA color type -

-

-
See Also:
Constant Field Values
-
-
- -

-INTERLACE_NONE

-
-public static final int INTERLACE_NONE
-
-
IHDR: No interlace -

-

-
See Also:
Constant Field Values
-
-
- -

-INTERLACE_ADAM7

-
-public static final int INTERLACE_ADAM7
-
-
IHDR: Adam7 interlace -

-

-
See Also:
Constant Field Values
-
-
- -

-FILTER_BASE

-
-public static final int FILTER_BASE
-
-
IHDR: Adaptive filtering -

-

-
See Also:
Constant Field Values
-
-
- -

-COMPRESSION_BASE

-
-public static final int COMPRESSION_BASE
-
-
IHDR: Deflate/inflate compression -

-

-
See Also:
Constant Field Values
-
-
- -

-UNIT_UNKNOWN

-
-public static final int UNIT_UNKNOWN
-
-
pHYs: Unit is unknown -

-

-
See Also:
Constant Field Values
-
-
- -

-UNIT_METER

-
-public static final int UNIT_METER
-
-
pHYs: Unit is the meter -

-

-
See Also:
Constant Field Values
-
-
- -

-SRGB_PERCEPTUAL

-
-public static final int SRGB_PERCEPTUAL
-
-
sRGB: Perceptual rendering intent -

-

-
See Also:
Constant Field Values
-
-
- -

-SRGB_RELATIVE_COLORIMETRIC

-
-public static final int SRGB_RELATIVE_COLORIMETRIC
-
-
sRGB: Relative colorimetric rendering intent -

-

-
See Also:
Constant Field Values
-
-
- -

-SRGB_SATURATION_PRESERVING

-
-public static final int SRGB_SATURATION_PRESERVING
-
-
sRGB: Saturation rendering intent -

-

-
See Also:
Constant Field Values
-
-
- -

-SRGB_ABSOLUTE_COLORIMETRIC

-
-public static final int SRGB_ABSOLUTE_COLORIMETRIC
-
-
sRGB: Absolute colormetric rendering intent -

-

-
See Also:
Constant Field Values
-
-
- -

-POSITION_X

-
-public static final String POSITION_X
-
-
oFFs: Image X position -

-

-
See Also:
Constant Field Values
-
-
- -

-POSITION_Y

-
-public static final String POSITION_Y
-
-
oFFs: Image Y position -

-

-
See Also:
Constant Field Values
-
-
- -

-POSITION_UNIT_PIXEL

-
-public static final int POSITION_UNIT_PIXEL
-
-
oFFs: Unit is the pixel (true dimensions unspecified) -

-

-
See Also:
Constant Field Values
-
-
- -

-POSITION_UNIT_MICROMETER

-
-public static final int POSITION_UNIT_MICROMETER
-
-
oFFs: Unit is the micrometer (10^-6 meter) -

-

-
See Also:
Constant Field Values
-
-
- -

-SCALE_UNIT_METER

-
-public static final int SCALE_UNIT_METER
-
-
sCAL: Unit is the meter -

-

-
See Also:
Constant Field Values
-
-
- -

-SCALE_UNIT_RADIAN

-
-public static final int SCALE_UNIT_RADIAN
-
-
sCAL: Unit is the radian -

-

-
See Also:
Constant Field Values
-
-
- -

-STEREO_MODE_CROSS

-
-public static final int STEREO_MODE_CROSS
-
-
sTER: Cross-fuse layout -

-

-
See Also:
Constant Field Values
-
-
- -

-STEREO_MODE_DIVERGING

-
-public static final int STEREO_MODE_DIVERGING
-
-
sTER: Diverging-fuse layout -

-

-
See Also:
Constant Field Values
-
- - - - - - - - -
-Constructor Detail
- -

-PngConstants

-
-public PngConstants()
-
-
- - - - - - - - -
-Method Detail
- -

-isAncillary

-
-public static boolean isAncillary(int chunkType)
-
-
Returns true if the given chunk type has the ancillary bit set - (the first letter is lowercase). - An ancillary chunk is once which is not strictly necessary - in order to meaningfully display the contents of the file. -

-

-
Parameters:
chunkType - the chunk type -
Returns:
whether the chunk type ancillary bit is set
-
-
-
- -

-isPrivate

-
-public static boolean isPrivate(int chunkType)
-
-
Returns true if the given chunk type has the private bit set - (the second letter is lowercase). - All unregistered chunk types should have this bit set. -

-

-
Parameters:
chunkType - the chunk type -
Returns:
whether the chunk type private bit is set
-
-
-
- -

-isReserved

-
-public static boolean isReserved(int chunkType)
-
-
Returns true if the given chunk type has the reserved bit set - (the third letter is lowercase). - The meaning of this bit is currently undefined, but reserved for future use. - Images conforming to the current version of the PNG specification must - not have this bit set. -

-

-
Parameters:
chunkType - the chunk type -
Returns:
whether the chunk type reserved bit is set
-
-
-
- -

-isSafeToCopy

-
-public static boolean isSafeToCopy(int chunkType)
-
-
Returns true if the given chunk type has the safe-to-copy bit set - (the fourth letter is lowercase). - Chunks marked as safe-to-copy may be copied to a modified PNG file - whether or not the software recognizes the chunk type. -

-

-
Parameters:
chunkType - the chunk type -
Returns:
whether the chunk safe-to-copy bit is set
-
-
-
- -

-getChunkName

-
-public static String getChunkName(int chunkType)
-
-
Returns the four-character ASCII name corresponding to the given - chunk type. For example, PngConstants.getChunkName(PngConstants.IHDR) will - return "IHDR". -

-

-
Parameters:
chunkType - the chunk type -
Returns:
the four-character ASCII chunk name
-
-
-
- -

-getChunkType

-
-public static int getChunkType(String chunkName)
-
-
Returns the chunk type corresponding to the given four-character - ASCII chunk name. -

-

-
Parameters:
chunkName - the four-character ASCII chunk name -
Returns:
the chunk type -
Throws: -
NullPointerException - if name is null -
IndexOutOfBoundsException - if name has less than four characters
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/PngException.html b/javapng2/javadoc/com/sixlegs/png/PngException.html deleted file mode 100644 index b2b1625..0000000 --- a/javapng2/javadoc/com/sixlegs/png/PngException.html +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - -PngException - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -com.sixlegs.png -
-Class PngException

-
-java.lang.Object
-  extended by java.lang.Throwable
-      extended by java.lang.Exception
-          extended by java.io.IOException
-              extended by com.sixlegs.png.PngException
-
-
-
All Implemented Interfaces:
Serializable
-
-
-
-
public class PngException
extends IOException
- - -

-The superclass for all decoding exceptions. -

- -

-

-
See Also:
Serialized Form
-
- -

- - - - - - - - - - - - -
-Method Summary
- booleanisFatal() - -
-          Returns true if this exception represents a fatal decoding error.
- - - - - - - -
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- - - - - - - -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-  -

- - - - - - - - -
-Method Detail
- -

-isFatal

-
-public boolean isFatal()
-
-
Returns true if this exception represents a fatal decoding error. - Most errors in non-ancillary chunks are fatal. -

-

-
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/PngImage.html b/javapng2/javadoc/com/sixlegs/png/PngImage.html deleted file mode 100644 index afa6615..0000000 --- a/javapng2/javadoc/com/sixlegs/png/PngImage.html +++ /dev/null @@ -1,1085 +0,0 @@ - - - - - - -PngImage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -com.sixlegs.png -
-Class PngImage

-
-java.lang.Object
-  extended by com.sixlegs.png.PngImage
-
-
-
All Implemented Interfaces:
Transparency
-
-
-
-
public class PngImage
extends Object
implements Transparency
- - -

-A class to decode PNG images. - The simplest use is if only a decoded BufferedImage is required: -

BufferedImage image = new PngImage().read(new java.io.File("test.png"));
- The PngImage instance used to read the image also stores all of the - image metadata. For customized PNG decoding, a PngConfig object - may be passed to the constructor. -

- This class is not thread-safe. Do not share a PngImage instance - among multiple threads without proper synchronization. -

- For more information visit http://www.sixlegs.com/ -

- -

-

-
Author:
-
Chris Nokleberg <chris@sixlegs.com>
-
See Also:
PngConfig
-
- -

- - - - - - - -
-Field Summary
- - - - - - - -
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
-  - - - - - - - - - - - - - -
-Constructor Summary
PngImage() - -
-          Constructor which uses a default instance of PngConfig.
PngImage(PngConfig config) - -
-          Constructor which uses the specified configuration.
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
-protected  BufferedImagecreateImage(InputStream in, - Dimension size) - -
-          A hook by which subclasses can access or manipulate the raw image data.
- ColorgetBackground() - -
-          Returns the background color explicitly encoded in the image.
- intgetBitDepth() - -
-          Returns the image bit depth.
- intgetColorType() - -
-          Returns the image color type.
- PngConfiggetConfig() - -
-          Returns the configuration used by this object.
- floatgetGamma() - -
-          Returns the gamma exponent that was explicitly encoded in the image, - if there was one, or the value of PngConfig.getDefaultGamma() otherwise.
- short[]getGammaTable() - -
-          Returns a gamma table which can be used for custom gamma correction.
- intgetHeight() - -
-          Returns the image height in pixels.
- MapgetProperties() - -
-          Returns the map which stores all of this image's property values.
- ObjectgetProperty(String name) - -
-          Returns a per-image property by name.
- intgetSamples() - -
-          Returns the number of samples per pixel.
- TextChunkgetTextChunk(String key) - -
-          Returns a text chunk that uses the given keyword, if one exists.
- intgetTransparency() - -
-          Returns the type of this Transparency.
- intgetWidth() - -
-          Returns the image widt hin pixels.
-protected  booleanhandlePass(BufferedImage image, - int pass) - -
-          A method which subclasses may override to take some action - after each pass has been decoded.
-protected  booleanhandleProgress(BufferedImage image, - float pct) - -
-          Reports the approximate degree of completion of the current read - call.
-protected  voidhandleWarning(PngException e) - -
-          Callback for customized handling of warnings.
- booleanisInterlaced() - -
-          Returns true if the image interlace type (PngConstants.INTERLACE) - is something other than INTERLACE_NONE.
-protected  booleanisMultipleOK(int type) - -
-          Returns whether a chunk is allowed to occur multiple times.
- BufferedImageread(File file) - -
-          Reads a PNG image from the specified file.
- BufferedImageread(InputStream in, - boolean close) - -
-          Reads a PNG image from the specified input stream.
-protected  voidreadChunk(int type, - DataInput in, - long offset, - int length) - -
-          Read the chunk data from the image input stream, storing - properties into this PngImage instance.
- - - - - - - -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Constructor Detail
- -

-PngImage

-
-public PngImage()
-
-
Constructor which uses a default instance of PngConfig. -

-

-
- -

-PngImage

-
-public PngImage(PngConfig config)
-
-
Constructor which uses the specified configuration. -

-

- - - - - - - - -
-Method Detail
- -

-getConfig

-
-public PngConfig getConfig()
-
-
Returns the configuration used by this object. -

-

-
-
-
- -
Returns:
the PngConfig instance used by this object
-
-
-
- -

-read

-
-public BufferedImage read(File file)
-                   throws IOException
-
-
Reads a PNG image from the specified file. Image metadata will - be stored in the property map of this PngImage instance, - for retrieval via the various helper methods (getWidth(), getHeight(), etc.) - and getProperty(java.lang.String). The decoded image itself is returned by this - method but not cached. -

- If PngConfig.getReadLimit() is anything but PngConfig.READ_ALL, - then this method will return null instead of the decoded image. -

- Multiple images can be read using the same PngImage instance. - The property map is cleared each time this method is called. -

-

-
-
-
-
Parameters:
file - the file to read -
Returns:
the decoded image, or null if no image was decoded -
Throws: -
IOException - if any error occurred while reading the image
See Also:
read(java.io.InputStream, boolean), -createImage(java.io.InputStream, java.awt.Dimension), -handlePass(java.awt.image.BufferedImage, int)
-
-
-
- -

-read

-
-public BufferedImage read(InputStream in,
-                          boolean close)
-                   throws IOException
-
-
Reads a PNG image from the specified input stream. Image metadata will - be stored in the property map of this PngImage instance, - for retrieval via the various helper methods (getWidth(), getHeight(), etc.) - and getProperty(java.lang.String). The decoded image itself is returned by this - method but not cached. -

- If PngConfig.getReadLimit() is anything but PngConfig.READ_ALL, - then this method will return null instead of the decoded image. -

- Multiple images can be read using the same PngImage instance. - A new property map is created each time this method is called. -

-

-
-
-
-
Parameters:
in - the input stream to read
close - whether to close the input stream after reading -
Returns:
the decoded image, or null if no image was decoded -
Throws: -
IOException - if any error occurred while reading the image
See Also:
read(java.io.File), -createImage(java.io.InputStream, java.awt.Dimension), -handlePass(java.awt.image.BufferedImage, int)
-
-
-
- -

-createImage

-
-protected BufferedImage createImage(InputStream in,
-                                    Dimension size)
-                             throws IOException
-
-
A hook by which subclasses can access or manipulate the raw image data. - All of the raw, compressed image data contained in the IDAT chunks - of the PNG image being read is concatenated and passed to this method - as a single input stream. The returned image will become the return value - of the calling read(java.io.File) or read(java.io.InputStream, boolean) - method. -

- Unlike readChunk(int, java.io.DataInput, long, int) implementations, subclasses may read less than the correct - amount from this stream; the remainder will be skipped. -

-

-
-
-
-
Parameters:
in - the input stream of raw, compressed image data
size - the size of the image data -
Returns:
the decoded image, or null -
Throws: -
IOException - if any error occurred while processing the image data
-
-
-
- -

-handlePass

-
-protected boolean handlePass(BufferedImage image,
-                             int pass)
-
-
A method which subclasses may override to take some action - after each pass has been decoded. An interlaced image has seven - passes, and non-interlaced image only one. The pass - arguments indicates the index of the completed - pass, starting with zero. -

- For interlaced images, the state of the image data before the last - pass is affected by the value of PngConfig.getProgressive(). -

- Image decoding can be aborted by returning false. The default - implementation always returns true. -

-

-
-
-
-
Parameters:
image - the partially or fully decoded image
pass - the index of the completed pass -
Returns:
false to abort image decoding
-
-
-
- -

-handleProgress

-
-protected boolean handleProgress(BufferedImage image,
-                                 float pct)
-
-
Reports the approximate degree of completion of the current read - call. This method is called periodically during - image decoding. The degree of completion is expressed as a percentage - varying from 0.0F to 100.0F, and is calculated using the number - of pixels decoded. -

- Image decoding can be aborted by returning false. The default - implementation returns true. -

-

-
-
-
-
Parameters:
image - the partially or fully decoded image
pct - the approximate percentage of decoding that has been completed -
Returns:
false to abort image decoding
-
-
-
- -

-handleWarning

-
-protected void handleWarning(PngException e)
-                      throws PngException
-
-
Callback for customized handling of warnings. Whenever a - non-fatal error is found, an instance of PngException is - created and passed to this method. To signal that the exception - should be treated as a fatal exception (and abort image - processing), an implementation should re-throw the exception. -

- By default, this method will re-throw the warning if the - warningsFatal property is true. -

-

-
-
-
- -
Throws: -
PngException - if the warning should be treated as fatal
-
-
-
- -

-getWidth

-
-public int getWidth()
-
-
Returns the image widt hin pixels. -

-

-
-
-
- -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getHeight

-
-public int getHeight()
-
-
Returns the image height in pixels. -

-

-
-
-
- -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getBitDepth

-
-public int getBitDepth()
-
-
Returns the image bit depth. -

-

-
-
-
- -
Returns:
1, 2, 4, 8, or 16 -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-isInterlaced

-
-public boolean isInterlaced()
-
-
Returns true if the image interlace type (PngConstants.INTERLACE) - is something other than INTERLACE_NONE. -

-

-
-
-
- -
Returns:
true if the image is interlaced -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getColorType

-
-public int getColorType()
-
-
Returns the image color type. -

-

-
-
-
- -
Returns:
COLOR_TYPE_GRAY,
- COLOR_TYPE_GRAY_ALPHA,
- COLOR_TYPE_PALETTE,
- COLOR_TYPE_RGB,
- or COLOR_TYPE_RGB_ALPHA -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getTransparency

-
-public int getTransparency()
-
-
Returns the type of this Transparency. -

-

-
Specified by:
getTransparency in interface Transparency
-
-
- -
Returns:
the field type of this Transparency, which is either OPAQUE, BITMASK or TRANSLUCENT. -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getSamples

-
-public int getSamples()
-
-
Returns the number of samples per pixel. Gray and paletted - images use one sample, gray+alpha uses two, RGB uses three, - and RGB+alpha uses four. -

-

-
-
-
- -
Returns:
1, 2, 3 or 4 -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getGamma

-
-public float getGamma()
-
-
Returns the gamma exponent that was explicitly encoded in the image, - if there was one, or the value of PngConfig.getDefaultGamma() otherwise. -

-

-
-
-
- -
Returns:
the gamma exponent -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getGammaTable

-
-public short[] getGammaTable()
-
-
Returns a gamma table which can be used for custom gamma correction. - The table is 256 entries unless the bit depth is 16 and - PngConfig.getReduce16() is false, in which - case the table is 65535 entries. -

- The values in the table take into account getGamma() and - PngConfig.getDisplayExponent(). -

-

-
-
-
- -
Returns:
a table of component values to be used in gamma correction -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getBackground

-
-public Color getBackground()
-
-
Returns the background color explicitly encoded in the image. - For 16-bit images the components are reduced to 8-bit by shifting. -

-

-
-
-
- -
Returns:
the background color, or null -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getProperty

-
-public Object getProperty(String name)
-
-
Returns a per-image property by name. All common property names are defined in - PngConstants; their types are listed in the following table. - The use of the various helper methods defined in this class, such as getBackground(), - is normally preferrable to working with the raw property values. -

-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
BIT_DEPTHIntegerBit depth
COLOR_TYPEIntegerColor type
COMPRESSIONIntegerCompression method
FILTERIntegerFilter method
GAMMAFloatGamma
WIDTHIntegerWidth
HEIGHTIntegerHeight
INTERLACEIntegerInterlace method
PALETTEbyte[]Palette entries
PALETTE_ALPHAbyte[]Palette alpha
TRANSPARENCYint[]Transparency samples
BACKGROUNDint[]Background samples
PIXELS_PER_UNIT_XIntegerPixels per unit, X axis
PIXELS_PER_UNIT_YIntegerPixels per unit, Y axis
UNITIntegerUnit specifier
RENDERING_INTENTIntegerRendering intent
SIGNIFICANT_BITSbyte[]Significant bits
TEXT_CHUNKSListList of text chunks
TIMEDateImage last-modification time
CHROMATICITYfloat[]Chromaticity
ICC_PROFILEbyte[]ICC profile
ICC_PROFILE_NAMEStringICC profile name
HISTOGRAMint[]Palette histogram
SUGGESTED_PALETTESListList of suggested palettes
GIF_DISPOSAL_METHODIntegerGIF disposal method
GIF_USER_INPUT_FLAGIntegerGIF user input flag
GIF_DELAY_TIMEIntegerGIF delay time (hundredths of a second)
SCALE_UNITIntegerUnit for physical scale of image subject
PIXEL_WIDTHDoublePhysical width of pixel
PIXEL_HEIGHTDoublePhysical height of pixel
POSITION_UNITIntegerUnit for image offset
STEREO_MODEIntegerIndicator of stereo image
-

-

-
-
-
-
Parameters:
name - a property name -
Returns:
the property value, or null if no such property exists -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-getProperties

-
-public Map getProperties()
-
-
Returns the map which stores all of this image's property values. - The map is mutable, and storing a value with the wrong type may - result in other methods in this class throwing IllegalStateException or - ClassCastException. -

-

-
-
-
- -
Returns:
the mutable map of image properties
-
-
-
- -

-getTextChunk

-
-public TextChunk getTextChunk(String key)
-
-
Returns a text chunk that uses the given keyword, if one exists. - If multiple text chunks share the same keyword, this method - will return the first one that was read. The full list of text - chunks may be accessed by calling -
getProperty(PngConstants.TEXT_CHUNKS)
-

-

-
-
-
-
Parameters:
key - the text chunk keyword -
Returns:
a TextChunk implementation, or null -
Throws: -
IllegalStateException - if an image has not been read
-
-
-
- -

-readChunk

-
-protected void readChunk(int type,
-                         DataInput in,
-                         long offset,
-                         int length)
-                  throws IOException
-
-
Read the chunk data from the image input stream, storing - properties into this PngImage instance. -

- By default this method will handle all of the chunk types defined - in Version 1.2 of the PNG Specification, and most of the - registered extension chunks. - IDAT chunks will be processed through this method only if - PngConfig.getReadLimit() is set to PngConfig.READ_EXCEPT_DATA. -

- Attempting to read past the end of the chunk data will result in - an EOFException. Unread data will be skipped. -

-

-
-
-
-
Parameters:
type - the chunk type
in - the chunk data
offset - the location of the chunk data within the entire PNG datastream
length - the length of the chunk data -
Throws: -
IOException
-
-
-
- -

-isMultipleOK

-
-protected boolean isMultipleOK(int type)
-
-
Returns whether a chunk is allowed to occur multiple times. -

- By default this method returns true only for sPLT, - iTXt, tEXt, - zTXt, and IDAT. -

-

-
-
-
-
Parameters:
type - the chunk type -
Returns:
whether multiple chunks of the given type are allowed
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/SuggestedPalette.html b/javapng2/javadoc/com/sixlegs/png/SuggestedPalette.html deleted file mode 100644 index f7cbe5f..0000000 --- a/javapng2/javadoc/com/sixlegs/png/SuggestedPalette.html +++ /dev/null @@ -1,312 +0,0 @@ - - - - - - -SuggestedPalette - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -com.sixlegs.png -
-Interface SuggestedPalette

-
-
-
public interface SuggestedPalette
- - -

-A suggested palette. Suggested palettes can be useful - when the display device is not capable of displaying - the full range of colors present in the image. -

- -

-

-
See Also:
PngImage.getProperty(java.lang.String), -PngConstants.SUGGESTED_PALETTES
-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- intgetFrequency(int index) - -
-          Retrieve a sample frequency value.
- StringgetName() - -
-          Returns palette name.
- voidgetSample(int index, - short[] pixel) - -
-          Retrieve a sample value.
- intgetSampleCount() - -
-          Returns the number of samples.
- intgetSampleDepth() - -
-          Returns the sample depth.
-  -

- - - - - - - - -
-Method Detail
- -

-getName

-
-String getName()
-
-
Returns palette name. This is any convenient name for - referring to the palette. The name will be unique across all - suggested palettes in the same image. -

-

-
-
-
-
- -

-getSampleCount

-
-int getSampleCount()
-
-
Returns the number of samples. -

-

-
-
-
-
- -

-getSampleDepth

-
-int getSampleDepth()
-
-
Returns the sample depth. This specifies the width of each color and alpha component - of each sample in this palette. -

-

- -
Returns:
8 or 16
-
-
-
- -

-getSample

-
-void getSample(int index,
-               short[] pixel)
-
-
Retrieve a sample value. The red, green, blue, and alpha components of the sample - at the given index are stored into the short array. Each component is of the depth - specified by getSampleDepth. The color samples are not - premultiplied by alpha. An alpha value of 0 means fully transparent. -

-

-
Parameters:
index - the sample index
pixel - the array in which to store the sample components -
Throws: -
IndexOutOfBoundsException - if index < 0, index >= getSampleCount, or - pixel.length is less than 4 -
NullPointerException - if pixel is null
-
-
-
- -

-getFrequency

-
-int getFrequency(int index)
-
-
Retrieve a sample frequency value. The frequency value is proportional to the - fraction of pixels in the image that are closest to that palette entry in RGBA - space. The range of individual values will reasonably fill 0 to 65535. - Entries appear in decreasing order of frequency. -

-

-
Parameters:
index - the sample index
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/TextChunk.html b/javapng2/javadoc/com/sixlegs/png/TextChunk.html deleted file mode 100644 index 83b5eb7..0000000 --- a/javapng2/javadoc/com/sixlegs/png/TextChunk.html +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - -TextChunk - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -com.sixlegs.png -
-Interface TextChunk

-
-
-
public interface TextChunk
- - -

-Common interface to all PNG text chunk data (tEXt, - zTXt, iTXt). -

- -

-

-
See Also:
PngImage.getTextChunk(java.lang.String)
-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- StringgetKeyword() - -
-          Returns the Latin-1 (ISO-8859-1) encoded keyword - of this TextChunk.
- StringgetLanguage() - -
-          Returns the language (RFC-1766) used by the translated - keyword and the text, or null if unspecified.
- StringgetText() - -
-          Returns the text of this TextChunk.
- StringgetTranslatedKeyword() - -
-          Returns a translation of the keyword into the language - used by this TextChunk, or null if unspecified.
- intgetType() - -
-          Returns the type of this TextChunk.
-  -

- - - - - - - - -
-Method Detail
- -

-getKeyword

-
-String getKeyword()
-
-
Returns the Latin-1 (ISO-8859-1) encoded keyword - of this TextChunk. -

-

-
-
-
-
- -

-getTranslatedKeyword

-
-String getTranslatedKeyword()
-
-
Returns a translation of the keyword into the language - used by this TextChunk, or null if unspecified. -

-

-
-
-
-
- -

-getLanguage

-
-String getLanguage()
-
-
Returns the language (RFC-1766) used by the translated - keyword and the text, or null if unspecified. -

-

-
-
-
-
- -

-getText

-
-String getText()
-
-
Returns the text of this TextChunk. -

-

-
-
-
-
- -

-getType

-
-int getType()
-
-
Returns the type of this TextChunk. -

-

- -
Returns:
PngConstants.tEXt,
- PngConstants.zTXt,
- or PngConstants.iTXt
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/class-use/PngConfig.Builder.html b/javapng2/javadoc/com/sixlegs/png/class-use/PngConfig.Builder.html deleted file mode 100644 index bdecdce..0000000 --- a/javapng2/javadoc/com/sixlegs/png/class-use/PngConfig.Builder.html +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - -Uses of Class com.sixlegs.png.PngConfig.Builder - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Uses of Class
com.sixlegs.png.PngConfig.Builder

-
- - - - - -
-Uses of PngConfig.Builder in com.sixlegs.png
-  -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Methods in com.sixlegs.png that return PngConfig.Builder
- PngConfig.BuilderPngConfig.Builder.convertIndexed(boolean convertIndexed) - -
-          Whether to convert images with an indexed color model - (paletted and 1/2/4/8-bit grayscale) to use a component color model.
- PngConfig.BuilderPngConfig.Builder.defaultGamma(float defaultGamma) - -
-          Sets the default gamma value.
- PngConfig.BuilderPngConfig.Builder.displayExponent(float displayExponent) - -
-          Sets the default display exponent.
- PngConfig.BuilderPngConfig.Builder.gammaCorrect(boolean gammaCorrect) - -
-          Enables or disables gamma correction.
- PngConfig.BuilderPngConfig.Builder.progressive(boolean progressive) - -
-          Enables or disables progressive display for interlaced images.
- PngConfig.BuilderPngConfig.Builder.readLimit(int readLimit) - -
-          Configures how much of the image to read.
- PngConfig.BuilderPngConfig.Builder.reduce16(boolean reduce16) - -
-          Enables or disables 16-bit reduction.
- PngConfig.BuilderPngConfig.Builder.sourceRegion(Rectangle sourceRegion) - -
-          Decode only a particular region of the source image.
- PngConfig.BuilderPngConfig.Builder.sourceSubsampling(int xsub, - int ysub, - int xoff, - int yoff) - -
-          Reduce the size of the decoded image (or source region) by only using - periodic rows and/or columns of the image.
- PngConfig.BuilderPngConfig.Builder.warningsFatal(boolean warningsFatal) - -
-          Configures whether warnings should be treated as fatal errors.
-  -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/class-use/PngConfig.html b/javapng2/javadoc/com/sixlegs/png/class-use/PngConfig.html deleted file mode 100644 index 2bd8b19..0000000 --- a/javapng2/javadoc/com/sixlegs/png/class-use/PngConfig.html +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - -Uses of Class com.sixlegs.png.PngConfig - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Uses of Class
com.sixlegs.png.PngConfig

-
- - - - - -
-Uses of PngConfig in com.sixlegs.png
-  -

- - - - - - - - - - - - - -
Methods in com.sixlegs.png that return PngConfig
- PngConfigPngConfig.Builder.build() - -
-          Create a configuration using the current values of this builder.
- PngConfigPngImage.getConfig() - -
-          Returns the configuration used by this object.
-  -

- - - - - - - - - - - -
Constructors in com.sixlegs.png with parameters of type PngConfig
PngConfig.Builder(PngConfig cfg) - -
-          Create a builder using values from the given configuration.
PngImage(PngConfig config) - -
-          Constructor which uses the specified configuration.
-  -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/class-use/PngConstants.html b/javapng2/javadoc/com/sixlegs/png/class-use/PngConstants.html deleted file mode 100644 index 20542f4..0000000 --- a/javapng2/javadoc/com/sixlegs/png/class-use/PngConstants.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - -Uses of Class com.sixlegs.png.PngConstants - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Uses of Class
com.sixlegs.png.PngConstants

-
-No usage of com.sixlegs.png.PngConstants -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/class-use/PngException.html b/javapng2/javadoc/com/sixlegs/png/class-use/PngException.html deleted file mode 100644 index fc32d5c..0000000 --- a/javapng2/javadoc/com/sixlegs/png/class-use/PngException.html +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - -Uses of Class com.sixlegs.png.PngException - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Uses of Class
com.sixlegs.png.PngException

-
- - - - - -
-Uses of PngException in com.sixlegs.png
-  -

- - - - - - - - - -
Methods in com.sixlegs.png with parameters of type PngException
-protected  voidPngImage.handleWarning(PngException e) - -
-          Callback for customized handling of warnings.
-  -

- - - - - - - - - -
Methods in com.sixlegs.png that throw PngException
-protected  voidPngImage.handleWarning(PngException e) - -
-          Callback for customized handling of warnings.
-  -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/class-use/PngImage.html b/javapng2/javadoc/com/sixlegs/png/class-use/PngImage.html deleted file mode 100644 index ff61a5f..0000000 --- a/javapng2/javadoc/com/sixlegs/png/class-use/PngImage.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - -Uses of Class com.sixlegs.png.PngImage - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Uses of Class
com.sixlegs.png.PngImage

-
-No usage of com.sixlegs.png.PngImage -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/class-use/SuggestedPalette.html b/javapng2/javadoc/com/sixlegs/png/class-use/SuggestedPalette.html deleted file mode 100644 index 5e1d5fa..0000000 --- a/javapng2/javadoc/com/sixlegs/png/class-use/SuggestedPalette.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - -Uses of Interface com.sixlegs.png.SuggestedPalette - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Uses of Interface
com.sixlegs.png.SuggestedPalette

-
-No usage of com.sixlegs.png.SuggestedPalette -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/class-use/TextChunk.html b/javapng2/javadoc/com/sixlegs/png/class-use/TextChunk.html deleted file mode 100644 index 2dd84b9..0000000 --- a/javapng2/javadoc/com/sixlegs/png/class-use/TextChunk.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - -Uses of Interface com.sixlegs.png.TextChunk - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Uses of Interface
com.sixlegs.png.TextChunk

-
- - - - - -
-Uses of TextChunk in com.sixlegs.png
-  -

- - - - - - - - - -
Methods in com.sixlegs.png that return TextChunk
- TextChunkPngImage.getTextChunk(String key) - -
-          Returns a text chunk that uses the given keyword, if one exists.
-  -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/package-frame.html b/javapng2/javadoc/com/sixlegs/png/package-frame.html deleted file mode 100644 index b794b02..0000000 --- a/javapng2/javadoc/com/sixlegs/png/package-frame.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - -com.sixlegs.png - - - - - - - - - - - -com.sixlegs.png - - - - -
-Interfaces  - -
-SuggestedPalette -
-TextChunk
- - - - - - -
-Classes  - -
-PngConfig -
-PngConfig.Builder -
-PngConstants -
-PngImage
- - - - - - -
-Exceptions  - -
-PngException
- - - - diff --git a/javapng2/javadoc/com/sixlegs/png/package-summary.html b/javapng2/javadoc/com/sixlegs/png/package-summary.html deleted file mode 100644 index 0657756..0000000 --- a/javapng2/javadoc/com/sixlegs/png/package-summary.html +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - -com.sixlegs.png - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-

-Package com.sixlegs.png -

- - - - - - - - - - - - - -
-Interface Summary
SuggestedPaletteA suggested palette.
TextChunkCommon interface to all PNG text chunk data (tEXt, - zTXt, iTXt).
-  - -

- - - - - - - - - - - - - - - - - - - - - -
-Class Summary
PngConfigCustomizable parameters used by PngImage when decoding an image.
PngConfig.BuilderBuilder class used to construct PngConfig instances.
PngConstantsThis interface defines all registered chunk types and provides methods - helper methods to examine them.
PngImageA class to decode PNG images.
-  - -

- - - - - - - - - -
-Exception Summary
PngExceptionThe superclass for all decoding exceptions.
-  - -

-

-
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/package-tree.html b/javapng2/javadoc/com/sixlegs/png/package-tree.html deleted file mode 100644 index ae23e41..0000000 --- a/javapng2/javadoc/com/sixlegs/png/package-tree.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -com.sixlegs.png Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For Package com.sixlegs.png -

-
-

-Class Hierarchy -

- -

-Interface Hierarchy -

- -
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/com/sixlegs/png/package-use.html b/javapng2/javadoc/com/sixlegs/png/package-use.html deleted file mode 100644 index c55ac6a..0000000 --- a/javapng2/javadoc/com/sixlegs/png/package-use.html +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - -Uses of Package com.sixlegs.png - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Uses of Package
com.sixlegs.png

-
- - - - - - - - - - - - - - - - - -
-Classes in com.sixlegs.png used by com.sixlegs.png
PngConfig - -
-          Customizable parameters used by PngImage when decoding an image.
PngConfig.Builder - -
-          Builder class used to construct PngConfig instances.
PngException - -
-          The superclass for all decoding exceptions.
TextChunk - -
-          Common interface to all PNG text chunk data (tEXt, - zTXt, iTXt).
-  -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/constant-values.html b/javapng2/javadoc/constant-values.html deleted file mode 100644 index 422a217..0000000 --- a/javapng2/javadoc/constant-values.html +++ /dev/null @@ -1,684 +0,0 @@ - - - - - - -Constant Field Values - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Constant Field Values

-
-
-Contents - - - - - - -
-com.sixlegs.*
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
com.sixlegs.png.PngConfig
-public static final intREAD_ALL0
-public static final intREAD_EXCEPT_DATA3
-public static final intREAD_EXCEPT_METADATA4
-public static final intREAD_HEADER1
-public static final intREAD_UNTIL_DATA2
- -

- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
com.sixlegs.png.PngConstants
-public static final StringBACKGROUND"background_rgb"
-public static final StringBIT_DEPTH"bit_depth"
-public static final intbKGD1649100612
-public static final intcHRM1665684045
-public static final StringCHROMATICITY"chromaticity"
-public static final StringCOLOR_TYPE"color_type"
-public static final intCOLOR_TYPE_GRAY0
-public static final intCOLOR_TYPE_GRAY_ALPHA4
-public static final intCOLOR_TYPE_PALETTE3
-public static final intCOLOR_TYPE_RGB2
-public static final intCOLOR_TYPE_RGB_ALPHA6
-public static final StringCOMPRESSION"compression"
-public static final intCOMPRESSION_BASE0
-public static final StringFILTER"filter"
-public static final intFILTER_BASE0
-public static final intgAMA1732332865
-public static final StringGAMMA"gamma"
-public static final StringGIF_DELAY_TIME"gif_delay_time"
-public static final StringGIF_DISPOSAL_METHOD"gif_disposal_method"
-public static final StringGIF_USER_INPUT_FLAG"gif_user_input_flag"
-public static final intgIFg1732855399
-public static final intgIFx1732855416
-public static final StringHEIGHT"height"
-public static final inthIST1749635924
-public static final StringHISTOGRAM"histogram"
-public static final StringICC_PROFILE"icc_profile"
-public static final StringICC_PROFILE_NAME"icc_profile_name"
-public static final intiCCP1766015824
-public static final intIDAT1229209940
-public static final intIEND1229278788
-public static final intIHDR1229472850
-public static final StringINTERLACE"interlace"
-public static final intINTERLACE_ADAM71
-public static final intINTERLACE_NONE0
-public static final intiTXt1767135348
-public static final intoFFs1866876531
-public static final StringPALETTE"palette"
-public static final StringPALETTE_ALPHA"palette_alpha"
-public static final intpCAL1883455820
-public static final intpHYs1883789683
-public static final StringPIXEL_HEIGHT"pixel_height"
-public static final StringPIXEL_WIDTH"pixel_width"
-public static final StringPIXELS_PER_UNIT_X"pixels_per_unit_x"
-public static final StringPIXELS_PER_UNIT_Y"pixels_per_unit_y"
-public static final intPLTE1347179589
-public static final StringPOSITION_UNIT"position_unit"
-public static final intPOSITION_UNIT_MICROMETER1
-public static final intPOSITION_UNIT_PIXEL0
-public static final StringPOSITION_X"position_x"
-public static final StringPOSITION_Y"position_y"
-public static final StringRENDERING_INTENT"rendering_intent"
-public static final intsBIT1933723988
-public static final intsCAL1933787468
-public static final StringSCALE_UNIT"scale_unit"
-public static final intSCALE_UNIT_METER1
-public static final intSCALE_UNIT_RADIAN2
-public static final longSIGNATURE-8552249625308161526L
-public static final StringSIGNIFICANT_BITS"significant_bits"
-public static final intsPLT1934642260
-public static final intsRGB1934772034
-public static final intSRGB_ABSOLUTE_COLORIMETRIC3
-public static final intSRGB_PERCEPTUAL0
-public static final intSRGB_RELATIVE_COLORIMETRIC1
-public static final intSRGB_SATURATION_PRESERVING2
-public static final intsTER1934902610
-public static final StringSTEREO_MODE"stereo_mode"
-public static final intSTEREO_MODE_CROSS0
-public static final intSTEREO_MODE_DIVERGING1
-public static final StringSUGGESTED_PALETTES"suggested_palettes"
-public static final inttEXt1950701684
-public static final StringTEXT_CHUNKS"text_chunks"
-public static final inttIME1950960965
-public static final StringTIME"time"
-public static final StringTRANSPARENCY"transparency"
-public static final inttRNS1951551059
-public static final StringUNIT"unit"
-public static final intUNIT_METER1
-public static final intUNIT_UNKNOWN0
-public static final StringWIDTH"width"
-public static final intzTXt2052348020
- -

- -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/deprecated-list.html b/javapng2/javadoc/deprecated-list.html deleted file mode 100644 index 86ee19b..0000000 --- a/javapng2/javadoc/deprecated-list.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - -Deprecated List - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Deprecated API

-
-
-Contents
    -
- -
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/help-doc.html b/javapng2/javadoc/help-doc.html deleted file mode 100644 index ed6d532..0000000 --- a/javapng2/javadoc/help-doc.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - -API Help - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-How This API Document Is Organized

-
-This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

-Package

-
- -

-Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    -
  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types
-
-

-Class/Interface

-
- -

-Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    -
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description -

    -

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary -

    -

  • Field Detail
  • Constructor Detail
  • Method Detail
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
- -

-Annotation Type

-
- -

-Each annotation type has its own separate page with the following sections:

    -
  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail
-
- -

-Enum

-
- -

-Each enum has its own separate page with the following sections:

    -
  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail
-
-

-Use

-
-Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
-

-Tree (Class Hierarchy)

-
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    -
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
-
-

-Deprecated API

-
-The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-

-Index

-
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-

-Prev/Next

-These links take you to the next or previous class, interface, package, or related page.

-Frames/No Frames

-These links show and hide the HTML frames. All pages are available with or without frames. -

-

-Serialized Form

-Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. -

-

-Constant Field Values

-The Constant Field Values page lists the static final fields and their values. -

- - -This help file applies to API documentation generated using the standard doclet. - -
-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/index-all.html b/javapng2/javadoc/index-all.html deleted file mode 100644 index 82ca27e..0000000 --- a/javapng2/javadoc/index-all.html +++ /dev/null @@ -1,683 +0,0 @@ - - - - - - -Index - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -B C D F G H I O P R S T U W Z
-

-B

-
-
BACKGROUND - -Static variable in class com.sixlegs.png.PngConstants -
bKGD: Background samples -
BIT_DEPTH - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Bit depth -
bKGD - -Static variable in class com.sixlegs.png.PngConstants -
Background color -
build() - -Method in class com.sixlegs.png.PngConfig.Builder -
Create a configuration using the current values of this builder. -
-
-

-C

-
-
cHRM - -Static variable in class com.sixlegs.png.PngConstants -
Primary chromaticities -
CHROMATICITY - -Static variable in class com.sixlegs.png.PngConstants -
cHRM: Chromaticity -
COLOR_TYPE - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Color type -
COLOR_TYPE_GRAY - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Grayscale color type -
COLOR_TYPE_GRAY_ALPHA - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Grayscale+alpha color type -
COLOR_TYPE_PALETTE - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Palette color type -
COLOR_TYPE_RGB - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: RGB color type -
COLOR_TYPE_RGB_ALPHA - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: RGBA color type -
com.sixlegs.png - package com.sixlegs.png
 
COMPRESSION - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Compression method -
COMPRESSION_BASE - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Deflate/inflate compression -
convertIndexed(boolean) - -Method in class com.sixlegs.png.PngConfig.Builder -
Whether to convert images with an indexed color model - (paletted and 1/2/4/8-bit grayscale) to use a component color model. -
createImage(InputStream, Dimension) - -Method in class com.sixlegs.png.PngImage -
A hook by which subclasses can access or manipulate the raw image data. -
-
-

-D

-
-
defaultGamma(float) - -Method in class com.sixlegs.png.PngConfig.Builder -
Sets the default gamma value. -
displayExponent(float) - -Method in class com.sixlegs.png.PngConfig.Builder -
Sets the default display exponent. -
-
-

-F

-
-
FILTER - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Filter method -
FILTER_BASE - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Adaptive filtering -
-
-

-G

-
-
gAMA - -Static variable in class com.sixlegs.png.PngConstants -
Image gamma -
GAMMA - -Static variable in class com.sixlegs.png.PngConstants -
gAMA: Gamma -
gammaCorrect(boolean) - -Method in class com.sixlegs.png.PngConfig.Builder -
Enables or disables gamma correction. -
getBackground() - -Method in class com.sixlegs.png.PngImage -
Returns the background color explicitly encoded in the image. -
getBitDepth() - -Method in class com.sixlegs.png.PngImage -
Returns the image bit depth. -
getChunkName(int) - -Static method in class com.sixlegs.png.PngConstants -
Returns the four-character ASCII name corresponding to the given - chunk type. -
getChunkType(String) - -Static method in class com.sixlegs.png.PngConstants -
Returns the chunk type corresponding to the given four-character - ASCII chunk name. -
getColorType() - -Method in class com.sixlegs.png.PngImage -
Returns the image color type. -
getConfig() - -Method in class com.sixlegs.png.PngImage -
Returns the configuration used by this object. -
getConvertIndexed() - -Method in class com.sixlegs.png.PngConfig -
Return sthe current indexed image conversion setting. -
getDefaultGamma() - -Method in class com.sixlegs.png.PngConfig -
Returns the current default gamma value. -
getDisplayExponent() - -Method in class com.sixlegs.png.PngConfig -
Returns the current display exponent. -
getFrequency(int) - -Method in interface com.sixlegs.png.SuggestedPalette -
Retrieve a sample frequency value. -
getGamma() - -Method in class com.sixlegs.png.PngImage -
Returns the gamma exponent that was explicitly encoded in the image, - if there was one, or the value of PngConfig.getDefaultGamma() otherwise. -
getGammaCorrect() - -Method in class com.sixlegs.png.PngConfig -
Returns the current gamma correction setting. -
getGammaTable() - -Method in class com.sixlegs.png.PngImage -
Returns a gamma table which can be used for custom gamma correction. -
getHeight() - -Method in class com.sixlegs.png.PngImage -
Returns the image height in pixels. -
getKeyword() - -Method in interface com.sixlegs.png.TextChunk -
Returns the Latin-1 (ISO-8859-1) encoded keyword - of this TextChunk. -
getLanguage() - -Method in interface com.sixlegs.png.TextChunk -
Returns the language (RFC-1766) used by the translated - keyword and the text, or null if unspecified. -
getName() - -Method in interface com.sixlegs.png.SuggestedPalette -
Returns palette name. -
getProgressive() - -Method in class com.sixlegs.png.PngConfig -
Returns the current progressive display setting. -
getProperties() - -Method in class com.sixlegs.png.PngImage -
Returns the map which stores all of this image's property values. -
getProperty(String) - -Method in class com.sixlegs.png.PngImage -
Returns a per-image property by name. -
getReadLimit() - -Method in class com.sixlegs.png.PngConfig -
Returns the current read limit setting. -
getReduce16() - -Method in class com.sixlegs.png.PngConfig -
Returns the current 16-bit reduction setting. -
getSample(int, short[]) - -Method in interface com.sixlegs.png.SuggestedPalette -
Retrieve a sample value. -
getSampleCount() - -Method in interface com.sixlegs.png.SuggestedPalette -
Returns the number of samples. -
getSampleDepth() - -Method in interface com.sixlegs.png.SuggestedPalette -
Returns the sample depth. -
getSamples() - -Method in class com.sixlegs.png.PngImage -
Returns the number of samples per pixel. -
getSourceRegion() - -Method in class com.sixlegs.png.PngConfig -
Returns the source region to be used. -
getSourceXSubsampling() - -Method in class com.sixlegs.png.PngConfig -
Returns the number of source columns to advance for each pixel. -
getSourceYSubsampling() - -Method in class com.sixlegs.png.PngConfig -
Returns the number of rows to advance for each pixel. -
getSubsamplingXOffset() - -Method in class com.sixlegs.png.PngConfig -
Returns the horizontal offset of the subsampling grid. -
getSubsamplingYOffset() - -Method in class com.sixlegs.png.PngConfig -
Returns the vertical offset of the subsampling grid. -
getText() - -Method in interface com.sixlegs.png.TextChunk -
Returns the text of this TextChunk. -
getTextChunk(String) - -Method in class com.sixlegs.png.PngImage -
Returns a text chunk that uses the given keyword, if one exists. -
getTranslatedKeyword() - -Method in interface com.sixlegs.png.TextChunk -
Returns a translation of the keyword into the language - used by this TextChunk, or null if unspecified. -
getTransparency() - -Method in class com.sixlegs.png.PngImage -
Returns the type of this Transparency. -
getType() - -Method in interface com.sixlegs.png.TextChunk -
Returns the type of this TextChunk. -
getWarningsFatal() - -Method in class com.sixlegs.png.PngConfig -
Returns whether warnings are treated as fatal errors. -
getWidth() - -Method in class com.sixlegs.png.PngImage -
Returns the image widt hin pixels. -
GIF_DELAY_TIME - -Static variable in class com.sixlegs.png.PngConstants -
gIFg: GIF delay time (hundredths of a second) -
GIF_DISPOSAL_METHOD - -Static variable in class com.sixlegs.png.PngConstants -
gIFg: GIF disposal method -
GIF_USER_INPUT_FLAG - -Static variable in class com.sixlegs.png.PngConstants -
gIFg: GIF user input flag -
gIFg - -Static variable in class com.sixlegs.png.PngConstants -
GIF Graphic Control Extension -
gIFx - -Static variable in class com.sixlegs.png.PngConstants -
GIF Application Extension -
-
-

-H

-
-
handlePass(BufferedImage, int) - -Method in class com.sixlegs.png.PngImage -
A method which subclasses may override to take some action - after each pass has been decoded. -
handleProgress(BufferedImage, float) - -Method in class com.sixlegs.png.PngImage -
Reports the approximate degree of completion of the current read - call. -
handleWarning(PngException) - -Method in class com.sixlegs.png.PngImage -
Callback for customized handling of warnings. -
HEIGHT - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Height -
hIST - -Static variable in class com.sixlegs.png.PngConstants -
Palette histogram -
HISTOGRAM - -Static variable in class com.sixlegs.png.PngConstants -
hIST: Palette histogram -
-
-

-I

-
-
ICC_PROFILE - -Static variable in class com.sixlegs.png.PngConstants -
iCCP: ICC profile -
ICC_PROFILE_NAME - -Static variable in class com.sixlegs.png.PngConstants -
iCCP: ICC profile name -
iCCP - -Static variable in class com.sixlegs.png.PngConstants -
Embedded ICC profile -
IDAT - -Static variable in class com.sixlegs.png.PngConstants -
Image data -
IEND - -Static variable in class com.sixlegs.png.PngConstants -
Image trailer -
IHDR - -Static variable in class com.sixlegs.png.PngConstants -
Image header -
INTERLACE - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Interlace method -
INTERLACE_ADAM7 - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Adam7 interlace -
INTERLACE_NONE - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: No interlace -
isAncillary(int) - -Static method in class com.sixlegs.png.PngConstants -
Returns true if the given chunk type has the ancillary bit set - (the first letter is lowercase). -
isFatal() - -Method in exception com.sixlegs.png.PngException -
Returns true if this exception represents a fatal decoding error. -
isInterlaced() - -Method in class com.sixlegs.png.PngImage -
Returns true if the image interlace type (PngConstants.INTERLACE) - is something other than INTERLACE_NONE. -
isMultipleOK(int) - -Method in class com.sixlegs.png.PngImage -
Returns whether a chunk is allowed to occur multiple times. -
isPrivate(int) - -Static method in class com.sixlegs.png.PngConstants -
Returns true if the given chunk type has the private bit set - (the second letter is lowercase). -
isReserved(int) - -Static method in class com.sixlegs.png.PngConstants -
Returns true if the given chunk type has the reserved bit set - (the third letter is lowercase). -
isSafeToCopy(int) - -Static method in class com.sixlegs.png.PngConstants -
Returns true if the given chunk type has the safe-to-copy bit set - (the fourth letter is lowercase). -
iTXt - -Static variable in class com.sixlegs.png.PngConstants -
International textual data -
-
-

-O

-
-
oFFs - -Static variable in class com.sixlegs.png.PngConstants -
Image offset -
-
-

-P

-
-
PALETTE - -Static variable in class com.sixlegs.png.PngConstants -
PLTE: Palette entries -
PALETTE_ALPHA - -Static variable in class com.sixlegs.png.PngConstants -
PLTE: Palette alpha -
pCAL - -Static variable in class com.sixlegs.png.PngConstants -
Calibration of pixel values -
pHYs - -Static variable in class com.sixlegs.png.PngConstants -
Physical pixel dimensions -
PIXEL_HEIGHT - -Static variable in class com.sixlegs.png.PngConstants -
sCAL: Physical height of pixel -
PIXEL_WIDTH - -Static variable in class com.sixlegs.png.PngConstants -
sCAL: Physical width of pixel -
PIXELS_PER_UNIT_X - -Static variable in class com.sixlegs.png.PngConstants -
pHYs: Pixels per unit, X axis -
PIXELS_PER_UNIT_Y - -Static variable in class com.sixlegs.png.PngConstants -
pHYs: Pixels per unit, Y axis -
PLTE - -Static variable in class com.sixlegs.png.PngConstants -
Palette -
PngConfig - Class in com.sixlegs.png
Customizable parameters used by PngImage when decoding an image.
PngConfig.Builder - Class in com.sixlegs.png
Builder class used to construct PngConfig instances.
PngConfig.Builder() - -Constructor for class com.sixlegs.png.PngConfig.Builder -
Create a new builder using default values. -
PngConfig.Builder(PngConfig) - -Constructor for class com.sixlegs.png.PngConfig.Builder -
Create a builder using values from the given configuration. -
PngConstants - Class in com.sixlegs.png
This interface defines all registered chunk types and provides methods - helper methods to examine them.
PngConstants() - -Constructor for class com.sixlegs.png.PngConstants -
  -
PngException - Exception in com.sixlegs.png
The superclass for all decoding exceptions.
PngImage - Class in com.sixlegs.png
A class to decode PNG images.
PngImage() - -Constructor for class com.sixlegs.png.PngImage -
Constructor which uses a default instance of PngConfig. -
PngImage(PngConfig) - -Constructor for class com.sixlegs.png.PngImage -
Constructor which uses the specified configuration. -
POSITION_UNIT - -Static variable in class com.sixlegs.png.PngConstants -
oFFs: Unit for image offset -
POSITION_UNIT_MICROMETER - -Static variable in class com.sixlegs.png.PngConstants -
oFFs: Unit is the micrometer (10^-6 meter) -
POSITION_UNIT_PIXEL - -Static variable in class com.sixlegs.png.PngConstants -
oFFs: Unit is the pixel (true dimensions unspecified) -
POSITION_X - -Static variable in class com.sixlegs.png.PngConstants -
oFFs: Image X position -
POSITION_Y - -Static variable in class com.sixlegs.png.PngConstants -
oFFs: Image Y position -
progressive(boolean) - -Method in class com.sixlegs.png.PngConfig.Builder -
Enables or disables progressive display for interlaced images. -
-
-

-R

-
-
read(File) - -Method in class com.sixlegs.png.PngImage -
Reads a PNG image from the specified file. -
read(InputStream, boolean) - -Method in class com.sixlegs.png.PngImage -
Reads a PNG image from the specified input stream. -
READ_ALL - -Static variable in class com.sixlegs.png.PngConfig -
Read the entire image -
READ_EXCEPT_DATA - -Static variable in class com.sixlegs.png.PngConfig -
Read the entire image, skipping over the image data -
READ_EXCEPT_METADATA - -Static variable in class com.sixlegs.png.PngConfig -
Read the entire image, skipping over all non-critical chunks except tRNS and gAMA -
READ_HEADER - -Static variable in class com.sixlegs.png.PngConfig -
Read only the header chunk -
READ_UNTIL_DATA - -Static variable in class com.sixlegs.png.PngConfig -
Read all the metadata up to the image data -
readChunk(int, DataInput, long, int) - -Method in class com.sixlegs.png.PngImage -
Read the chunk data from the image input stream, storing - properties into this PngImage instance. -
readLimit(int) - -Method in class com.sixlegs.png.PngConfig.Builder -
Configures how much of the image to read. -
reduce16(boolean) - -Method in class com.sixlegs.png.PngConfig.Builder -
Enables or disables 16-bit reduction. -
RENDERING_INTENT - -Static variable in class com.sixlegs.png.PngConstants -
sRGB: Rendering intent -
-
-

-S

-
-
sBIT - -Static variable in class com.sixlegs.png.PngConstants -
Significant bits -
sCAL - -Static variable in class com.sixlegs.png.PngConstants -
Physical scale of image subject -
SCALE_UNIT - -Static variable in class com.sixlegs.png.PngConstants -
sCAL: Unit for physical scale of image subject -
SCALE_UNIT_METER - -Static variable in class com.sixlegs.png.PngConstants -
sCAL: Unit is the meter -
SCALE_UNIT_RADIAN - -Static variable in class com.sixlegs.png.PngConstants -
sCAL: Unit is the radian -
SIGNATURE - -Static variable in class com.sixlegs.png.PngConstants -
Eight byte magic number that begins all PNG images -
SIGNIFICANT_BITS - -Static variable in class com.sixlegs.png.PngConstants -
sBIT: Significant bits -
sourceRegion(Rectangle) - -Method in class com.sixlegs.png.PngConfig.Builder -
Decode only a particular region of the source image. -
sourceSubsampling(int, int, int, int) - -Method in class com.sixlegs.png.PngConfig.Builder -
Reduce the size of the decoded image (or source region) by only using - periodic rows and/or columns of the image. -
sPLT - -Static variable in class com.sixlegs.png.PngConstants -
Suggested palette -
sRGB - -Static variable in class com.sixlegs.png.PngConstants -
Standard RGB color space -
SRGB_ABSOLUTE_COLORIMETRIC - -Static variable in class com.sixlegs.png.PngConstants -
sRGB: Absolute colormetric rendering intent -
SRGB_PERCEPTUAL - -Static variable in class com.sixlegs.png.PngConstants -
sRGB: Perceptual rendering intent -
SRGB_RELATIVE_COLORIMETRIC - -Static variable in class com.sixlegs.png.PngConstants -
sRGB: Relative colorimetric rendering intent -
SRGB_SATURATION_PRESERVING - -Static variable in class com.sixlegs.png.PngConstants -
sRGB: Saturation rendering intent -
sTER - -Static variable in class com.sixlegs.png.PngConstants -
Indicator of Stereo Image -
STEREO_MODE - -Static variable in class com.sixlegs.png.PngConstants -
sTER: Indicator of stereo image -
STEREO_MODE_CROSS - -Static variable in class com.sixlegs.png.PngConstants -
sTER: Cross-fuse layout -
STEREO_MODE_DIVERGING - -Static variable in class com.sixlegs.png.PngConstants -
sTER: Diverging-fuse layout -
SUGGESTED_PALETTES - -Static variable in class com.sixlegs.png.PngConstants -
sPLT: List of suggested palettes -
SuggestedPalette - Interface in com.sixlegs.png
A suggested palette.
-
-

-T

-
-
tEXt - -Static variable in class com.sixlegs.png.PngConstants -
Textual data -
TEXT_CHUNKS - -Static variable in class com.sixlegs.png.PngConstants -
tEXt/zTXt/iTXt: List of text chunks -
TextChunk - Interface in com.sixlegs.png
Common interface to all PNG text chunk data (tEXt, - zTXt, iTXt).
tIME - -Static variable in class com.sixlegs.png.PngConstants -
Image last-modification time -
TIME - -Static variable in class com.sixlegs.png.PngConstants -
tIME: Image last-modification time -
TRANSPARENCY - -Static variable in class com.sixlegs.png.PngConstants -
tRNS: Transparency samples -
tRNS - -Static variable in class com.sixlegs.png.PngConstants -
Transparency -
-
-

-U

-
-
UNIT - -Static variable in class com.sixlegs.png.PngConstants -
pHYs: Unit specifier -
UNIT_METER - -Static variable in class com.sixlegs.png.PngConstants -
pHYs: Unit is the meter -
UNIT_UNKNOWN - -Static variable in class com.sixlegs.png.PngConstants -
pHYs: Unit is unknown -
-
-

-W

-
-
warningsFatal(boolean) - -Method in class com.sixlegs.png.PngConfig.Builder -
Configures whether warnings should be treated as fatal errors. -
WIDTH - -Static variable in class com.sixlegs.png.PngConstants -
IHDR: Width -
-
-

-Z

-
-
zTXt - -Static variable in class com.sixlegs.png.PngConstants -
Compressed textual data -
-
-B C D F G H I O P R S T U W Z - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/index.html b/javapng2/javadoc/index.html deleted file mode 100644 index f8020cc..0000000 --- a/javapng2/javadoc/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - -Generated Documentation (Untitled) - - - - - - - - -<H2> -Frame Alert</H2> - -<P> -This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. -<BR> -Link to<A HREF="com/sixlegs/png/package-summary.html">Non-frame version.</A> - - - diff --git a/javapng2/javadoc/overview-tree.html b/javapng2/javadoc/overview-tree.html deleted file mode 100644 index 810c3d5..0000000 --- a/javapng2/javadoc/overview-tree.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - -Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For All Packages

-
-
-
Package Hierarchies:
com.sixlegs.png
-
-

-Class Hierarchy -

- -

-Interface Hierarchy -

- -
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/package-list b/javapng2/javadoc/package-list deleted file mode 100644 index 59ec8ce..0000000 --- a/javapng2/javadoc/package-list +++ /dev/null @@ -1 +0,0 @@ -com.sixlegs.png diff --git a/javapng2/javadoc/resources/inherit.gif b/javapng2/javadoc/resources/inherit.gif deleted file mode 100644 index c814867..0000000 Binary files a/javapng2/javadoc/resources/inherit.gif and /dev/null differ diff --git a/javapng2/javadoc/serialized-form.html b/javapng2/javadoc/serialized-form.html deleted file mode 100644 index cae3227..0000000 --- a/javapng2/javadoc/serialized-form.html +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - -Serialized Form - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Serialized Form

-
-
- - - - - -
-Package com.sixlegs.png
- -

- - - - - -
-Class com.sixlegs.png.PngException extends IOException implements Serializable
- -

- - - - - -
-Serialized Fields
- -

-fatal

-
-boolean fatal
-
-
-
-
- -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/javapng2/javadoc/stylesheet.css b/javapng2/javadoc/stylesheet.css deleted file mode 100644 index 6d31fdb..0000000 --- a/javapng2/javadoc/stylesheet.css +++ /dev/null @@ -1,29 +0,0 @@ -/* Javadoc style sheet */ - -/* Define colors, fonts and other style attributes here to override the defaults */ - -/* Page background color */ -body { background-color: #FFFFFF } - -/* Headings */ -h1 { font-size: 145% } - -/* Table colors */ -.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ -.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ -.TableRowColor { background: #FFFFFF } /* White */ - -/* Font used in left-hand frame lists */ -.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } -.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } -.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } - -/* Navigation bar fonts and colors */ -.NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ -.NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ -.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} -.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} - -.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} -.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} - diff --git a/javapng2/lib/png1.jar b/javapng2/lib/png1.jar deleted file mode 100644 index dbdbe59..0000000 Binary files a/javapng2/lib/png1.jar and /dev/null differ diff --git a/javapng2/libdev/asm.jar b/javapng2/libdev/asm.jar deleted file mode 100644 index 297690f..0000000 Binary files a/javapng2/libdev/asm.jar and /dev/null differ diff --git a/javapng2/libdev/bzip2.jar b/javapng2/libdev/bzip2.jar deleted file mode 100644 index 94eeb97..0000000 Binary files a/javapng2/libdev/bzip2.jar and /dev/null differ diff --git a/javapng2/libdev/cobertura.jar b/javapng2/libdev/cobertura.jar deleted file mode 100644 index 03baf65..0000000 Binary files a/javapng2/libdev/cobertura.jar and /dev/null differ diff --git a/javapng2/libdev/jarjar.jar b/javapng2/libdev/jarjar.jar deleted file mode 100644 index 142a8be..0000000 Binary files a/javapng2/libdev/jarjar.jar and /dev/null differ diff --git a/javapng2/libdev/log4j.jar b/javapng2/libdev/log4j.jar deleted file mode 100644 index a6568b0..0000000 Binary files a/javapng2/libdev/log4j.jar and /dev/null differ diff --git a/javapng2/libdev/oro.jar b/javapng2/libdev/oro.jar deleted file mode 100644 index 23488d2..0000000 Binary files a/javapng2/libdev/oro.jar and /dev/null differ diff --git a/javapng2/libdev/xml-writer.jar b/javapng2/libdev/xml-writer.jar deleted file mode 100644 index 7405226..0000000 Binary files a/javapng2/libdev/xml-writer.jar and /dev/null differ diff --git a/javapng2/src/apng/com/sixlegs/png/AnimatedPngImage.java b/javapng2/src/apng/com/sixlegs/png/AnimatedPngImage.java deleted file mode 100644 index 3e5585e..0000000 --- a/javapng2/src/apng/com/sixlegs/png/AnimatedPngImage.java +++ /dev/null @@ -1,347 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.*; -import java.util.*; -import java.util.List; - -/** - * TODO - */ -public class AnimatedPngImage -extends PngImage -{ - /** TODO */ - public static final int acTL = 0x6163544C; - /** TODO */ - public static final int fcTL = 0x6663544C; - /** TODO */ - public static final int fdAT = 0x66644154; - - private static final PngConfig DEFAULT_CONFIG = - new PngConfig.Builder().readLimit(PngConfig.READ_EXCEPT_DATA).build(); - - private final List chunks = new ArrayList(); - private final List frames = new ArrayList(); - private final Map frameData = new HashMap(); - private final List defaultImageData = new ArrayList(); - - private Rectangle headerBounds; - private boolean animated; - private boolean sawData; - private boolean useDefaultImage; - private int numFrames; - private int numPlays; - - /** - * TODO - */ - public AnimatedPngImage() - { - super(DEFAULT_CONFIG); - } - - /** - * TODO - */ - public AnimatedPngImage(PngConfig config) - { - super(new PngConfig.Builder(config).readLimit(PngConfig.READ_EXCEPT_DATA).build()); - } - - private void reset() - { - animated = sawData = useDefaultImage = false; - chunks.clear(); - frames.clear(); - frameData.clear(); - defaultImageData.clear(); - } - - /** - * TODO - */ - public boolean isAnimated() - { - assertRead(); - return animated; - } - - /** - * TODO - */ - public int getNumFrames() - { - assertRead(); - return frames.size(); - } - - /** - * TODO - */ - public int getNumPlays() - { - assertRead(); - return animated ? numPlays : 1; - } - - /** - * TODO - */ - public FrameControl getFrame(int index) - { - assertRead(); - return (FrameControl)frames.get(index); - } - - /** - * TODO - */ - public boolean isClearRequired() - { - assertRead(); - if (!animated) - return false; - FrameControl first = getFrame(0); - return (first.getBlend() == FrameControl.BLEND_OVER) || - !first.getBounds().equals(new Rectangle(getWidth(), getHeight())); - } - - /** - * TODO - */ - public BufferedImage[] readAllFrames(File file) - throws IOException - { - read(file); - BufferedImage[] images = new BufferedImage[getNumFrames()]; - for (int i = 0; i < images.length; i++) - images[i] = readFrame(file, getFrame(i)); - return images; - } - - // TODO: make sure that file is what we read before? - // TODO: make sure that frame control is from this image? - /** - * TODO - */ - public BufferedImage readFrame(File file, FrameControl frame) - throws IOException - { - assertRead(); - if (frame == null) - return readImage(file, defaultImageData, new Dimension(getWidth(), getHeight())); - return readImage(file, (List)frameData.get(frame), frame.getBounds().getSize()); - } - - private BufferedImage readImage(File file, List data, Dimension size) - throws IOException - { - FrameDataInputStream in = new FrameDataInputStream(file, data); - try { - return createImage(in, size); - } finally { - in.close(); - } - } - - private void assertRead() - { - if (frames.isEmpty()) - throw new IllegalStateException("Image has not been read"); - } - - protected void readChunk(int type, DataInput in, long offset, int length) - throws IOException - { - switch (type) { - case PngConstants.IEND: - validate(); - super.readChunk(type, in, offset, length); - break; - - case PngConstants.IHDR: - reset(); - super.readChunk(type, in, offset, length); - headerBounds = new Rectangle(getWidth(), getHeight()); - break; - - case acTL: - RegisteredChunks.checkLength(type, length, 8); - if (sawData) - error("acTL cannot appear after IDAT"); - animated = true; - if ((numFrames = in.readInt()) <= 0) - error("Invalid frame count: " + numFrames); - if ((numPlays = in.readInt()) < 0) - error("Invalid play count: " + numPlays); - break; - - case fcTL: - RegisteredChunks.checkLength(type, length, 26); - add(in.readInt(), readFrameControl(in)); - break; - - case fdAT: - if (!sawData) - error("fdAT chunks cannot appear before IDAT"); - add(in.readInt(), new FrameData(offset + 4, length - 4)); - break; - - case PngConstants.IDAT: - sawData = true; - defaultImageData.add(new FrameData(offset, length)); - break; - - default: - super.readChunk(type, in, offset, length); - } - } - - protected boolean isMultipleOK(int type) - { - switch (type) { - case fcTL: - case fdAT: - return true; - } - return super.isMultipleOK(type); - } - - private void add(int seq, Object chunk) - throws PngException - { - if (chunks.size() != seq || - (seq == 0 && !(chunk instanceof FrameControl))) - error("APNG chunks out of order"); - chunks.add(chunk); - } - - private static void error(String message) - throws PngException - { - throw new PngException(message, false); - } - - private FrameControl readFrameControl(DataInput in) - throws IOException - { - int w = in.readInt(); - int h = in.readInt(); - Rectangle bounds = new Rectangle(in.readInt(), in.readInt(), w, h); - if (!sawData) { - if (!chunks.isEmpty()) - error("Multiple fcTL chunks are not allowed before IDAT"); - if (!bounds.equals(headerBounds)) - error("Default image frame must match IHDR bounds"); - useDefaultImage = true; - } - if (!headerBounds.contains(bounds)) - error("Frame bounds must fall within IHDR bounds"); - - int delayNum = in.readUnsignedShort(); - int delayDen = in.readUnsignedShort(); - if (delayDen == 0) - delayDen = 100; - - int disposeOp = in.readByte(); - switch (disposeOp) { - case FrameControl.DISPOSE_NONE: - case FrameControl.DISPOSE_BACKGROUND: - break; - case FrameControl.DISPOSE_PREVIOUS: - if (chunks.isEmpty()) - disposeOp = FrameControl.DISPOSE_BACKGROUND; - break; - default: - error("Unknown APNG dispose op " + disposeOp); - } - - int blendOp = in.readByte(); - switch (blendOp) { - case FrameControl.BLEND_OVER: - case FrameControl.BLEND_SOURCE: - break; - default: - error("Unknown APNG blend op " + blendOp); - } - return new FrameControl(bounds, (float)delayNum / delayDen, disposeOp, blendOp); - } - - private void validate() - throws IOException - { - if (!animated) { - frames.add(null); - return; - } - try { - if (chunks.isEmpty()) - error("Found zero frames"); - - List list = null; - for (int i = 0; i < chunks.size(); i++) { - Object chunk = chunks.get(i); - if (chunk instanceof FrameControl) { - frames.add(chunk); - frameData.put(chunk, list = new ArrayList()); - } else { - list.add(chunk); - } - } - - if (frames.size() != numFrames) - error("Found " + frames.size() + " frames, expected " + numFrames); - - if (useDefaultImage) - ((List)frameData.get(frames.get(0))).addAll(defaultImageData); - - for (int i = 0; i < frames.size(); i++) { - if (((List)frameData.get(frames.get(i))).isEmpty()) - error("Missing data for frame"); - } - chunks.clear(); - - } catch (IOException e) { - animated = false; - throw e; - } - } -} diff --git a/javapng2/src/apng/com/sixlegs/png/Animator.java b/javapng2/src/apng/com/sixlegs/png/Animator.java deleted file mode 100644 index 423e736..0000000 --- a/javapng2/src/apng/com/sixlegs/png/Animator.java +++ /dev/null @@ -1,217 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.image.BufferedImage; -import java.awt.image.Raster; -import javax.swing.Timer; -import java.util.*; -import java.util.List; - -/** - * TODO - */ -public class Animator -implements ActionListener -{ - private static final Color TRANSPARENT_BLACK = new Color(0, true); - private static final int MIN_DELAY = 10; - - private final AnimatedPngImage png; - private final BufferedImage target; - private final Graphics2D g; - private final BufferedImage prev; - private final Graphics2D gPrev; - private final RenderData[] render; - private final int timerDelay; - private final boolean clearRequired; - - private long waitUntil = 0; - private int index = -1; - private int iter; - private boolean done; - - private static BufferedImage createCompatibleImage(BufferedImage image, int width, int height) - { - return new BufferedImage(image.getColorModel(), - image.getRaster().createCompatibleWritableRaster(width, height), - image.isAlphaPremultiplied(), - null); // TODO: properties - } - - /** - * TODO - */ - public Animator(AnimatedPngImage png, BufferedImage[] frames, BufferedImage target) - { - if (!png.isAnimated()) - throw new IllegalArgumentException("PNG is not animated"); - if (target == null) - target = createCompatibleImage(frames[0], png.getWidth(), png.getHeight()); - - this.png = png; - this.target = target; - g = target.createGraphics(); - - Rectangle prevBounds = new Rectangle(0, 0, 0, 0); - List renderList = new ArrayList(); - int minDelay = Integer.MAX_VALUE; - for (int i = 0; i < png.getNumFrames(); i++) { - FrameControl frame = png.getFrame(i); - RenderData rd = new RenderData(); - rd.image = frames[i]; - rd.bounds = frame.getBounds(); - rd.dispose = frame.getDispose(); - rd.blend = (frame.getBlend() == FrameControl.BLEND_SOURCE) ? - AlphaComposite.Src : - AlphaComposite.SrcOver; - if (frame.getDispose() == FrameControl.DISPOSE_PREVIOUS) - prevBounds.add(new Rectangle(rd.bounds.getSize())); - rd.delay = Math.max((int)(frame.getDelay() * 1000), MIN_DELAY); - minDelay = Math.min(minDelay, rd.delay); - renderList.add(rd); - } - timerDelay = minDelay; - render = (RenderData[])renderList.toArray(new RenderData[renderList.size()]); - if (prevBounds.isEmpty()) { - prev = null; - gPrev = null; - } else { - prev = createCompatibleImage(frames[0], prevBounds.width, prevBounds.height); - gPrev = prev.createGraphics(); - gPrev.setComposite(AlphaComposite.Src); - } - clearRequired = png.isClearRequired(); - if (clearRequired) - clearFrame(target); - } - - public void reset() - { - waitUntil = 0; - iter = 0; - index = -1; - done = false; - clearFrame(target); - } - - private void clearFrame(BufferedImage target) - { - g.setComposite(AlphaComposite.Src); - g.setColor(TRANSPARENT_BLACK); - g.fillRect(0, 0, target.getWidth(), target.getHeight()); - } - - /** - * TODO - */ - public BufferedImage getTarget() - { - return target; - } - - /** - * TODO - */ - public int getTimerDelay() - { - return timerDelay; - } - - // TODO: add fudge factor in case we get triggered a little too early - public void actionPerformed(ActionEvent e) - { - long now = System.currentTimeMillis(); - if (done || waitUntil > now) - return; - if (waitUntil == 0) - waitUntil = now; - while (waitUntil <= now) { - if (index >= 0) - dispose(render[index]); - if (++index == render.length) { - int maxIter = png.getNumPlays(); - if (++iter == maxIter && maxIter != 0) { - done = true; - return; - } - if (clearRequired) - clearFrame(target); - index = 0; - } - waitUntil += render[index].delay; - draw(render[index]); - } - } - - private void dispose(RenderData rd) - { - Rectangle bounds = rd.bounds; - switch (rd.dispose) { - case FrameControl.DISPOSE_BACKGROUND: - g.setComposite(AlphaComposite.Src); - g.setColor(TRANSPARENT_BLACK); - g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); - break; - case FrameControl.DISPOSE_PREVIOUS: - g.setComposite(AlphaComposite.Src); - g.drawImage(prev, bounds.x, bounds.y, bounds.width, bounds.height, null, null); - break; - } - } - - private void draw(RenderData rd) - { - Rectangle bounds = rd.bounds; - if (rd.dispose == FrameControl.DISPOSE_PREVIOUS) - gPrev.drawImage(target, bounds.x, bounds.y, bounds.width, bounds.height, null, null); - g.setComposite(rd.blend); - g.drawImage(rd.image, bounds.x, bounds.y, bounds.width, bounds.height, null, null); - } - - private static class RenderData - { - int delay; - int dispose; - Rectangle bounds; - BufferedImage image; - Composite blend; - } -} diff --git a/javapng2/src/apng/com/sixlegs/png/FrameControl.java b/javapng2/src/apng/com/sixlegs/png/FrameControl.java deleted file mode 100644 index ad9f1a2..0000000 --- a/javapng2/src/apng/com/sixlegs/png/FrameControl.java +++ /dev/null @@ -1,108 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.Rectangle; - -/** - * TODO - */ -public class FrameControl -{ - /** TODO */ - public static final int DISPOSE_NONE = 0; - /** TODO */ - public static final int DISPOSE_BACKGROUND = 1; - /** TODO */ - public static final int DISPOSE_PREVIOUS = 2; - - /** TODO */ - public static final int BLEND_SOURCE = 0; - /** TODO */ - public static final int BLEND_OVER = 1; - - private final Rectangle bounds; - private final float delay; - private final int dispose; - private final int blend; - - FrameControl(Rectangle bounds, float delay, int dispose, int blend) - { - this.bounds = bounds; - this.delay = delay; - this.dispose = dispose; - this.blend = blend; - } - - /** - * TODO - */ - public Rectangle getBounds() - { - return new Rectangle(bounds); - } - - /** - * TODO - */ - public float getDelay() - { - return delay; - } - - /** - * TODO - */ - public int getDispose() - { - return dispose; - } - - /** - * TODO - */ - public int getBlend() - { - return blend; - } - - public String toString() - { - return "FrameControl{bounds=" + bounds + ",delay=" + delay + - ",dispose=" + dispose + ",blend=" + blend + "}"; - } -} diff --git a/javapng2/src/apng/com/sixlegs/png/FrameData.java b/javapng2/src/apng/com/sixlegs/png/FrameData.java deleted file mode 100644 index b4c43d8..0000000 --- a/javapng2/src/apng/com/sixlegs/png/FrameData.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.io.*; - -class FrameData -{ - private final long offset; - private final int length; - - public FrameData(long offset, int length) - { - this.offset = offset; - this.length = length; - } - - public long getOffset() - { - return offset; - } - - public int getLength() - { - return length; - } -} diff --git a/javapng2/src/apng/com/sixlegs/png/FrameDataInputStream.java b/javapng2/src/apng/com/sixlegs/png/FrameDataInputStream.java deleted file mode 100644 index 5c36542..0000000 --- a/javapng2/src/apng/com/sixlegs/png/FrameDataInputStream.java +++ /dev/null @@ -1,136 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.io.*; -import java.util.*; - -class FrameDataInputStream -extends InputStream -{ - private final RandomAccessFile file; - private final Iterator it; - private InputStream in; - - public FrameDataInputStream(File file, List frameData) - throws IOException - { - this.file = new RandomAccessFile(file, "r"); - this.it = frameData.iterator(); - advance(); - } - - public void close() - throws IOException - { - if (in != null) { - in.close(); - in = null; - while (it.hasNext()) - it.next(); - } - file.close(); - } - - private void advance() - throws IOException - { - if (in != null) - in.close(); - in = null; - if (it.hasNext()) { - // TODO: enable streaming - FrameData data = (FrameData)it.next(); - file.seek(data.getOffset()); - byte[] bytes = new byte[data.getLength()]; - file.readFully(bytes); - in = new ByteArrayInputStream(bytes); - } - } - - public int available() - throws IOException - { - if (in == null) - return 0; - return in.available(); - } - - public boolean markSupported() - { - return false; - } - - public int read() - throws IOException - { - if (in == null) - return -1; - int result = in.read(); - if (result == -1) { - advance(); - return read(); - } - return result; - } - - public int read(byte[] b, int off, int len) - throws IOException - { - if (in == null) - return -1; - int result = in.read(b, off, len); - if (result == -1) { - advance(); - return read(b, off, len); - } - return result; - } - - public long skip(long n) - throws IOException - { - if (in == null) - return 0; - long result = in.skip(n); - if (result != 0) - return result; - if (read() == -1) - return 0; - return 1; - } -} diff --git a/javapng2/src/examples/com/sixlegs/png/examples/AnimatedGif2Png.java b/javapng2/src/examples/com/sixlegs/png/examples/AnimatedGif2Png.java deleted file mode 100644 index c5cb2e9..0000000 --- a/javapng2/src/examples/com/sixlegs/png/examples/AnimatedGif2Png.java +++ /dev/null @@ -1,451 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.examples; - -import com.sixlegs.png.*; -import java.awt.*; -import java.awt.image.*; -import java.io.*; -import java.util.*; -import java.util.List; -import java.util.zip.*; -import javax.imageio.*; -import javax.imageio.metadata.*; -import javax.imageio.stream.FileImageInputStream; -import org.w3c.dom.Node; - -public class AnimatedGif2Png -{ - private static final int MIN_DELAY = 75; // ms - - public static void main(String[] args) - throws IOException - { - if (args.length != 2) { - System.err.println("Usage: java -jar gif2apng.jar "); - return; - } - convert(new File(args[0]), new File(args[1])); - } - - public static void convert(File in, File out) - throws IOException - { - ImageReader imageReader = ImageIO.getImageReadersByFormatName("GIF").next(); - imageReader.setInput(new FileImageInputStream(in)); - - int numIterations = 1; - byte[] netscape = getAppExtension(imageReader.getImageMetadata(0), "NETSCAPE", "2.0"); - if (netscape != null && netscape[0] != 0) { - int repeat = ((0xFF & netscape[2]) << 8) | (0xFF & netscape[1]); - if (repeat == 0) { - numIterations = 0; - } else { - numIterations = 1 + repeat; - } - } - - int index = 0; - Set entries = new HashSet(); - List frames = new ArrayList(); - int[] prev = null; - boolean different = false; - try { - for (;;) { - // TODO: get palette from metadata instead of decoding image? - BufferedImage image = imageReader.read(index); - ColorModel colorModel = image.getColorModel(); - IndexColorModel icm = (IndexColorModel)colorModel; - int[] palette = new int[icm.getMapSize()]; - icm.getRGBs(palette); - for (int i = 0; i < palette.length; i++) - entries.add(palette[i]); - if (!different && prev != null && !Arrays.equals(palette, prev)) - different = true; - prev = palette; - - IIOMetadata metadata = imageReader.getImageMetadata(index); - Node root = metadata.getAsTree(metadata.getNativeMetadataFormatName()); - Node desc = getChild(root, "ImageDescriptor"); - Node gce = getChild(root, "GraphicControlExtension"); - int blendOp = (index == 0) ? FrameControl.BLEND_SOURCE : FrameControl.BLEND_OVER; - frames.add(new Frame(palette, - new Rectangle(Integer.parseInt(getAttr(desc, "imageLeftPosition")), - Integer.parseInt(getAttr(desc, "imageTopPosition")), - Integer.parseInt(getAttr(desc, "imageWidth")), - Integer.parseInt(getAttr(desc, "imageHeight"))), - Math.max(10 * Integer.parseInt(getAttr(gce, "delayTime")), MIN_DELAY), - mapDisposal(getAttr(gce, "disposalMethod")), - blendOp)); - index++; - } - } catch (IndexOutOfBoundsException e) { - // no more frames - } - - // expand first frame to fit all frames - Frame first = frames.get(0); - if (!first.bounds.getLocation().equals(new Point(0, 0))) - throw new UnsupportedOperationException("TODO: first frame has non-zero origin"); - for (Frame frame : frames) - first.bounds.add(frame.bounds); - - PngWriter w = new PngWriter(out); - boolean paletted = entries.size() <= 256; - int colorType = paletted ? PngConstants.COLOR_TYPE_PALETTE : - PngConstants.COLOR_TYPE_RGB_ALPHA; - w.start(first.bounds.getSize(), colorType, first.palette, frames.size(), numIterations); - if (paletted) { - if (different) - throw new UnsupportedOperationException("implement palette remapping"); - writePaletted(w, imageReader, frames); - } else { - writeTruecolor(w, imageReader, frames); - } - w.finish(); - imageReader.dispose(); - } - - private static byte[] getAppExtension(IIOMetadata metadata, String id, String code) - { - Node root = metadata.getAsTree(metadata.getNativeMetadataFormatName()); - Node extensions = getChild(root, "ApplicationExtensions"); - if (extensions == null) - return null; - for (Node node = extensions.getFirstChild(); node != null; node = node.getNextSibling()) { - if (id.equals(getAttr(node, "applicationID")) && - code.equals(getAttr(node, "authenticationCode"))) - return (byte[])((IIOMetadataNode)node).getUserObject(); - } - return null; - } - - /* - private static Color getGifBackground(ImageReader imageReader) - throws IOException - { - IIOMetadata metadata = imageReader.getStreamMetadata(); - Node globalColorTable = - getChild(metadata.getAsTree(metadata.getNativeMetadataFormatName()), "GlobalColorTable"); - if (globalColorTable == null) - return null; - String index = getAttr(globalColorTable, "backgroundColorIndex"); - for (Node node = globalColorTable.getFirstChild(); node != null; node = node.getNextSibling()) { - if (getAttr(node, "index").equals(index)) { - return new Color(Integer.parseInt(getAttr(node, "red")), - Integer.parseInt(getAttr(node, "green")), - Integer.parseInt(getAttr(node, "blue"))); - } - } - return null; - } - */ - - private static void writePaletted(PngWriter w, ImageReader imageReader, List frames) - throws IOException - { - // TODO: if palette is <= 64 entries, use smaller bit depth - boolean animated = frames.size() > 1; - Frame first = frames.get(0); - ByteArrayOutputStream raw = new ByteArrayOutputStream(); - byte[] row = new byte[first.bounds.width]; - int index = 0; - for (Frame frame : frames) { - int width = frame.bounds.width; - BufferedImage image = pad(imageReader.read(index++), frame.bounds); - raw.reset(); - DeflaterOutputStream defl = new DeflaterOutputStream(raw); - for (int y = 0, height = frame.bounds.height; y < height; y++) { - image.getRaster().getDataElements(0, y, width, 1, row); - defl.write(0); // filter byte - defl.write(row, 0, width); - } - defl.close(); - w.frame(animated, frame, raw.toByteArray()); - } - } - - private static void writeTruecolor(PngWriter w, ImageReader imageReader, List frames) - throws IOException - { - // TODO: could use tRNS instead of alpha channel in some cases for better compression - boolean animated = frames.size() > 1; - Frame first = frames.get(0); - ByteArrayOutputStream raw = new ByteArrayOutputStream(); - byte[] row = new byte[first.bounds.width]; - byte[] rgbs = new byte[4 * row.length]; - byte[] prev = new byte[4 * row.length]; - Filterer filterer = new Filterer(4 * row.length, 4); - int index = 0; - for (Frame frame : frames) { - int[] palette = frame.palette; - int width = frame.bounds.width; - BufferedImage image = pad(imageReader.read(index++), frame.bounds); - raw.reset(); - DataOutputStream defl = new DataOutputStream(new DeflaterOutputStream(raw)); - for (int y = 0, height = frame.bounds.height; y < height; y++) { - image.getRaster().getDataElements(0, y, width, 1, row); - int toX = 0; - for (int x = 0; x < width; x++) { - int argb = palette[0xFF & row[x]]; - rgbs[toX++] = (byte)(0xFF & (argb >>> 16)); - rgbs[toX++] = (byte)(0xFF & (argb >>> 8)); - rgbs[toX++] = (byte)(0xFF & argb); - rgbs[toX++] = (byte)(0xFF & (argb >>> 24)); - } - int filterType = filterer.filter(rgbs, prev, 4 * width); - defl.write(filterType); - defl.write(rgbs, 0, 4 * width); - byte[] t = rgbs; rgbs = prev; prev = t; // swap - } - defl.close(); - w.frame(animated, frame, raw.toByteArray()); - } - } - - private static BufferedImage pad(BufferedImage image, Rectangle bounds) - { - if (image.getWidth() == bounds.width && image.getHeight() == bounds.height) - return image; - BufferedImage padded = - new BufferedImage(image.getColorModel(), - image.getRaster().createCompatibleWritableRaster(bounds.width, bounds.height), - image.isAlphaPremultiplied(), - null); - Graphics2D g = padded.createGraphics(); - g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null, null); - g.dispose(); - return padded; - } - - private static class Filterer - { - private final byte[] work; - private final byte[] best; - private final int pixelStride; - - public Filterer(int maxLength, int pixelStride) - { - work = new byte[maxLength]; - best = new byte[maxLength]; - this.pixelStride = pixelStride; - } - - public int filter(byte[] row, byte[] prev, int length) - { - int bestType = 0; - int bestSum = Integer.MAX_VALUE; - for (int type = 0; type <= 2; type++) { - filter(row, prev, length, type); - int sum = sumBytes(work, length); - if (sum < bestSum) { - bestSum = sum; - bestType = type; - System.arraycopy(work, 0, best, 0, length); - } - } - System.arraycopy(best, 0, row, 0, length); - return bestType; - } - - private static int sumBytes(byte[] bytes, int length) - { - int sum = 0; - for (int i = 0; i < length; i++) - sum += 0xFF & bytes[i]; - return sum; - } - - private void filter(byte[] row, byte[] prev, int length, int type) - { - switch (type) { - case 0: // None - System.arraycopy(row, 0, work, 0, length); - break; - case 1: // Sub - for (int i = 0; i < pixelStride; i++) - work[i] = row[i]; - for (int i = pixelStride, from = 0; i < length; i++, from++) - work[i] = (byte)((row[i] - row[from]) % 256); - break; - case 2: // Up - for (int i = 0; i < length; i++) - work[i] = (byte)((row[i] - prev[i]) % 256); - break; - default: - throw new UnsupportedOperationException("implement me"); - } - } - } - - private static class PngWriter - { - private final DataOutputStream data; - private final ChunkWriter chunk = new ChunkWriter(); - private int seq; - - public PngWriter(File out) - throws IOException - { - this.data = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(out))); - } - - public void start(Dimension size, int colorType, int[] palette, int numFrames, int numIterations) - throws IOException - { - data.writeLong(PngConstants.SIGNATURE); - chunk.start(PngConstants.IHDR); - chunk.writeInt(size.width); - chunk.writeInt(size.height); - chunk.writeByte(8); // bit depth - chunk.writeByte(colorType); - chunk.writeByte(PngConstants.COMPRESSION_BASE); - chunk.writeByte(PngConstants.FILTER_BASE); - chunk.writeByte(PngConstants.INTERLACE_NONE); - chunk.finish(data); - - if (colorType == PngConstants.COLOR_TYPE_PALETTE) { - chunk.start(PngConstants.PLTE); - int numTrans = 0; - int maxTrans = 0; - for (int i = 0; i < palette.length; i++) { - Color color = new Color(palette[i], true); - chunk.writeByte(color.getRed()); - chunk.writeByte(color.getGreen()); - chunk.writeByte(color.getBlue()); - if (color.getAlpha() != 0xFF) { - numTrans++; - maxTrans = i; - } - } - chunk.finish(data); - - if (numTrans > 0) { - chunk.start(PngConstants.tRNS); - for (int i = 0; i <= maxTrans; i++) - chunk.writeByte(palette[i] >>> 24); - chunk.finish(data); - } - } - - if (numFrames > 1) { - chunk.start(AnimatedPngImage.acTL); - chunk.writeInt(numFrames); - chunk.writeInt(numIterations); - chunk.finish(data); - } - } - - public void frame(boolean animated, Frame frame, byte[] bytes) - throws IOException - { - if (animated) { - chunk.start(AnimatedPngImage.fcTL); - chunk.writeInt(seq++); - chunk.writeInt(frame.bounds.width); - chunk.writeInt(frame.bounds.height); - chunk.writeInt(frame.bounds.x); - chunk.writeInt(frame.bounds.y); - chunk.writeShort(frame.delayTime); - chunk.writeShort(1000); - chunk.writeByte(frame.dispose); - chunk.writeByte(frame.blend); - chunk.finish(data); - if (seq == 1) { - chunk.start(PngConstants.IDAT); - } else { - chunk.start(AnimatedPngImage.fdAT); - chunk.writeInt(seq++); - } - chunk.write(bytes); - chunk.finish(data); - } else { - chunk.start(PngConstants.IDAT); - chunk.write(bytes); - chunk.finish(data); - } - } - - public void finish() - throws IOException - { - chunk.start(PngConstants.IEND); - chunk.finish(data); - data.close(); - } - } - - private static Node getChild(Node node, String name) - { - for (node = node.getFirstChild(); node != null; node = node.getNextSibling()) - if (name.equals(node.getNodeName())) - break; - return node; - } - - private static String getAttr(Node element, String name) - { - return element.getAttributes().getNamedItem(name).getNodeValue(); - } - - private static int mapDisposal(String gifDisposalMethod) - { - if (gifDisposalMethod.equals("restoreToBackgroundColor")) - return FrameControl.DISPOSE_BACKGROUND; - if (gifDisposalMethod.equals("restoreToPrevious")) - return FrameControl.DISPOSE_PREVIOUS; - return FrameControl.DISPOSE_NONE; - } - - private static class Frame - { - final int[] palette; - final Rectangle bounds; - final int delayTime; - final int dispose; - final int blend; - - public Frame(int[] palette, Rectangle bounds, int delayTime, int dispose, int blend) - { - this.palette = palette; - this.bounds = bounds; - this.delayTime = delayTime; - this.dispose = dispose; - this.blend = blend; - } - } -} diff --git a/javapng2/src/examples/com/sixlegs/png/examples/ArgumentProcessor.java b/javapng2/src/examples/com/sixlegs/png/examples/ArgumentProcessor.java deleted file mode 100644 index 9ddf233..0000000 --- a/javapng2/src/examples/com/sixlegs/png/examples/ArgumentProcessor.java +++ /dev/null @@ -1,218 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.examples; - -import java.util.*; - -class ArgumentProcessor -{ - private static final Map PARSERS = new HashMap(); - - static - { - PARSERS.put(Boolean.class.getName(), new Parser() { - public Object parse(String arg) { return Boolean.valueOf(arg); } - }); - PARSERS.put(String.class.getName(), new Parser() { - public Object parse(String arg) { return arg; } - }); - PARSERS.put(Integer.class.getName(), new Parser() { - public Object parse(String arg) { return Integer.valueOf(arg, 10); } - }); - PARSERS.put(Short.class.getName(), new Parser() { - public Object parse(String arg) { return Short.valueOf(arg, 10); } - }); - PARSERS.put(Byte.class.getName(), new Parser() { - public Object parse(String arg) { return Byte.valueOf(arg, 10); } - }); - PARSERS.put(Long.class.getName(), new Parser() { - public Object parse(String arg) { return Long.valueOf(arg, 10); } - }); - PARSERS.put(Character.class.getName(), new Parser() { - public Object parse(String arg) { - if (arg.length() != 1) - throw new IllegalArgumentException("requires single character"); - return arg.charAt(0); - } - }); - } - - abstract private static class Parser - { - abstract public Object parse(String arg); - } - - private final Map options = new HashMap(); - - public ArgumentProcessor(Option... options) - { - for (Option opt : options) - this.options.put(opt.name, new Option(opt)); - } - - // mutates args - // throws exception if arguments are invalid - public Map parse(List src, List dst) - { - Map result = new HashMap(); - int index = 0; - while (index < src.size()) { - String arg = src.get(index); - if (arg.startsWith("--")) { - index++; - if (arg.equals("--")) - break; - String name = arg.substring(2); - Option opt = options.get(name); - if (opt == null) - throw new IllegalArgumentException("Unknown argument " + arg); - if (opt.type.equals(Boolean.class)) { - result.put(name, Boolean.TRUE); - } else { - String peek = (index < src.size()) ? src.get(index) : null; - if (peek == null || peek.startsWith("--")) - throw new IllegalArgumentException("Expecting argument for option " + name); - index++; - result.put(name, opt.parse(peek)); - } - } else { - break; - } - } - for (Option opt : options.values()) { - if (!result.containsKey(opt.name)) { - if (opt.required) - throw new IllegalArgumentException("--" + opt.name + " is required"); - result.put(opt.name, opt.defaultValue); - } - } - - List tmp = new ArrayList(); - tmp.addAll(src.subList(index, src.size())); - dst.clear(); - dst.addAll(tmp); - return result; - } - - public static Option option(String name) - { - return new Option(name); - } - - public static Option option(String name, Class type) - { - return new Option(name, type); - } - - public static class Option - { - final String name; - final Class type; - boolean required = true; - Object defaultValue; - Comparable start; - Comparable end; - - Option(Option option) - { - name = option.name; - type = option.type; - required = option.required; - defaultValue = option.defaultValue; - start = option.start; - end = option.end; - } - - Option(String name) - { - this(name, Boolean.class); - defaultValue(Boolean.FALSE); - } - - Option(String name, Class type) - { - if (!PARSERS.containsKey(type.getName())) - throw new IllegalArgumentException("Unsupported type " + type); - if (name.startsWith("-")) - throw new IllegalArgumentException("Option names cannot start with a hyphen"); - this.name = name; - this.type = type; - } - - public Option defaultValue(Object value) - { - checkType(value); - required = false; - defaultValue = value; - return this; - } - - public Option range(Comparable start, Comparable end) - { - checkType(start); - checkType(end); - if (!Comparable.class.isAssignableFrom(type)) - throw new IllegalArgumentException(type + " is not Comparable"); - if (start.compareTo(end) >= 0) - throw new IllegalArgumentException(start + " is not less than " + end); - this.start = start; - this.end = end; - return this; - } - - private Object parse(String arg) - { - try { - Object value = PARSERS.get(type.getName()).parse(arg); - if (start != null) { - Comparable comp = (Comparable)value; - if (comp.compareTo(start) < 0 || comp.compareTo(end) > 0) - throw new IllegalArgumentException(value + " is not between " + start + " and " + end); - } - return value; - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException(name + " " + e.getMessage()); - } - } - - private void checkType(Object value) - { - if (!type.isAssignableFrom(value.getClass())) - throw new IllegalArgumentException(name + " value " + value + " is not assignable to " + type.getName()); - } - } -} diff --git a/javapng2/src/examples/com/sixlegs/png/examples/ChunkWriter.java b/javapng2/src/examples/com/sixlegs/png/examples/ChunkWriter.java deleted file mode 100644 index df26dd2..0000000 --- a/javapng2/src/examples/com/sixlegs/png/examples/ChunkWriter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.examples; - -import java.io.*; -import java.util.zip.*; - -class ChunkWriter -extends DataOutputStream -{ - public ChunkWriter() - { - super(new ByteArrayOutputStream()); - } - - public void start(int type) - throws IOException - { - ((ByteArrayOutputStream)out).reset(); - writeInt(type); - } - - public int finish(DataOutput data) - throws IOException - { - byte[] bytes = ((ByteArrayOutputStream)out).toByteArray(); - int crc = crc(bytes); - data.writeInt(bytes.length - 4); - data.write(bytes); - data.writeInt(crc); - return crc; - } - - private static int crc(byte[] bytes) - throws IOException - { - CheckedOutputStream checked = new CheckedOutputStream(new NullOutputStream(), new CRC32()); - DataOutputStream data = new DataOutputStream(checked); - data.write(bytes); - data.close(); - return (int)checked.getChecksum().getValue(); - } - - private static class NullOutputStream extends OutputStream - { - public void write(int b) { } - public void write(byte[] b) { } - public void write(byte[] b, int off, int len) { } - } -} diff --git a/javapng2/src/examples/com/sixlegs/png/examples/ExtractFrames.java b/javapng2/src/examples/com/sixlegs/png/examples/ExtractFrames.java deleted file mode 100644 index de1abf8..0000000 --- a/javapng2/src/examples/com/sixlegs/png/examples/ExtractFrames.java +++ /dev/null @@ -1,181 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.examples; - -import com.sixlegs.png.*; -import java.awt.image.BufferedImage; -import java.io.*; -import java.text.DecimalFormat; -import java.util.*; - -public class ExtractFrames -{ - public static void main(String[] args) - throws Exception - { - DecimalFormat fmt = new DecimalFormat("000"); - for (int i = 0; i < args.length; i++) { - File in = new File(args[i]); - PngSplitter splitter = new PngSplitter(in); - int numFrames = splitter.getNumFrames(); - for (int frame = 0; frame < numFrames; frame++) { - File out = new File(fmt.format(frame) + "-" + in.getName()); - if (out.exists()) { - System.err.println("File exists, skipping: " + out); - break; - } - System.err.println("Writing " + out); - splitter.write(out, frame); - } - } - } - - private static class PngSplitter - extends PngImage - { - private static final PngConfig CONFIG = new PngConfig.Builder() - .warningsFatal(true) - .readLimit(PngConfig.READ_EXCEPT_DATA) - .build(); - - private File in; - private List commonBefore = new ArrayList(); - private List commonAfter = new ArrayList(); - private List data = new ArrayList(); - private List bySequence = new ArrayList(); - private List> byFrame = new ArrayList>(); - private byte[] buf = new byte[0x2000]; - - public PngSplitter(File in) - throws IOException - { - super(CONFIG); - this.in = in; - read(in); - byFrame.add(data); - List cur = null; - for (Chunk chunk : bySequence) { - if (chunk.type == AnimatedPngImage.fcTL) { - byFrame.add(cur = new ArrayList()); - } else { - cur.add(chunk); - } - } - } - - public int getNumFrames() - { - return byFrame.size(); - } - - public void write(File file, int index) - throws IOException - { - DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); - ChunkWriter cw = new ChunkWriter(); - try { - out.writeLong(PngConstants.SIGNATURE); - echo(out, commonBefore); - echo(out, byFrame.get(index)); - echo(out, commonAfter); - } finally { - out.close(); - } - } - - private void echo(DataOutput out, List chunks) - throws IOException - { - ChunkWriter cw = new ChunkWriter(); - RandomAccessFile rf = new RandomAccessFile(in, "r"); - try { - for (Chunk chunk : chunks) { - cw.start(chunk.type); - rf.seek(chunk.offset); - rf.readFully(buf, 0, chunk.length); - cw.write(buf, 0, chunk.length); - cw.close(); - cw.finish(out); - } - } finally { - rf.close(); - } - } - - protected void readChunk(int type, DataInput in, long offset, int length) - throws IOException - { - Chunk chunk = new Chunk(); - chunk.type = type; - chunk.offset = offset; - chunk.length = length; - switch (type) { - case PngConstants.IDAT: - data.add(chunk); - break; - case AnimatedPngImage.acTL: - break; - case AnimatedPngImage.fdAT: - chunk.type = PngConstants.IDAT; - chunk.offset += 4; - chunk.length -= 4; - /* fall-through */ - case AnimatedPngImage.fcTL: - int seq = in.readInt(); - while (bySequence.size() <= seq) - bySequence.add(null); - bySequence.set(seq, chunk); - break; - default: - (data.isEmpty() ? commonBefore : commonAfter).add(chunk); - super.readChunk(type, in, offset, length); - } - } - } - - private static class Chunk - { - int type; - long offset; - int length; - - public String toString() - { - return PngConstants.getChunkName(type); - } - } -} diff --git a/javapng2/src/examples/com/sixlegs/png/examples/Png2AnimatedPng.java b/javapng2/src/examples/com/sixlegs/png/examples/Png2AnimatedPng.java deleted file mode 100644 index 1a4f8f0..0000000 --- a/javapng2/src/examples/com/sixlegs/png/examples/Png2AnimatedPng.java +++ /dev/null @@ -1,149 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.examples; - -import com.sixlegs.png.*; -import java.awt.image.*; -import java.io.*; -import java.util.*; -import static com.sixlegs.png.examples.ArgumentProcessor.*; - -// TODO: this is a work in progress -// TODO: support crop -public class Png2AnimatedPng -{ - private static final ArgumentProcessor PROC; - - static - { - PROC = new ArgumentProcessor( - option("iter", Integer.class).defaultValue(0).range(0, Integer.MAX_VALUE), - option("delay", Integer.class).range(0, (int)Short.MAX_VALUE), - option("blend", Integer.class).defaultValue(0).range(0, 1), - option("dispose", Integer.class).defaultValue(0).range(0, 2), - option("skip"), - option("crop") - ); - } - - public static void main(String[] args) throws Exception { - try { - run(args); - } catch (Exception e) { - System.err.println(e.getMessage()); - } - } - - public static void run(String... orig) throws Exception { - List args = new ArrayList(); - Map opts = PROC.parse(Arrays.asList(orig), args); - final int iter = ((Number)opts.get("iter")).intValue(); - final int delay = ((Number)opts.get("delay")).intValue(); - final int blend = ((Number)opts.get("blend")).intValue(); - final int dispose = ((Number)opts.get("dispose")).intValue(); - final boolean skip = ((Boolean)opts.get("skip")).booleanValue(); - - // TODO: handle numIterations, delay, skip - final List files = new ArrayList(); - if (args.size() < 2) - throw new IllegalArgumentException("Not enough arguments"); - for (String arg : args) - files.add(new File(arg)); - File target = files.remove(files.size() - 1); - - final DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(target))); - final PngConfig config = new PngConfig.Builder().readLimit(PngConfig.READ_EXCEPT_DATA).build(); - out.writeLong(PngConstants.SIGNATURE); - (new PngImage(config) { - private ChunkWriter chunk = new ChunkWriter(); - private int seq = 0; - protected void readChunk(int type, DataInput in, long offset, int length) throws IOException { - byte[] data = new byte[length]; - in.readFully(data); - - if (type == PngConstants.IEND) { - for (File file : files.subList(1, files.size())) { - nextFrame(); - (new PngImage(config) { - protected void readChunk(int type, DataInput in, long offset, int length) throws IOException { - if (type == PngConstants.IDAT) { - byte[] data = new byte[length]; - in.readFully(data); - chunk.start(AnimatedPngImage.fdAT); - chunk.writeInt(seq++); - chunk.write(data); - chunk.finish(out); - } else { - super.readChunk(type, in, offset, length); - } - } - }).read(file); - } - } - - chunk.start(type); - chunk.write(data); - chunk.finish(out); - super.readChunk(type, new DataInputStream(new ByteArrayInputStream(data)), offset, length); - - if (type == PngConstants.IHDR) { - chunk.start(AnimatedPngImage.acTL); - chunk.writeInt(files.size()); - chunk.writeInt(iter); - chunk.finish(out); - if (!skip) - nextFrame(); - } - } - - private void nextFrame() throws IOException { - chunk.start(AnimatedPngImage.fcTL); - chunk.writeInt(seq++); - chunk.writeInt(getWidth()); - chunk.writeInt(getHeight()); - chunk.writeInt(0); - chunk.writeInt(0); - chunk.writeShort(delay); - chunk.writeShort(1000); - chunk.writeByte((byte)dispose); - chunk.writeByte((!skip && seq == 1) ? 0 : (byte)blend); - chunk.finish(out); - } - }).read(files.get(0)); - out.close(); - } -} diff --git a/javapng2/src/examples/com/sixlegs/png/examples/PngCheck.java b/javapng2/src/examples/com/sixlegs/png/examples/PngCheck.java deleted file mode 100644 index 5863791..0000000 --- a/javapng2/src/examples/com/sixlegs/png/examples/PngCheck.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.sixlegs.png.examples; - -import com.sixlegs.png.*; -import java.io.IOException; -import java.io.File; -import java.util.*; - -public class PngCheck -{ - public static void main(String[] args) - throws IOException - { - (new PngImage(new PngConfig.Builder().readLimit(PngConfig.READ_UNTIL_DATA).build()){ - public void handleWarning(PngException e) { - System.out.println("Warning: " + e.getMessage()); - } - }).read(new File(args[0])); - } -} diff --git a/javapng2/src/examples/com/sixlegs/png/examples/WriteAnimatedDemos.java b/javapng2/src/examples/com/sixlegs/png/examples/WriteAnimatedDemos.java deleted file mode 100644 index fa26706..0000000 --- a/javapng2/src/examples/com/sixlegs/png/examples/WriteAnimatedDemos.java +++ /dev/null @@ -1,105 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.examples; - -import java.awt.*; -import java.awt.geom.*; -import java.awt.image.*; -import java.io.*; -import java.util.Arrays; - -public class WriteAnimatedDemos -{ - public static void main(String[] args) - throws Exception - { - Dimension size = new Dimension(200, 200); - Png2AnimatedPng.run( - "--delay", "1000", - "--blend", "1", - "--crop", - writeBlank(size), - writeFrame(size, 0x55FF0000, -90), - writeFrame(size, 0x5500FF00, 30), - writeFrame(size, 0x550000FF, 150), - args[0] - ); - } - - private static String writeBlank(Dimension size) - throws IOException - { - File file = File.createTempFile("demo", ".png"); - file.deleteOnExit(); - javax.imageio.ImageIO.write(new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB), - "PNG", file); - return file.getPath(); - } - - private static String writeFrame(Dimension size, int rgba, int angle) - throws IOException - { - Point center = new Point(size.width / 2, size.height / 2 + 10); - Shape ellipse = createEllipse(getPoint(center, size.width / 5, angle), size.width / 4); - - BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g.setColor(new Color(rgba)); - g.draw(ellipse); - g.setColor(new Color(rgba, true)); - g.fill(ellipse); - g.dispose(); - - File file = File.createTempFile("demo", ".png"); - file.deleteOnExit(); - javax.imageio.ImageIO.write(image, "PNG", file); - return file.getPath(); - } - - private static Point getPoint(Point center, int offset, int angle) - { - double theta = Math.toRadians(angle); - return new Point(center.x + (int)Math.round(offset * Math.cos(theta)), - center.y + (int)Math.round(offset * Math.sin(theta))); - } - - private static Ellipse2D createEllipse(Point center, int r) - { - return new Ellipse2D.Float(center.x - r, center.y - r, r * 2, r * 2); - } -} diff --git a/javapng2/src/iio/com/sixlegs/png/iio/PngImageMetadata.java b/javapng2/src/iio/com/sixlegs/png/iio/PngImageMetadata.java deleted file mode 100644 index 63c43e4..0000000 --- a/javapng2/src/iio/com/sixlegs/png/iio/PngImageMetadata.java +++ /dev/null @@ -1,716 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 2006 Dimitri Koussa - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.iio; - -import com.sixlegs.png.*; -import java.util.*; -import javax.imageio.metadata.*; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class PngImageMetadata -extends IIOMetadata -{ - // Format defined by sun - with bug - static final String nativeMetadataFormatName = - "javax_imageio_png_1.0"; - - private Map props; - private Map unknownChunks; - private Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - - PngImageMetadata(Map props, Map unknownChunks) - { - super(true, nativeMetadataFormatName, - "com.sixlegs.png.iio.PngImageMetadata", - null, null); - this.props = props; - this.unknownChunks = unknownChunks; - } - - public IIOMetadataFormat getMetadataFormat(String formatName) - { - if (formatName.equals(nativeMetadataFormatName)) - return PngImageMetadataFormat.getDefaultInstance(); - if (formatName.equals(IIOMetadataFormatImpl.standardMetadataFormatName)) - return IIOMetadataFormatImpl.getStandardFormatInstance(); - throw new IllegalArgumentException(formatName); - } - - public Node getAsTree(String formatName) - { - if (formatName.equals(nativeMetadataFormatName)) - return getNativeTree(); - if (formatName.equals(IIOMetadataFormatImpl.standardMetadataFormatName)) - return getStandardTree(); - throw new IllegalArgumentException(formatName); - } - - public boolean isReadOnly() - { - //TODO - return true; - } - - public void reset() - { - //TODO - } - - public void mergeTree(String formatName, Node root) - { - //TODO - } - - private static void appendSimpleNode(IIOMetadataNode parent, String name, String attName, String attValue) - { - IIOMetadataNode node = new IIOMetadataNode(name); - node.setAttribute(attName, attValue); - parent.appendChild(node); - } - - // ----------- Methods needed to support the Standard metadata format - // - // The DTD is available from - // http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/metadata/doc-files/standard_metadata.html - // - - // Used to separate elements such as in a List of Integers - private static final String list_separator = " "; - - protected IIOMetadataNode getStandardChromaNode() - { - IIOMetadataNode parent = new IIOMetadataNode("Chroma"); - - int colorType = getInt(PngConstants.COLOR_TYPE); - appendSimpleNode(parent, "ColorSpaceType", "name", - ((colorType & 2) != 0) ? "RGB" : "GRAY"); - appendSimpleNode(parent, "NumChannels", "value", String.valueOf(getNumChannels())); - - Float gamma = (Float)get(PngConstants.GAMMA); - if (gamma != null) - appendSimpleNode(parent, "Gamma", "value", gamma.toString()); - appendSimpleNode(parent, "BlackIsZero", "value", "true"); - - IIOMetadataNode node = getPalette("Palette", "PaletteEntry"); - if (node != null) { - byte[] alpha = (byte[])get(PngConstants.PALETTE_ALPHA); - if (alpha != null) { - NodeList children = node.getChildNodes(); - for (int i = 0, len = children.getLength(); i < len; i++) { - int alphaValue = (i < alpha.length) ? (0xFF & alpha[i]) : 255; - ((IIOMetadataNode)children.item(i)).setAttribute("alpha", String.valueOf(alphaValue)); - } - } - parent.appendChild(node); - } - - int[] bg = (int[])get(PngConstants.BACKGROUND); - if (bg != null) { - if (colorType == PngConstants.COLOR_TYPE_PALETTE) { - appendSimpleNode(parent, "BackgroundIndex", "value", String.valueOf(bg[0])); - } else { - node = new IIOMetadataNode("BackgroundColor"); - int r, g, b; - if (bg.length == 3) { - r = bg[0]; - g = bg[1]; - b = bg[2]; - } else { - r = g = b = bg[0]; - } - node.setAttribute("red", String.valueOf(r)); - node.setAttribute("green", String.valueOf(g)); - node.setAttribute("blue", String.valueOf(b)); - parent.appendChild(node); - } - } - return parent; - } - - private int getNumChannels() - { - switch (getInt(PngConstants.COLOR_TYPE)) { - case PngConstants.COLOR_TYPE_GRAY: - return 1; - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - return 2; - case PngConstants.COLOR_TYPE_PALETTE: - return (get(PngConstants.PALETTE_ALPHA) != null) ? 4 : 3; - case PngConstants.COLOR_TYPE_RGB: - return 3; - case PngConstants.COLOR_TYPE_RGB_ALPHA: - return 4; - } - return 0; - } - - protected IIOMetadataNode getStandardCompressionNode() - { - IIOMetadataNode parent = new IIOMetadataNode("Compression"); - appendSimpleNode(parent, "CompressionTypeName", "value", "deflate"); - appendSimpleNode(parent, "Lossless", "value", "true"); - appendSimpleNode(parent, "NumProgressiveScans", "value", isInterlaced() ? "7" : "1"); - return parent; - } - - protected IIOMetadataNode getStandardDataNode() - { - int colorType = getInt(PngConstants.COLOR_TYPE); - IIOMetadataNode parent = new IIOMetadataNode("Data"); - appendSimpleNode(parent, "PlanarConfiguration", "value", "PixelInterleaved"); - appendSimpleNode(parent, "SampleFormat", "value", - (colorType == PngConstants.COLOR_TYPE_PALETTE) ? "Index" : "UnsignedIntegral"); - appendSimpleNode(parent, "BitsPerSample", "value", getBitsPerSample()); - - byte[] sbit = (byte[])get(PngConstants.SIGNIFICANT_BITS); - if (sbit != null) { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < sbit.length; i++) { - if (i > 0) - sb.append(' '); - sb.append(sbit[i]); - } - appendSimpleNode(parent, "SignificantBitsPerSample", "value", sb.toString()); - } - return parent; - } - - private String getBitsPerSample() - { - String d = String.valueOf(getInt(PngConstants.BIT_DEPTH)); - switch (getInt(PngConstants.COLOR_TYPE)) { - case PngConstants.COLOR_TYPE_GRAY: - return d; - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - return d + " " + d; - case PngConstants.COLOR_TYPE_RGB: - return d + " " + d + " " + d; - case PngConstants.COLOR_TYPE_RGB_ALPHA: - return d + " " + d + " " + d + " " + d; - case PngConstants.COLOR_TYPE_PALETTE: - int size = getPaletteSize(((byte[])get(PngConstants.PALETTE)).length / 3); - d = String.valueOf((int)Math.round(Math.log(size) / Math.log(2))); - if (get(PngConstants.PALETTE_ALPHA) != null) - return d + " " + d + " " + d + " " + d; - return d + " " + d + " " + d; - } - return null; - } - - protected IIOMetadataNode getStandardDimensionNode() - { - IIOMetadataNode parent = new IIOMetadataNode("Dimension"); - float aspect = 1.0f; - Integer unit = (Integer)get(PngConstants.UNIT); - if (unit != null) { - aspect = (float)getInt(PngConstants.PIXELS_PER_UNIT_X) / - getInt(PngConstants.PIXELS_PER_UNIT_Y); - } - appendSimpleNode(parent, "PixelAspectRatio", "value", String.valueOf(aspect)); - appendSimpleNode(parent, "ImageOrientation", "value", "Normal"); -// appendSimpleNode(parent, "HorizontalScreenSize", "value", -// String.valueOf(getInt(PngConstants.WIDTH))); -// appendSimpleNode(parent, "VerticalScreenSize", "value", -// String.valueOf(getInt(PngConstants.HEIGHT))); - if (unit != null && unit.intValue() == PngConstants.UNIT_METER) { - appendSimpleNode(parent, "HorizontalPixelSize", "value", - String.valueOf(1000f / getInt(PngConstants.PIXELS_PER_UNIT_X))); - appendSimpleNode(parent, "VerticalPixelSize", "value", - String.valueOf(1000f / getInt(PngConstants.PIXELS_PER_UNIT_Y))); - } - return parent; - } - - protected IIOMetadataNode getStandardDocumentNode() - { - IIOMetadataNode time = getTime("ImageModificationTime"); - if (time != null) { - IIOMetadataNode parent = new IIOMetadataNode("Document"); - parent.appendChild(time); - return parent; - } - return null; - } - - protected IIOMetadataNode getStandardTextNode() - { - List textChunks = (List)get(PngConstants.TEXT_CHUNKS); - if (textChunks == null) - return null; - - IIOMetadataNode node = new IIOMetadataNode("Text"); - for (Iterator it = textChunks.iterator(); it.hasNext();) { - TextChunk chunk = (TextChunk)it.next(); - IIOMetadataNode child = new IIOMetadataNode("TextEntry"); - child.setAttribute("keyword", chunk.getKeyword()); - child.setAttribute("value", chunk.getText()); - - if (chunk.getType() == PngConstants.tEXt) - child.setAttribute("encoding", "ISO-8859-1"); - - //FIXME what about compressed iTXt? - if (chunk.getType() == PngConstants.zTXt) { - child.setAttribute("compression", "deflate"); - } else { - child.setAttribute("compression", "none"); - } - node.appendChild(child); - } - return node; - } - - protected IIOMetadataNode getStandardTransparencyNode() - { - int colorType = getInt(PngConstants.COLOR_TYPE); - IIOMetadataNode parent = new IIOMetadataNode("Transparency"); - - boolean hasAlpha = colorType == PngConstants.COLOR_TYPE_RGB_ALPHA || - colorType == PngConstants.COLOR_TYPE_GRAY_ALPHA || - get(PngConstants.PALETTE_ALPHA) != null; - // TODO: sun has spelling error: nonpremultipled instead of premultiplied - appendSimpleNode(parent, "Alpha", "value", hasAlpha ? "nonpremultipled" : "none"); - - Object transObj = get(PngConstants.TRANSPARENCY); - if (transObj instanceof int[]) { - int[] trans = (int[])transObj; - String value; - if (trans.length == 3) { - value = trans[0] + " " + trans[1] + " " + trans[2]; - } else { - value = String.valueOf(trans[0]); - } - appendSimpleNode(parent, "TransparencyColor", "value", value); - } else if (get(PngConstants.PALETTE_ALPHA) != null) { - // hack - parent.appendChild(new IIOMetadataNode("TransparencyColor")); - } - return parent; - } - - // ----------- Methods needed to support the Native metadata format - // - // This format is very similar to the javax_imageio_png_1.0 - // - // It differs in that it is not susceptible to the bug described here - // http://developer.java.sun.com/developer/bugParade/bugs/4518989.html - // - - private IIOMetadataNode getNativeTree() - { - IIOMetadataNode root = new IIOMetadataNode(nativeMetadataFormatName); - add_IHDR(root); - add_PLTE(root); - add_bKGD(root); - add_cHRM(root); - add_gAMA(root); - add_hIST(root); - add_iCCP(root); - add_pHYS(root); - add_sBIT(root); - add_sRGB(root); - add_tIME(root); - add_tRNS(root); - add_text_chunks(root); - add_unknown_chunks(root); - return root; - } - - private int getInt(String name) - { - return ((Number)get(name)).intValue(); - } - - private Object get(String name) - { - return props.get(name); - } - - private void add_IHDR(IIOMetadataNode root) - { - IIOMetadataNode node = new IIOMetadataNode("IHDR"); - node.setAttribute("width", String.valueOf(getInt(PngConstants.WIDTH))); - node.setAttribute("height", String.valueOf(getInt(PngConstants.HEIGHT))); - node.setAttribute("bitDepth", String.valueOf(getInt(PngConstants.BIT_DEPTH))); - node.setAttribute("colorType", getColorType(getInt(PngConstants.COLOR_TYPE))); - node.setAttribute("compressionMethod", "deflate"); - node.setAttribute("filterMethod", "adaptive"); - node.setAttribute("interlaceMethod", isInterlaced() ? "adam7" : "none"); - root.appendChild(node); - } - - private boolean isInterlaced() - { - return getInt(PngConstants.INTERLACE) == PngConstants.INTERLACE_ADAM7; - } - - private static String getColorType(int colorType) - { - switch (colorType) { - case PngConstants.COLOR_TYPE_GRAY: - return "Grayscale"; - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - return "GrayAlpha"; - case PngConstants.COLOR_TYPE_PALETTE: - return "Palette"; - case PngConstants.COLOR_TYPE_RGB: - return "RGB"; - case PngConstants.COLOR_TYPE_RGB_ALPHA: - return "RGBAlpha"; - } - return null; - } - - private void add_PLTE(IIOMetadataNode root) - { - IIOMetadataNode node = getPalette("PLTE", "PLTEEntry"); - if (node != null) - root.appendChild(node); - } - - private IIOMetadataNode getPalette(String nodeName, String entryName) - { - byte[] palette = (byte[])get(PngConstants.PALETTE); - if (palette == null) - return null; - - IIOMetadataNode node = new IIOMetadataNode(nodeName); - int entries = palette.length / 3; - int extraEntries = getPaletteSize(entries) - entries; - - int index = 0; - while (index < palette.length) { - IIOMetadataNode entry = new IIOMetadataNode(entryName); - add_PaletteEntry(node,entryName, index / 3, - 0xFF & palette[index++], - 0xFF & palette[index++], - 0xFF & palette[index++]); - } - for (int i = 0; i < extraEntries; i++) - add_PaletteEntry(node, entryName, i + entries, 0, 0, 0); - return node; - } - - private void add_PaletteEntry(IIOMetadataNode root, String name, int i, int r, int g, int b) - { - IIOMetadataNode node = new IIOMetadataNode(name); - node.setAttribute("index", Integer.toString(i)); - node.setAttribute("red", Integer.toString(r)); - node.setAttribute("green", Integer.toString(g)); - node.setAttribute("blue", Integer.toString(b)); - root.appendChild(node); - } - - // Sun seems to insist on having extra (enpty) palette entries - private static int getPaletteSize(int entries) - { - if (entries == 0) - return 0; - if (entries <= 2) - return 2; - if (entries <= 4) - return 4; - if (entries <= 16) - return 16; - return 256; - } - - private void add_gAMA(IIOMetadataNode root) - { - Float gamma = (Float)get(PngConstants.GAMMA); - if (gamma == null) - return; - IIOMetadataNode node = new IIOMetadataNode("gAMA"); - node.setAttribute("value", formatFloat(gamma.floatValue())); - root.appendChild(node); - } - - private void add_tIME(IIOMetadataNode root) - { - IIOMetadataNode node = getTime("tIME"); - if (node != null) - root.appendChild(node); - } - - private IIOMetadataNode getTime(String nodeName) - { - Date time = (Date)get(PngConstants.TIME); - if (time == null) - return null; - IIOMetadataNode node = new IIOMetadataNode(nodeName); - cal.setTime(time); - node.setAttribute("year", String.valueOf(cal.get(Calendar.YEAR))); - node.setAttribute("month", String.valueOf(cal.get(Calendar.MONTH) + 1)); - node.setAttribute("day", String.valueOf(cal.get(Calendar.DAY_OF_MONTH))); - node.setAttribute("hour", String.valueOf(cal.get(Calendar.HOUR_OF_DAY))); - node.setAttribute("minute", String.valueOf(cal.get(Calendar.MINUTE))); - node.setAttribute("second", String.valueOf(cal.get(Calendar.SECOND))); - return node; - } - - private void add_pHYS(IIOMetadataNode root) - { - if (!props.containsKey(PngConstants.PIXELS_PER_UNIT_X)) - return; - IIOMetadataNode node = new IIOMetadataNode("pHYS"); - node.setAttribute("pixelsPerUnitXAxis", - String.valueOf(getInt(PngConstants.PIXELS_PER_UNIT_X))); - node.setAttribute("pixelsPerUnitYAxis", - String.valueOf(getInt(PngConstants.PIXELS_PER_UNIT_Y))); - boolean meter = getInt(PngConstants.UNIT) == PngConstants.UNIT_METER; - node.setAttribute("unitSpecifier", meter ? "meter" : "unknown"); - root.appendChild(node); - } - - private void add_bKGD(IIOMetadataNode root) - { - int[] background = (int[])get(PngConstants.BACKGROUND); - if (background == null) - return; - - IIOMetadataNode node = new IIOMetadataNode("bKGD"); - IIOMetadataNode child = null; - switch (getInt(PngConstants.COLOR_TYPE)) { - case PngConstants.COLOR_TYPE_GRAY: - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - child = new IIOMetadataNode("bKGD_Grayscale"); - child.setAttribute("gray", String.valueOf(background[0])); - break; - case PngConstants.COLOR_TYPE_RGB: - case PngConstants.COLOR_TYPE_RGB_ALPHA: - child = new IIOMetadataNode("bKGD_RGB"); - child.setAttribute("red", String.valueOf(background[0])); - child.setAttribute("green", String.valueOf(background[1])); - child.setAttribute("blue", String.valueOf(background[2])); - break; - case PngConstants.COLOR_TYPE_PALETTE: - child = new IIOMetadataNode("bKGD_Palette"); - child.setAttribute("index", String.valueOf(background[0])); - break; - } - node.appendChild(child); - root.appendChild(node); - } - - private void add_cHRM(IIOMetadataNode root) - { - float[] chrom = (float[])get(PngConstants.CHROMATICITY); - if (chrom == null) - return; - - IIOMetadataNode node = new IIOMetadataNode("cHRM"); - node.setAttribute("whitePointX", formatFloat(chrom[0])); - node.setAttribute("whitePointY", formatFloat(chrom[1])); - node.setAttribute("redX", formatFloat(chrom[2])); - node.setAttribute("redY", formatFloat(chrom[3])); - node.setAttribute("greenX", formatFloat(chrom[4])); - node.setAttribute("greenY", formatFloat(chrom[5])); - node.setAttribute("blueX", formatFloat(chrom[6])); - node.setAttribute("blueY", formatFloat(chrom[7])); - root.appendChild(node); - } - - private static String formatFloat(float value) - { - return String.valueOf((int)Math.round(value * 1e5)); - } - - private void add_tRNS(IIOMetadataNode root) - { - Object trans = get(PngConstants.TRANSPARENCY); - byte[] alpha = (byte[])get(PngConstants.PALETTE_ALPHA); - if (trans == null && alpha == null) - return; - - IIOMetadataNode node = new IIOMetadataNode("tRNS"); - IIOMetadataNode child = null; - - switch (getInt(PngConstants.COLOR_TYPE)) { - case PngConstants.COLOR_TYPE_GRAY: - child = new IIOMetadataNode("tRNS_Grayscale"); - child.setAttribute("gray", String.valueOf(((int[])trans)[0])); - break; - - case PngConstants.COLOR_TYPE_RGB: - child = new IIOMetadataNode("tRNS_RGB"); - child.setAttribute("red", String.valueOf(((int[])trans)[0])); - child.setAttribute("green", String.valueOf(((int[])trans)[1])); - child.setAttribute("blue", String.valueOf(((int[])trans)[2])); - break; - - case PngConstants.COLOR_TYPE_PALETTE: - child = new IIOMetadataNode("tRNS_Palette"); - for (int i = 0; i < alpha.length; i++) { - IIOMetadataNode entry = new IIOMetadataNode("tRNS_PaletteEntry"); - entry.setAttribute("index", String.valueOf(i)); - entry.setAttribute("alpha", String.valueOf(alpha[i])); - child.appendChild(entry); - } - break; - } - node.appendChild(child); - root.appendChild(node); - } - - private void add_sBIT(IIOMetadataNode root) - { - byte[] sbit = (byte[])get(PngConstants.SIGNIFICANT_BITS); - if (sbit == null) - return; - - IIOMetadataNode node = new IIOMetadataNode("sBIT"); - int colorType = getInt(PngConstants.COLOR_TYPE); - IIOMetadataNode child = new IIOMetadataNode("sBIT_" + getColorType(colorType)); - int index = 0; - if ((colorType & 2) != 0) { - child.setAttribute("red", String.valueOf(sbit[index++])); - child.setAttribute("green", String.valueOf(sbit[index++])); - child.setAttribute("blue", String.valueOf(sbit[index++])); - } else { - child.setAttribute("gray", String.valueOf(sbit[index++])); - } - if ((colorType & 4) != 0) - child.setAttribute("alpha", String.valueOf(sbit[index++])); - node.appendChild(child); - root.appendChild(node); - } - - private void add_sRGB(IIOMetadataNode root) - { - Integer ri = (Integer)get(PngConstants.RENDERING_INTENT); - if (ri == null) - return; - appendSimpleNode(root, "sRGB", "renderingIntent", getRenderingIntent(ri.intValue())); - } - - private static String getRenderingIntent(int ri) - { - switch (ri) { - case PngConstants.SRGB_PERCEPTUAL: - return "Perceptual"; - case PngConstants.SRGB_RELATIVE_COLORIMETRIC: - return "Relative colorimetric"; - case PngConstants.SRGB_SATURATION_PRESERVING: - return "Saturation"; - case PngConstants.SRGB_ABSOLUTE_COLORIMETRIC: - return "Absolute colorimetric"; - } - return null; - } - - private void add_iCCP(IIOMetadataNode root) - { - String name = (String)get(PngConstants.ICC_PROFILE_NAME); - if (name == null) - return; - - IIOMetadataNode node = new IIOMetadataNode("iCCP"); - node.setAttribute("profileName", name); - node.setAttribute("compressionMethod", "deflate"); - node.setUserObject(get(PngConstants.ICC_PROFILE)); - root.appendChild(node); - } - - private void add_unknown_chunks(IIOMetadataNode root) - { - if (unknownChunks.isEmpty()) - return; - - IIOMetadataNode node = new IIOMetadataNode("UnknownChunks"); - for (Iterator it = unknownChunks.keySet().iterator(); it.hasNext();) { - Integer type = (Integer)it.next(); - IIOMetadataNode child = new IIOMetadataNode("UnknownChunk"); - child.setAttribute("type", PngConstants.getChunkName(type.intValue())); - child.setUserObject(unknownChunks.get(type)); - node.appendChild(child); - } - root.appendChild(node); - } - - private void add_hIST(IIOMetadataNode root) - { - int[] hist = (int[])get(PngConstants.HISTOGRAM); - if (hist == null) - return; - - IIOMetadataNode node = new IIOMetadataNode("hIST"); - for (int i = 0; i < hist.length; i++) { - IIOMetadataNode child = new IIOMetadataNode("hISTEntry"); - child.setAttribute("index", String.valueOf(i)); - child.setAttribute("value", String.valueOf(hist[i])); - node.appendChild(child); - } - root.appendChild(node); - } - - private void add_text_chunks(IIOMetadataNode root) - { - List textChunks = (List)get(PngConstants.TEXT_CHUNKS); - if (textChunks == null) - return; - - Map nodes = new HashMap(); - nodes.put("tEXt", new IIOMetadataNode("tEXt")); - nodes.put("zTXt", new IIOMetadataNode("zTXt")); - nodes.put("iTXt", new IIOMetadataNode("iTXt")); - for (Iterator it = textChunks.iterator(); it.hasNext();) { - TextChunk chunk = (TextChunk)it.next(); - String name = PngConstants.getChunkName(chunk.getType()); - IIOMetadataNode child = new IIOMetadataNode(name + "Entry"); - child.setAttribute("keyword", chunk.getKeyword()); - switch (chunk.getType()) { - case PngConstants.zTXt: - child.setAttribute("compressionMethod", "deflate"); - child.setAttribute("text", chunk.getText()); - break; - case PngConstants.iTXt: - child.setAttribute("compressionMethod", "deflate"); - child.setAttribute("value", chunk.getText()); - child.setAttribute("languageTag", chunk.getLanguage()); - child.setAttribute("translatedKeyword", chunk.getTranslatedKeyword()); - child.setAttribute("compressionFlag", "FALSE"); // TODO - break; - case PngConstants.tEXt: - child.setAttribute("value", chunk.getText()); - } - IIOMetadataNode parent = (IIOMetadataNode)nodes.get(name); - if (parent.getLength() == 0) - root.appendChild(parent); - parent.appendChild(child); - } - } -} diff --git a/javapng2/src/iio/com/sixlegs/png/iio/PngImageMetadataFormat.java b/javapng2/src/iio/com/sixlegs/png/iio/PngImageMetadataFormat.java deleted file mode 100644 index f9868c5..0000000 --- a/javapng2/src/iio/com/sixlegs/png/iio/PngImageMetadataFormat.java +++ /dev/null @@ -1,297 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 2006 Dimitri Koussa - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.iio; - -import java.awt.*; -import javax.imageio.ImageTypeSpecifier; -import javax.imageio.metadata.IIOMetadataFormatImpl; -import java.util.*; - -public class PngImageMetadataFormat -extends IIOMetadataFormatImpl -{ - private static final String rootName = "javax_imageio_png_1.0"; - - private static final Set validNodes = Collections.unmodifiableSet(new HashSet(Arrays.asList(new String[]{ - "IHDR", "iCCP", "cHRM", "sRGB", "gAMA", "pHYS", "tIME", - "sPLT", "sPLTEntry", - "hIST", "hISTEntry", - "sBIT", "sBIT_Grayscale", "sBIT_GrayAlpha", "sBIT_RGB", "sBIT_RGBAlpha", "sBIT_Palette", - "PLTE", "PLTEEntry", - "tRNS", "tRNS_Grayscale", "tRNS_RGB", "tRNS_Palette", - "bKGD", "bKGD_Grayscale", "bKGD_Palette", "bKGD_Palette", "bKGD_RGB", - "iTXt", "iTXtEntry", "zTXt", "zTXtEntry", "tEXt", "tEXtEntry", - "UnknownChunks", "UnknownChunk", - }))); - - // singleton - private static final PngImageMetadataFormat defaultInstance = - new PngImageMetadataFormat(); - - // Make constructor private to enforce the singleton pattern - private PngImageMetadataFormat() - { - // Set the name of the root node - super(rootName, CHILD_POLICY_REPEAT); - - setup_IHDR(); - setup_PLTE(); - setup_bKGD(); - setup_cHRM(); - setup_gAMA(); - setup_hIST(); - setup_iCCP(); - setup_iTXt(); - setup_pHYS(); - setup_sBIT(); - setup_sPLT(); - setup_sRGB(); - setup_tEXt(); - setup_tIME(); - setup_tRNS(); - setup_zTXt(); - setup_unknownChunks(); - } - - private void setup_IHDR() - { - addElement("IHDR", rootName, CHILD_POLICY_EMPTY); - - addAttribute("IHDR", "width", DATATYPE_INTEGER, true, null); - addAttribute("IHDR", "height", DATATYPE_INTEGER, true, null); - addAttribute("IHDR", "bitDepth", DATATYPE_INTEGER, true, null); - addAttribute("IHDR", "colorType", DATATYPE_STRING, true, null); - addAttribute("IHDR", "compressionMethod", DATATYPE_STRING, true, null); - addAttribute("IHDR", "filterMethod", DATATYPE_STRING, true, null); - addAttribute("IHDR", "interlaceMethod", DATATYPE_STRING, true, null); - } - - private void setup_sPLT() - { - addElement("sPLT", rootName, CHILD_POLICY_REPEAT); - - addElement("sPLTEntry", "sPLT", CHILD_POLICY_EMPTY); - addAttribute("sPLTEntry", "index", DATATYPE_INTEGER, true, null); - addAttribute("sPLTEntry", "red", DATATYPE_INTEGER, true, null); - addAttribute("sPLTEntry", "green", DATATYPE_INTEGER, true, null); - addAttribute("sPLTEntry", "blue", DATATYPE_INTEGER, true, null); - addAttribute("sPLTEntry", "alpha", DATATYPE_INTEGER, true, null); - } - - private void setup_hIST() - { - addElement("hIST", rootName, CHILD_POLICY_REPEAT); - - addElement("hISTEntry", "hIST", CHILD_POLICY_EMPTY); - addAttribute("hISTEntry", "index", DATATYPE_INTEGER, true, null); - addAttribute("hISTEntry", "value", DATATYPE_INTEGER, true, null); - } - - private void setup_iCCP() - { - addElement("iCCP", rootName, CHILD_POLICY_EMPTY); - addAttribute("iCCP", "profileName", DATATYPE_STRING, true, null); - addAttribute("iCCP", "compressionMethod", DATATYPE_STRING, true, null); - } - - private void setup_cHRM() - { - addElement("cHRM", rootName, CHILD_POLICY_EMPTY); - - addAttribute("cHRM", "whitePointX", DATATYPE_INTEGER, true, null); - addAttribute("cHRM", "whitePointY", DATATYPE_INTEGER, true, null); - addAttribute("cHRM", "redX", DATATYPE_INTEGER, true, null); - addAttribute("cHRM", "redY", DATATYPE_INTEGER, true, null); - addAttribute("cHRM", "greenX", DATATYPE_INTEGER, true, null); - addAttribute("cHRM", "greenY", DATATYPE_INTEGER, true, null); - addAttribute("cHRM", "blueX", DATATYPE_INTEGER, true, null); - addAttribute("cHRM", "blueY", DATATYPE_INTEGER, true, null); - } - - private void setup_sBIT() - { - addElement("sBIT", rootName, CHILD_POLICY_CHOICE); - - addElement("sBIT_Grayscale", "sBIT", CHILD_POLICY_EMPTY); - addAttribute("sBIT_Grayscale", "gray", DATATYPE_INTEGER, true, null); - - addElement("sBIT_GrayAlpha", "sBIT", CHILD_POLICY_EMPTY); - addAttribute("sBIT_GrayAlpha", "gray", DATATYPE_INTEGER, true, null); - addAttribute("sBIT_GrayAlpha", "alpha", DATATYPE_INTEGER, true, null); - - addElement("sBIT_RGB", "sBIT", CHILD_POLICY_EMPTY); - addAttribute("sBIT_RGB", "red", DATATYPE_INTEGER, true, null); - addAttribute("sBIT_RGB", "green", DATATYPE_INTEGER, true, null); - addAttribute("sBIT_RGB", "blue", DATATYPE_INTEGER, true, null); - - addElement("sBIT_RGBAlpha", "sBIT", CHILD_POLICY_EMPTY); - addAttribute("sBIT_RGBAlpha", "red", DATATYPE_INTEGER, true, null); - addAttribute("sBIT_RGBAlpha", "green", DATATYPE_INTEGER, true, null); - addAttribute("sBIT_RGBAlpha", "blue", DATATYPE_INTEGER, true, null); - addAttribute("sBIT_RGBAlpha", "alpha", DATATYPE_INTEGER, true, null); - - addElement("sBIT_Palette", "sBIT", CHILD_POLICY_EMPTY); - addAttribute("sBIT_Palette", "red", DATATYPE_INTEGER, true, null); - addAttribute("sBIT_Palette", "green", DATATYPE_INTEGER, true, null); - addAttribute("sBIT_Palette", "blue", DATATYPE_INTEGER, true, null); - } - - private void setup_PLTE() - { - addElement("PLTE", rootName, CHILD_POLICY_REPEAT); - addElement("PLTEEntry", "PLTE", CHILD_POLICY_EMPTY); - - addAttribute("PLTEEntry", "index", DATATYPE_INTEGER, true, null); - addAttribute("PLTEEntry", "red", DATATYPE_INTEGER, true, null); - addAttribute("PLTEEntry", "green", DATATYPE_INTEGER, true, null); - addAttribute("PLTEEntry", "blue", DATATYPE_INTEGER, true, null); - } - - private void setup_tRNS() - { - addElement("tRNS", rootName, CHILD_POLICY_CHOICE); - - addElement("tRNS_Grayscale", rootName, CHILD_POLICY_CHOICE); - addAttribute("tRNS_Grayscale", "gray", DATATYPE_INTEGER, true, null); - - addElement("tRNS_RGB", rootName, CHILD_POLICY_CHOICE); - addAttribute("tRNS_RGB", "red", DATATYPE_INTEGER, true, null); - addAttribute("tRNS_RGB", "green", DATATYPE_INTEGER, true, null); - addAttribute("tRNS_RGB", "blue", DATATYPE_INTEGER, true, null); - - addElement("tRNS_Palette", rootName, CHILD_POLICY_CHOICE); - addAttribute("tRNS_Palette", "index", DATATYPE_INTEGER, true, null); - addAttribute("tRNS_Palette", "alpha", DATATYPE_INTEGER, true, null); - } - - private void setup_bKGD() - { - addElement("bKGD", rootName, CHILD_POLICY_CHOICE); - - addElement("bKGD_Grayscale", rootName, CHILD_POLICY_EMPTY); - addAttribute("bKGD_Grayscale", "gray", DATATYPE_INTEGER, true, null); - - addElement("bKGD_Palette", rootName, CHILD_POLICY_EMPTY); - addAttribute("bKGD_Palette", "index", DATATYPE_INTEGER, true, null); - - addElement("bKGD_RGB", rootName, CHILD_POLICY_EMPTY); - addAttribute("bKGD_RGB", "red", DATATYPE_INTEGER, true, null); - addAttribute("bKGD_RGB", "green", DATATYPE_INTEGER, true, null); - addAttribute("bKGD_RGB", "blue", DATATYPE_INTEGER, true, null); - } - - private void setup_sRGB() - { - addElement("sRGB", rootName, CHILD_POLICY_EMPTY); - addAttribute("sRGB", "renderingIntent", DATATYPE_STRING, true, null); - } - - private void setup_gAMA() - { - addElement("gAMA", rootName, CHILD_POLICY_EMPTY); - addAttribute("gAMA", "value", DATATYPE_INTEGER, true, null); - } - - private void setup_iTXt() - { - addElement("iTXt", rootName, CHILD_POLICY_REPEAT); - - addElement("iTXtEntry", rootName, CHILD_POLICY_EMPTY); - addAttribute("iTXtEntry", "keyword", DATATYPE_STRING, true, null); - addAttribute("iTXtEntry", "compressionFlag", DATATYPE_STRING, true, null); - addAttribute("iTXtEntry", "compressionMethod", DATATYPE_STRING, true, null); - addAttribute("iTXtEntry", "languageTag", DATATYPE_STRING, true, null); - addAttribute("iTXtEntry", "translatedKeyword", DATATYPE_STRING, true, null); - addAttribute("iTXtEntry", "text", DATATYPE_STRING, true, null); - } - - private void setup_zTXt() - { - addElement("zTXt", rootName, CHILD_POLICY_REPEAT); - - addElement("zTXtEntry", "zTXt", CHILD_POLICY_EMPTY); - addAttribute("zTXtEntry", "keyword", DATATYPE_STRING, true, null); - addAttribute("zTXtEntry", "compressionMethod", DATATYPE_STRING, true, null); - } - - private void setup_tEXt() - { - addElement("tEXt", rootName, CHILD_POLICY_REPEAT); - addElement("tEXtEntry", rootName, CHILD_POLICY_EMPTY); - addAttribute("tEXtEntry", "keyword", DATATYPE_STRING, true, null); - addAttribute("tEXtEntry", "value", DATATYPE_STRING, true, null); - } - - private void setup_pHYS() - { - addElement("pHYS", rootName, CHILD_POLICY_EMPTY); - addAttribute("pHYS", "pixelsPerUnitXAxis", DATATYPE_INTEGER, true, null); - addAttribute("pHYS", "pixelsPerUnitYAxis", DATATYPE_INTEGER, true, null); - addAttribute("pHYS", "unitSpecifier", DATATYPE_STRING, true, null); - } - - private void setup_tIME() - { - addElement("tIME", rootName, CHILD_POLICY_EMPTY); - addAttribute("tIME", "year", DATATYPE_INTEGER, true, null); - addAttribute("tIME", "month", DATATYPE_INTEGER, true, null); - addAttribute("tIME", "day", DATATYPE_INTEGER, true, null); - addAttribute("tIME", "hour", DATATYPE_INTEGER, true, null); - addAttribute("tIME", "minute", DATATYPE_INTEGER, true, null); - addAttribute("tIME", "second", DATATYPE_INTEGER, true, null); - } - - private void setup_unknownChunks() - { - addElement("UnknownChunks", rootName, CHILD_POLICY_REPEAT); - addElement("UnknownChunk", "UnknownChunks", CHILD_POLICY_EMPTY); - addAttribute("UnknownChunk", "type", DATATYPE_STRING, true, null); - } - - public boolean canNodeAppear(String e, ImageTypeSpecifier imageType) - { - // TODO: A PLTE chunk may not appear in a Gray or GrayAlpha image - // TODO: A tRNS chunk may not appear in GrayAlpha and RGBA images - return validNodes.contains(e); - } - - // Return the singleton instance - public static PngImageMetadataFormat getDefaultInstance() - { - return defaultInstance; - } -} diff --git a/javapng2/src/iio/com/sixlegs/png/iio/PngImageReader.java b/javapng2/src/iio/com/sixlegs/png/iio/PngImageReader.java deleted file mode 100644 index f720456..0000000 --- a/javapng2/src/iio/com/sixlegs/png/iio/PngImageReader.java +++ /dev/null @@ -1,366 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.iio; - -import com.sixlegs.png.*; -import java.awt.image.BufferedImage; -import java.awt.color.ColorSpace; -import javax.imageio.ImageReader; -import javax.imageio.ImageReadParam; -import javax.imageio.ImageTypeSpecifier; -import javax.imageio.metadata.IIOMetadata; -import javax.imageio.stream.ImageInputStream; -import java.io.DataInput; -import java.io.IOException; -import java.util.*; - -public class PngImageReader -extends ImageReader -{ - private PngImage png = new IIOPngImage(new PngConfig.Builder().build()); - private PngHeader pngHeader; - private PngImageMetadata pngMetadata; - private BufferedImage pngImage; - private Map unknownChunks = new HashMap(); - - public PngImageReader(PngImageReaderSpi provider) - { - super(provider); - } - - public void dispose() - { - png = null; - pngHeader = null; - pngMetadata = null; - pngImage = null; - unknownChunks = null; - } - - public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) - { - if (!(input instanceof ImageInputStream)) - throw new IllegalArgumentException("Expected ImageInputStream, got " + input); - super.setInput(input, seekForwardOnly, ignoreMetadata); - pngHeader = null; - pngMetadata = null; - pngImage = null; - unknownChunks.clear(); - } - - public int getNumImages(boolean allowSearch) - { - return 1; - } - - private void checkIndex(int imageIndex) - { - if (imageIndex != 0) - throw new IndexOutOfBoundsException("Requested image " + imageIndex); - } - - private void readHeader() - throws IOException - { - if (pngHeader == null) - pngHeader = new PngHeader((ImageInputStream)input); - } - - public int getWidth(int imageIndex) - throws IOException - { - checkIndex(imageIndex); - readHeader(); - return pngHeader.width; - } - - public int getHeight(int imageIndex) - throws IOException - { - checkIndex(imageIndex); - readHeader(); - return pngHeader.height; - } - - public Iterator getImageTypes(int imageIndex) - throws IOException - { - checkIndex(imageIndex); - readHeader(); - - int datatype = java.awt.image.DataBuffer.TYPE_BYTE; - int[] bandOffsets = null; - ImageTypeSpecifier imageType = null; - ColorSpace rgb = null; - - // FIXME: These need to be checked - switch (pngHeader.colorType) { - case PngConstants.COLOR_TYPE_GRAY: - imageType = ImageTypeSpecifier.createGrayscale( - pngHeader.bitDepth, - datatype, - false); - break; - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - imageType = ImageTypeSpecifier.createGrayscale( - pngHeader.bitDepth, - datatype, - false, - true); - break; - //FIXME Are the palette entries needed if PngImage deals with them? - case PngConstants.COLOR_TYPE_PALETTE: - imageType = ImageTypeSpecifier.createIndexed( - null,//redLUT, - null,//greenLUT, - null,//blueLUT, - null,//alphaLUT, - pngHeader.bitDepth, - datatype); - break; - case PngConstants.COLOR_TYPE_RGB: - rgb = ColorSpace.getInstance(ColorSpace.CS_sRGB); - bandOffsets = new int[3]; - bandOffsets[0] = 0; - bandOffsets[1] = 1; - bandOffsets[2] = 2; - imageType = ImageTypeSpecifier.createInterleaved(rgb, - bandOffsets, - datatype, - false, - false); - break; - case PngConstants.COLOR_TYPE_RGB_ALPHA: - rgb = ColorSpace.getInstance(ColorSpace.CS_sRGB); - bandOffsets = new int[3]; - bandOffsets[0] = 0; - bandOffsets[1] = 1; - bandOffsets[2] = 2; - imageType = ImageTypeSpecifier.createInterleaved(rgb, - bandOffsets, - datatype, - true, - false); - break; - } - - return Arrays.asList(new ImageTypeSpecifier[]{ - imageType - }).iterator(); - } - - public IIOMetadata getImageMetadata(int imageIndex) - throws IOException - { - checkIndex(imageIndex); - readMetadata(); - return pngMetadata; - } - - public IIOMetadata getStreamMetadata() - { - return null; - } - - public void readMetadata() - throws IOException - { - if (pngMetadata == null && !ignoreMetadata) { - readHeader(); - readImage(); - pngMetadata = new PngImageMetadata(new HashMap(png.getProperties()), - new HashMap(unknownChunks)); - } - } - - private void readImage() - throws IOException - { - if (pngImage == null) { - clearAbortRequest(); - processImageStarted(0); - pngImage = png.read(new StreamWrapper((ImageInputStream)input), false); - processImageComplete(); - } - } - - public BufferedImage read(int imageIndex, ImageReadParam param) - throws IOException - { - checkIndex(imageIndex); - readMetadata(); - readImage(); - - /* - PngConfig config = new PngConfig.Builder().build(); - if (param != null) { - config.setSourceSubsampling(param.getSourceXSubsampling(), - param.getSourceYSubsampling(), - param.getSubsamplingXOffset(), - param.getSubsamplingYOffset()); - } - */ - - //FIXME use param to get a destination image. Not exactly sure how to - //go about this. - // - //BufferedImage dst = getDestination(param, getImageTypes(0), - // pngHeader.width, pngHeader.height); - // - //Copy pixels from pngImage to dst??? - - return pngImage; - } - - private class IIOPngImage - extends PngImage - { - public IIOPngImage(PngConfig cfg) - { - super(cfg); - } - - protected void handleWarning(PngException e) - throws PngException - { - processWarningOccurred(e.getMessage()); - } - - protected boolean handlePass(BufferedImage image, int pass) - { - // TODO: processPassXXX - if (pass == 6 || !isInterlaced()) { - processImageComplete(); - } else if (abortRequested()) { - processReadAborted(); - return false; - } - return true; - } - - protected boolean handleProgress(BufferedImage image, float pct) - { - processImageProgress(pct); - if (abortRequested()) { - processReadAborted(); - return false; - } - return true; - } - - protected void readChunk(int type, DataInput in, long offset, int length) - throws IOException - { - if (ignoreMetadata) { - switch (type) { - case PngConstants.IHDR: - case PngConstants.PLTE: - case PngConstants.tRNS: - case PngConstants.IEND: - case PngConstants.gAMA: - break; - default: - return; - } - } - if (isKnownChunkType(type)) { - super.readChunk(type, in, offset, length); - } else { - byte[] bytes = new byte[length]; - in.readFully(bytes); - unknownChunks.put(new Integer(type), bytes); - } - } - } - - private static boolean isKnownChunkType(int type) - { - switch (type) { - case PngConstants.IHDR: - case PngConstants.IEND: - case PngConstants.IDAT: - case PngConstants.PLTE: - case PngConstants.bKGD: - case PngConstants.tRNS: - case PngConstants.sBIT: - case PngConstants.cHRM: - case PngConstants.gAMA: - case PngConstants.hIST: - case PngConstants.iCCP: - case PngConstants.pHYs: - case PngConstants.sRGB: - case PngConstants.tIME: - case PngConstants.sPLT: - case PngConstants.gIFg: - case PngConstants.oFFs: - case PngConstants.sCAL: - case PngConstants.sTER: - case PngConstants.iTXt: - case PngConstants.tEXt: - case PngConstants.zTXt: - return true; - } - return false; - } - - /* Reads a PNG header */ - private static class PngHeader - { - public final int width; - public final int height; - public final int colorType; - public final int bitDepth; - public final int interlaceType; - - public PngHeader(ImageInputStream in) - throws IOException - { - in.mark(); - - in.seek(16); - width = in.readInt(); - height = in.readInt(); - colorType = in.read(); - - in.skipBytes(2); - bitDepth = in.read(); - interlaceType = in.read(); - - in.reset(); - } - } -} diff --git a/javapng2/src/iio/com/sixlegs/png/iio/PngImageReaderSpi.java b/javapng2/src/iio/com/sixlegs/png/iio/PngImageReaderSpi.java deleted file mode 100644 index 733506f..0000000 --- a/javapng2/src/iio/com/sixlegs/png/iio/PngImageReaderSpi.java +++ /dev/null @@ -1,86 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.iio; - -import java.io.IOException; -import java.util.Locale; -import javax.imageio.ImageReader; -import javax.imageio.spi.ImageReaderSpi; -import javax.imageio.stream.ImageInputStream; - -public class PngImageReaderSpi -extends ImageReaderSpi -{ - private static final long SIGNATURE = 0x89504E470D0A1A0AL; - - public PngImageReaderSpi() - { - super("Chris Nokleberg", - "2.0", - new String[]{ "png", "PNG" }, - new String[]{ "png", "PNG" }, - new String[]{ "image/png", "image/x-png"}, - "com.sixlegs.png.iio.PngImageReader", - new Class[]{ ImageInputStream.class, }, - null, // writer - false, null, null, null, null, - false, null, null, null, null); - } - - public String getDescription(Locale locale) - { - return "com.sixlegs.png ImageIO plugin"; - } - - public boolean canDecodeInput(Object source) - throws IOException - { - if (source instanceof ImageInputStream) { - ImageInputStream in = (ImageInputStream)source; - in.mark(); - long sig = in.readLong(); - in.reset(); - return sig == SIGNATURE; - } - return false; - } - - public ImageReader createReaderInstance(Object extension) - { - return new PngImageReader(this); - } -} diff --git a/javapng2/src/iio/com/sixlegs/png/iio/StreamWrapper.java b/javapng2/src/iio/com/sixlegs/png/iio/StreamWrapper.java deleted file mode 100644 index 8683845..0000000 --- a/javapng2/src/iio/com/sixlegs/png/iio/StreamWrapper.java +++ /dev/null @@ -1,105 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png.iio; - -import java.io.InputStream; -import java.io.IOException; -import javax.imageio.stream.ImageInputStream; - -// TODO: add flushing for performance? -class StreamWrapper -extends InputStream -{ - private ImageInputStream in; - - public StreamWrapper(ImageInputStream in) - { - this.in = in; - } - - public int available() - throws IOException - { - return (int)(in.length() - in.getStreamPosition()); - } - - public void close() - throws IOException - { - in.close(); - } - - public void mark(int readlimit) - { - in.mark(); - } - - public boolean markSupported() - { - return true; - } - - public int read() - throws IOException - { - return in.read(); - } - - public int read(byte[] b) - throws IOException - { - return in.read(b); - } - - public int read(byte[] b, int off, int len) - throws IOException - { - return in.read(b, off, len); - } - - public void reset() - throws IOException - { - in.reset(); - } - - public long skip(long n) - throws IOException - { - return in.skipBytes(n); - } -} diff --git a/javapng2/src/main/com/sixlegs/png/BasicPixelProcessor.java b/javapng2/src/main/com/sixlegs/png/BasicPixelProcessor.java deleted file mode 100644 index ba018a1..0000000 --- a/javapng2/src/main/com/sixlegs/png/BasicPixelProcessor.java +++ /dev/null @@ -1,66 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -class BasicPixelProcessor -extends PixelProcessor -{ - protected final Destination dst; - protected final int samples; - - public BasicPixelProcessor(Destination dst, int samples) - { - this.dst = dst; - this.samples = samples; - } - - public boolean process(int[] row, int xOffset, int xStep, int yStep, int y, int width) - { - if (xStep == 1) { - dst.setPixels(xOffset, y, width, row); - } else { - int dstX = xOffset; - for (int index = 0, total = samples * width; index < total; index += samples) { - for (int i = 0; i < samples; i++) - row[i] = row[index + i]; - dst.setPixel(dstX, y, row); - dstX += xStep; - } - } - return true; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/ConvertIndexedDestination.java b/javapng2/src/main/com/sixlegs/png/ConvertIndexedDestination.java deleted file mode 100644 index 904ccc7..0000000 --- a/javapng2/src/main/com/sixlegs/png/ConvertIndexedDestination.java +++ /dev/null @@ -1,95 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.image.*; - -class ConvertIndexedDestination -extends Destination -{ - private final Destination dst; - private final IndexColorModel srcColorModel; - private final int srcSamples; - private final int dstSamples; - private final int sampleDiff; - private final int[] row; - - public ConvertIndexedDestination(Destination dst, int width, IndexColorModel srcColorModel, ComponentColorModel dstColorModel) - { - this.dst = dst; - this.srcColorModel = srcColorModel; - srcSamples = srcColorModel.getNumComponents(); - dstSamples = dstColorModel.getNumComponents(); - sampleDiff = srcSamples - dstSamples; - row = new int[width * dstSamples + sampleDiff]; - } - - public void setPixels(int x, int y, int w, int[] pixels) - { - for (int i = w - 1, off = dstSamples * i; i >= 0; i--, off -= dstSamples) - srcColorModel.getComponents(pixels[i], row, off); - if (sampleDiff != 0) - System.arraycopy(row, sampleDiff, row, 0, dstSamples * w); - dst.setPixels(x, y, w, row); - } - - public void setPixel(int x, int y, int[] pixel) - { - setPixels(x, y, 1, pixel); - } - - public void getPixel(int x, int y, int[] pixel) - { - // TODO: convert backwards (requires looking up palette index) - throw new UnsupportedOperationException("implement me"); - } - - public WritableRaster getRaster() - { - return dst.getRaster(); - } - - public int getSourceWidth() - { - return dst.getSourceWidth(); - } - - public void done() - { - dst.done(); - } -} diff --git a/javapng2/src/main/com/sixlegs/png/Defilterer.java b/javapng2/src/main/com/sixlegs/png/Defilterer.java deleted file mode 100644 index 1554068..0000000 --- a/javapng2/src/main/com/sixlegs/png/Defilterer.java +++ /dev/null @@ -1,190 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.Point; -import java.awt.image.*; -import java.io.*; - -class Defilterer -{ - private final InputStream in; - private final int width; - private final int bitDepth; - private final int samples; - private final PixelProcessor pp; - private final int bpp; - private final int[] row; - - public Defilterer(InputStream in, int bitDepth, int samples, int width, PixelProcessor pp) - { - this.in = in; - this.bitDepth = bitDepth; - this.samples = samples; - this.width = width; - this.pp = pp; - bpp = Math.max(1, (bitDepth * samples) >> 3); - row = new int[samples * width]; - } - - public boolean defilter(int xOffset, int yOffset, - int xStep, int yStep, - int passWidth, int passHeight) - throws IOException - { - if (passWidth == 0 || passHeight == 0) - return true; - - int bytesPerRow = (bitDepth * samples * passWidth + 7) / 8; - boolean isShort = bitDepth == 16; - WritableRaster passRow = createInputRaster(bitDepth, samples, width); - DataBuffer dbuf = passRow.getDataBuffer(); - byte[] byteData = isShort ? null : ((DataBufferByte)dbuf).getData(); - short[] shortData = isShort ? ((DataBufferUShort)dbuf).getData() : null; - - int rowSize = bytesPerRow + bpp; - byte[] prev = new byte[rowSize]; - byte[] cur = new byte[rowSize]; - - for (int srcY = 0, dstY = yOffset; srcY < passHeight; srcY++, dstY += yStep) { - int filterType = in.read(); - if (filterType == -1) - throw new EOFException("Unexpected end of image data"); - readFully(in, cur, bpp, bytesPerRow); - defilter(cur, prev, bpp, filterType); - if (isShort) { - for (int c = 0, i = bpp; i < rowSize; c++, i += 2) - shortData[c] = (short)((cur[i] << 8) | (0xFF & cur[i + 1])); - } else { - System.arraycopy(cur, bpp, byteData, 0, bytesPerRow); - } - passRow.getPixels(0, 0, passWidth, 1, row); - if (!pp.process(row, xOffset, xStep, yStep, dstY, passWidth)) - return false; - byte[] tmp = cur; - cur = prev; - prev = tmp; - } - return true; - } - - private static void defilter(byte[] cur, byte[] prev, int bpp, int filterType) - throws PngException - { - int rowSize = cur.length; - int xc, xp; - switch (filterType) { - case 0: // None - break; - case 1: // Sub - for (xc = bpp, xp = 0; xc < rowSize; xc++, xp++) - cur[xc] = (byte)(cur[xc] + cur[xp]); - break; - case 2: // Up - for (xc = bpp; xc < rowSize; xc++) - cur[xc] = (byte)(cur[xc] + prev[xc]); - break; - case 3: // Average - for (xc = bpp, xp = 0; xc < rowSize; xc++, xp++) - cur[xc] = (byte)(cur[xc] + ((0xFF & cur[xp]) + (0xFF & prev[xc])) / 2); - break; - case 4: // Paeth - for (xc = bpp, xp = 0; xc < rowSize; xc++, xp++) { - byte L = cur[xp]; - byte u = prev[xc]; - byte nw = prev[xp]; - int a = 0xFF & L; // inline byte->int - int b = 0xFF & u; - int c = 0xFF & nw; - int p = a + b - c; - int pa = p - a; if (pa < 0) pa = -pa; // inline Math.abs - int pb = p - b; if (pb < 0) pb = -pb; - int pc = p - c; if (pc < 0) pc = -pc; - int result; - if (pa <= pb && pa <= pc) { - result = a; - } else if (pb <= pc) { - result = b; - } else { - result = c; - } - cur[xc] = (byte)(cur[xc] + result); - } - break; - default: - throw new PngException("Unrecognized filter type " + filterType, true); - } - } - - private static int[][] bandOffsets = { - null, - { 0 }, - { 0, 1 }, - { 0, 1, 2 }, - { 0, 1, 2, 3 }, - }; - - private static WritableRaster createInputRaster(int bitDepth, int samples, int width) - { - int rowSize = (bitDepth * samples * width + 7) / 8; - Point origin = new Point(0, 0); - if ((bitDepth < 8) && (samples == 1)) { - DataBuffer dbuf = new DataBufferByte(rowSize); - return Raster.createPackedRaster(dbuf, width, 1, bitDepth, origin); - } else if (bitDepth <= 8) { - DataBuffer dbuf = new DataBufferByte(rowSize); - return Raster.createInterleavedRaster(dbuf, width, 1, rowSize, samples, - bandOffsets[samples], origin); - } else { - DataBuffer dbuf = new DataBufferUShort(rowSize / 2); - return Raster.createInterleavedRaster(dbuf, width, 1, rowSize / 2, samples, - bandOffsets[samples], origin); - } - } - - private static void readFully(InputStream in, byte[] b, int off, int len) - throws IOException - { - int total = 0; - while (total < len) { - int result = in.read(b, off + total, len - total); - if (result == -1) - throw new EOFException("Unexpected end of image data"); - total += result; - } - } -} diff --git a/javapng2/src/main/com/sixlegs/png/Destination.java b/javapng2/src/main/com/sixlegs/png/Destination.java deleted file mode 100644 index ff928be..0000000 --- a/javapng2/src/main/com/sixlegs/png/Destination.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.image.WritableRaster; - -// not an interface for performance -abstract class Destination -{ - abstract public void setPixels(int x, int y, int w, int[] pixels); // TODO: change to setRow(int y, int w, int[] pixels) - abstract public void setPixel(int x, int y, int[] pixel); - abstract public void getPixel(int x, int y, int[] pixel); // used only by ProgressivePixelProcessor - abstract public WritableRaster getRaster(); - abstract public int getSourceWidth(); - abstract public void done(); -} diff --git a/javapng2/src/main/com/sixlegs/png/GammaPixelProcessor.java b/javapng2/src/main/com/sixlegs/png/GammaPixelProcessor.java deleted file mode 100644 index 85d7bec..0000000 --- a/javapng2/src/main/com/sixlegs/png/GammaPixelProcessor.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -final class GammaPixelProcessor -extends BasicPixelProcessor -{ - final private short[] gammaTable; - final private int shift; - final private int samplesNoAlpha; - final private boolean hasAlpha; - final private boolean shiftAlpha; - - public GammaPixelProcessor(Destination dst, short[] gammaTable, int shift) - { - super(dst, dst.getRaster().getNumBands()); - this.gammaTable = gammaTable; - this.shift = shift; - hasAlpha = samples % 2 == 0; - samplesNoAlpha = hasAlpha ? samples - 1 : samples; // don't change alpha channel - shiftAlpha = hasAlpha && shift > 0; - } - - public boolean process(int[] row, int xOffset, int xStep, int yStep, int y, int width) - { - int total = samples * width; - for (int i = 0; i < samplesNoAlpha; i++) - for (int index = i; index < total; index += samples) - row[index] = 0xFFFF & gammaTable[row[index] >> shift]; - if (shiftAlpha) - for (int index = samplesNoAlpha; index < total; index += samples) - row[index] >>= shift; - return super.process(row, xOffset, xStep, yStep, y, width); - } -} diff --git a/javapng2/src/main/com/sixlegs/png/ImageDataInputStream.java b/javapng2/src/main/com/sixlegs/png/ImageDataInputStream.java deleted file mode 100644 index 8d682ef..0000000 --- a/javapng2/src/main/com/sixlegs/png/ImageDataInputStream.java +++ /dev/null @@ -1,86 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.io.*; - -class ImageDataInputStream -extends InputStream -{ - private final PngInputStream in; - private final StateMachine machine; - private final byte[] onebyte = new byte[1]; - private boolean done; - - public ImageDataInputStream(PngInputStream in, StateMachine machine) - { - this.in = in; - this.machine = machine; - } - - public int read() - throws IOException - { - return (read(onebyte, 0, 1) == -1) ? -1 : 0xFF & onebyte[0]; - } - - public int read(byte[] b, int off, int len) - throws IOException - { - if (done) - return -1; - try { - int total = 0; - while ((total != len) && !done) { - while ((total != len) && in.getRemaining() > 0) { - int amt = Math.min(len - total, in.getRemaining()); - in.readFully(b, off + total, amt); - total += amt; - } - if (in.getRemaining() <= 0) { - in.endChunk(machine.getType()); - machine.nextState(in.startChunk()); - done = machine.getType() != PngConstants.IDAT; - } - } - return total; - } catch (EOFException e) { - done = true; - return -1; - } - } -} diff --git a/javapng2/src/main/com/sixlegs/png/ImageFactory.java b/javapng2/src/main/com/sixlegs/png/ImageFactory.java deleted file mode 100644 index 504dbd8..0000000 --- a/javapng2/src/main/com/sixlegs/png/ImageFactory.java +++ /dev/null @@ -1,276 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.Transparency; -import java.awt.color.ColorSpace; -import java.awt.image.*; -import java.io.*; -import java.util.*; -import java.util.zip.Inflater; -import java.util.zip.InflaterInputStream; - -class ImageFactory -{ - private static short[] GAMMA_TABLE_45455 = - PngImage.createGammaTable(0.45455f, 2.2f, false); - private static short[] GAMMA_TABLE_100000 = - PngImage.createGammaTable(1f, 2.2f, false); - - public static BufferedImage createImage(PngImage png, InputStream in) - throws IOException - { - return createImage(png, in, new Dimension(png.getWidth(), png.getHeight())); - } - - // width and height are overridable for APNG - public static BufferedImage createImage(PngImage png, InputStream in, Dimension size) - throws IOException - { - PngConfig config = png.getConfig(); - - int width = size.width; - int height = size.height; - int bitDepth = png.getBitDepth(); - int samples = png.getSamples(); - boolean interlaced = png.isInterlaced(); - - boolean indexed = isIndexed(png); - boolean convertIndexed = indexed && config.getConvertIndexed(); - short[] gammaTable = config.getGammaCorrect() ? getGammaTable(png) : null; - ColorModel dstColorModel = createColorModel(png, gammaTable, convertIndexed); - - int dstWidth = width; - int dstHeight = height; - Rectangle sourceRegion = config.getSourceRegion(); - if (sourceRegion != null) { - if (!new Rectangle(dstWidth, dstHeight).contains(sourceRegion)) - throw new IllegalStateException("Source region " + sourceRegion + " falls outside of " + - width + "x" + height + " image"); - dstWidth = sourceRegion.width; - dstHeight = sourceRegion.height; - } - - Destination dst; - int xsub = config.getSourceXSubsampling(); - int ysub = config.getSourceYSubsampling(); - if (xsub != 1 || ysub != 1) { - int xoff = config.getSubsamplingXOffset(); - int yoff = config.getSubsamplingYOffset(); - int subw = calcSubsamplingSize(dstWidth, xsub, xoff, 'X'); - int subh = calcSubsamplingSize(dstHeight, ysub, yoff, 'Y'); - WritableRaster raster = dstColorModel.createCompatibleWritableRaster(subw, subh); - dst = new SubsamplingDestination(raster, width, xsub, ysub, xoff, yoff); - } else { - dst = new RasterDestination(dstColorModel.createCompatibleWritableRaster(dstWidth, dstHeight), width); - } - if (sourceRegion != null) - dst = new SourceRegionDestination(dst, sourceRegion); - - - // Destination dst = createDestination(config, dstColorModel, size, interlaced); - BufferedImage image = new BufferedImage(dstColorModel, dst.getRaster(), false, null); - - PixelProcessor pp = null; - if (!indexed) { - int[] trans = (int[])png.getProperty(PngConstants.TRANSPARENCY, int[].class, false); - int shift = (bitDepth == 16 && config.getReduce16()) ? 8 : 0; - if (shift != 0 || trans != null || gammaTable != null) { - if (gammaTable == null) - gammaTable = getIdentityTable(bitDepth - shift); - if (trans != null) { - pp = new TransGammaPixelProcessor(dst, gammaTable, trans, shift); - } else { - pp = new GammaPixelProcessor(dst, gammaTable, shift); - } - } - } - if (convertIndexed) { - IndexColorModel srcColorModel = (IndexColorModel)createColorModel(png, gammaTable, false); - dst = new ConvertIndexedDestination(dst, width, srcColorModel, (ComponentColorModel)dstColorModel); - } - - if (pp == null) - pp = new BasicPixelProcessor(dst, samples); - if (config.getProgressive() && interlaced && !convertIndexed) - pp = new ProgressivePixelProcessor(dst, pp, width, height); - pp = new ProgressUpdater(png, image, pp); - - InflaterInputStream inflate = new InflaterInputStream(in, new Inflater(), 0x1000); - Defilterer d = new Defilterer(inflate, bitDepth, samples, width, pp); - - // TODO: if not progressive, initialize to fully transparent? - boolean complete; - if (interlaced) { - complete = - d.defilter(0, 0, 8, 8, (width + 7) / 8, (height + 7) / 8) && - png.handlePass(image, 0) && - d.defilter(4, 0, 8, 8, (width + 3) / 8, (height + 7) / 8) && - png.handlePass(image, 1) && - d.defilter(0, 4, 4, 8, (width + 3) / 4, (height + 3) / 8) && - png.handlePass(image, 2) && - d.defilter(2, 0, 4, 4, (width + 1) / 4, (height + 3) / 4) && - png.handlePass(image, 3) && - d.defilter(0, 2, 2, 4, (width + 1) / 2, (height + 1) / 4) && - png.handlePass(image, 4) && - d.defilter(1, 0, 2, 2, width / 2, (height + 1) / 2) && - png.handlePass(image, 5) && - d.defilter(0, 1, 1, 2, width, height / 2) && - png.handlePass(image, 6); - } else { - complete = - d.defilter(0, 0, 1, 1, width, height) && - png.handlePass(image, 0); - } - // TODO: handle complete? - dst.done(); - return image; - } - - private static short[] getGammaTable(PngImage png) - { - PngConfig config = png.getConfig(); - if ((png.getBitDepth() != 16 || config.getReduce16()) && - config.getDisplayExponent() == 2.2f) { - float gamma = png.getGamma(); - if (gamma == 0.45455f) - return GAMMA_TABLE_45455; - if (gamma == 1f) - return GAMMA_TABLE_100000; - } - return png.getGammaTable(); - } - - private static int calcSubsamplingSize(int len, int sub, int off, char desc) - { - int size = (len - off + sub - 1) / sub; - if (size == 0) - throw new IllegalStateException("Source " + desc + " subsampling " + sub + ", offset " + off + - " is invalid for image dimension " + len); - return size; - } - - private static boolean isIndexed(PngImage png) - { - int colorType = png.getColorType(); - return colorType == PngConstants.COLOR_TYPE_PALETTE || - (colorType == PngConstants.COLOR_TYPE_GRAY && png.getBitDepth() < 16); - } - - private static ColorModel createColorModel(PngImage png, short[] gammaTable, boolean convertIndexed) - throws PngException - { - Map props = png.getProperties(); - int colorType = png.getColorType(); - int bitDepth = png.getBitDepth(); - int outputDepth = (bitDepth == 16 && png.getConfig().getReduce16()) ? 8 : bitDepth; - - if (isIndexed(png) && !convertIndexed) { - byte[] r, g, b; - if (colorType == PngConstants.COLOR_TYPE_PALETTE) { - byte[] palette = (byte[])png.getProperty(PngConstants.PALETTE, byte[].class, true); - int paletteSize = palette.length / 3; - r = new byte[paletteSize]; - g = new byte[paletteSize]; - b = new byte[paletteSize]; - for (int i = 0, p = 0; i < paletteSize; i++) { - r[i] = palette[p++]; - g[i] = palette[p++]; - b[i] = palette[p++]; - } - applyGamma(r, gammaTable); - applyGamma(g, gammaTable); - applyGamma(b, gammaTable); - } else { - int paletteSize = 1 << bitDepth; - r = g = b = new byte[paletteSize]; - for (int i = 0; i < paletteSize; i++) { - r[i] = (byte)(i * 255 / (paletteSize - 1)); - } - applyGamma(r, gammaTable); - } - if (props.containsKey(PngConstants.PALETTE_ALPHA)) { - byte[] trans = (byte[])png.getProperty(PngConstants.PALETTE_ALPHA, byte[].class, true); - byte[] a = new byte[r.length]; - Arrays.fill(a, trans.length, r.length, (byte)0xFF); - System.arraycopy(trans, 0, a, 0, trans.length); - return new IndexColorModel(outputDepth, r.length, r, g, b, a); - } else { - int trans = -1; - if (props.containsKey(PngConstants.TRANSPARENCY)) - trans = ((int[])png.getProperty(PngConstants.TRANSPARENCY, int[].class, true))[0]; - return new IndexColorModel(outputDepth, r.length, r, g, b, trans); - } - } else { - int dataType = (outputDepth == 16) ? - DataBuffer.TYPE_USHORT : DataBuffer.TYPE_BYTE; - int colorSpace = - (colorType == PngConstants.COLOR_TYPE_GRAY || - colorType == PngConstants.COLOR_TYPE_GRAY_ALPHA) ? - ColorSpace.CS_GRAY : - ColorSpace.CS_sRGB; - int transparency = png.getTransparency(); - // TODO: cache/enumerate color models? - return new ComponentColorModel(ColorSpace.getInstance(colorSpace), - null, - transparency != Transparency.OPAQUE, - false, - transparency, - dataType); - } - } - - private static void applyGamma(byte[] palette, short[] gammaTable) - { - if (gammaTable != null) { - for (int i = 0; i < palette.length; i++) - palette[i] = (byte)gammaTable[0xFF & palette[i]]; - } - } - - private static short[] getIdentityTable(int bitDepth) - { - // TODO: cache identity tables? - int size = 1 << bitDepth; - short[] table = new short[size]; - for (int i = 0; i < size; i++) - table[i] = (short)i; - return table; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/Integers.java b/javapng2/src/main/com/sixlegs/png/Integers.java deleted file mode 100644 index c81504d..0000000 --- a/javapng2/src/main/com/sixlegs/png/Integers.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -class Integers -{ - public static Integer valueOf(int i) - { - switch (i) { - case 0: return INT_0; - case 1: return INT_1; - case 2: return INT_2; - case 3: return INT_3; - case 4: return INT_4; - case 5: return INT_5; - case 6: return INT_6; - case 7: return INT_7; - case 8: return INT_8; - default: - return new Integer(i); - } - } - - private static final Integer INT_0 = new Integer(0); - private static final Integer INT_1 = new Integer(1); - private static final Integer INT_2 = new Integer(2); - private static final Integer INT_3 = new Integer(3); - private static final Integer INT_4 = new Integer(4); - private static final Integer INT_5 = new Integer(5); - private static final Integer INT_6 = new Integer(6); - private static final Integer INT_7 = new Integer(7); - private static final Integer INT_8 = new Integer(8); -} diff --git a/javapng2/src/main/com/sixlegs/png/PixelProcessor.java b/javapng2/src/main/com/sixlegs/png/PixelProcessor.java deleted file mode 100644 index c048934..0000000 --- a/javapng2/src/main/com/sixlegs/png/PixelProcessor.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -// not an interface for performance -abstract class PixelProcessor -{ - abstract public boolean process(int[] row, int xOffset, int xStep, int yStep, int y, int width); -} diff --git a/javapng2/src/main/com/sixlegs/png/PngConfig.java b/javapng2/src/main/com/sixlegs/png/PngConfig.java deleted file mode 100644 index 7f294f3..0000000 --- a/javapng2/src/main/com/sixlegs/png/PngConfig.java +++ /dev/null @@ -1,410 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.Rectangle; - -/** - * Customizable parameters used by {@link PngImage} when decoding an image. - * Instances of this class are immutable and can only be constructed - * using the {@link Builder} inner-class. - */ -final public class PngConfig -{ - /** Read the entire image */ - public static final int READ_ALL = 0; - /** Read only the header chunk */ - public static final int READ_HEADER = 1; - /** Read all the metadata up to the image data */ - public static final int READ_UNTIL_DATA = 2; - /** Read the entire image, skipping over the image data */ - public static final int READ_EXCEPT_DATA = 3; - /** Read the entire image, skipping over all non-critical chunks except tRNS and gAMA */ - public static final int READ_EXCEPT_METADATA = 4; - - final int readLimit; - final float defaultGamma; - final float displayExponent; - final boolean warningsFatal; - final boolean progressive; - final boolean reduce16; - final boolean gammaCorrect; - final Rectangle sourceRegion; - final int[] subsampling; - final boolean convertIndexed; - - PngConfig(Builder builder) - { - this.readLimit = builder.readLimit; - this.defaultGamma = builder.defaultGamma; - this.displayExponent = builder.displayExponent; - this.warningsFatal = builder.warningsFatal; - this.progressive = builder.progressive; - this.reduce16 = builder.reduce16; - this.gammaCorrect = builder.gammaCorrect; - this.sourceRegion = builder.sourceRegion; - this.subsampling = builder.subsampling; - this.convertIndexed = builder.convertIndexed; - - boolean subsampleOn = getSourceXSubsampling() != 1 || getSourceYSubsampling() != 1; - if (progressive && (subsampleOn || getSourceRegion() != null)) - throw new IllegalStateException("Progressive rendering cannot be used with source regions or subsampling"); - } - - /** - * Builder class used to construct {@link PngConfig PngConfig} instances. - * Each "setter" method returns an reference to the instance to enable - * chaining multiple calls. - * Call {@link #build} to construct a new {@code PngConfig} instance - * using the current {@code Builder} settings. Example: - *
PngConfig config = new PngConfig.Builder()
-     *        .readLimit(PngConfig.READ_EXCEPT_METADATA)
-     *        .warningsFatal(true)
-     *        .build();
- */ - final public static class Builder - { - private static final int[] DEFAULT_SUBSAMPLING = { 1, 1, 0, 0 }; - - int readLimit = READ_ALL; - float defaultGamma = 0.45455f; - float displayExponent = 2.2f; - boolean warningsFatal; - boolean progressive; - boolean reduce16 = true; - boolean gammaCorrect = true; - Rectangle sourceRegion; - int[] subsampling = DEFAULT_SUBSAMPLING; - boolean convertIndexed; - - /** - * Create a new builder using default values. - */ - public Builder() - { - } - - /** - * Create a builder using values from the given configuration. - * @param cfg the configuration to copy - */ - public Builder(PngConfig cfg) - { - this.readLimit = cfg.readLimit; - this.defaultGamma = cfg.defaultGamma; - this.displayExponent = cfg.displayExponent; - this.warningsFatal = cfg.warningsFatal; - this.progressive = cfg.progressive; - this.reduce16 = cfg.reduce16; - this.gammaCorrect = cfg.gammaCorrect; - this.subsampling = cfg.subsampling; - } - - /** - * Create a configuration using the current values of this builder. - */ - public PngConfig build() - { - return new PngConfig(this); - } - - /** - * Enables or disables 16-bit reduction. If enabled, 16-bit samples are reduced to 8-bit samples by - * shifting to the right by 8 bits. Default is true. - * @param reduce16 enable 16-bit reduction - */ - public Builder reduce16(boolean reduce16) - { - this.reduce16 = reduce16; - return this; - } - - /** - * Sets the default gamma value. This value is used unless the image - * contains an explicit gamma value. Initial value is 1/45455. - * @param defaultGamma the default gamma value - */ - public Builder defaultGamma(float defaultGamma) - { - this.defaultGamma = defaultGamma; - return this; - } - - /** - * Sets the default display exponent. The proper setting depends on monitor and OS gamma lookup - * table settings, if any. The default value of 2.2 should - * work well with most PC displays. If the operating system has - * a gamma lookup table (e.g. Macintosh) the display exponent should be lower. - * @param displayExponent the display exponent - */ - public Builder displayExponent(float displayExponent) - { - this.displayExponent = displayExponent; - return this; - } - - /** - * Enables or disables gamma correction. If enabled, decoded images will be gamma corrected. - * Sets to false if your application will perform gamma correctly manually. - * Default is true. - * @param gammaCorrect use gamma correction - * @see PngImage#getGamma - * @see PngImage#getGammaTable - */ - public Builder gammaCorrect(boolean gammaCorrect) - { - this.gammaCorrect = gammaCorrect; - return this; - } - - /** - * Enables or disables progressive display for interlaced images. - * If enabled, each received pixel is expanded (replicated) to fill a rectangle - * covering the yet-to-be-transmitted pixel positions below and to the right - * of the received pixel. This produces a "fade-in" effect as the new image - * gradually replaces the old, at the cost of some additional processing time. - * Default is false. - * @param progressive use progressive display - * @see PngImage#handlePass - */ - public Builder progressive(boolean progressive) - { - this.progressive = progressive; - return this; - } - - /** - * Configures how much of the image to read. Useful when one is interested - * in only a portion of the image metadata, and would like to avoid - * reading and/or decoding the actual image data. - * @param readLimit - * {@link #READ_ALL READ_ALL},
- * {@link #READ_HEADER READ_HEADER},
- * {@link #READ_UNTIL_DATA READ_UNTIL_DATA},
- * {@link #READ_EXCEPT_DATA READ_EXCEPT_DATA},
- * or {@link #READ_EXCEPT_METADATA READ_EXCEPT_METADATA} - */ - public Builder readLimit(int readLimit) - { - this.readLimit = readLimit; - return this; - } - - /** - * Configures whether warnings should be treated as fatal errors. - * All non-fatal {@link PngException} exceptions are caught and passed to the {@link PngImage#handleWarning} - * method. If warnings are configured as fatal, that method will re-throw the - * exception, which will abort image processing. Default is false. - * @param warningsFatal true if warnings should be treated as fatal errors - * @see PngImage#handleWarning - */ - public Builder warningsFatal(boolean warningsFatal) - { - this.warningsFatal = warningsFatal; - return this; - } - - /** - * Decode only a particular region of the source image. See the equivalent - * {@linkplain javax.imageio.IIOParam#setSourceRegion ImageIO method} - * for full documentation. - */ - public Builder sourceRegion(Rectangle sourceRegion) - { - if (sourceRegion != null) { - if (sourceRegion.x < 0 || - sourceRegion.y < 0 || - sourceRegion.width <= 0 || - sourceRegion.height <= 0) - throw new IllegalArgumentException("invalid source region: " + sourceRegion); - this.sourceRegion = new Rectangle(sourceRegion); - } else { - this.sourceRegion = null; - } - return this; - } - - /** - * Reduce the size of the decoded image (or source region) by only using - * periodic rows and/or columns of the image. See the equivalent - * {@linkplain javax.imageio.IIOParam#setSourceSubsampling ImageIO method} - * for full documentation. - */ - public Builder sourceSubsampling(int xsub, int ysub, int xoff, int yoff) - { - if (xsub <= 0 || ysub <= 0 || - xoff < 0 || xoff >= xsub || - yoff < 0 || yoff >= ysub) - throw new IllegalArgumentException("invalid subsampling values"); - subsampling = new int[]{ xsub, ysub, xoff, yoff }; - return this; - } - - /** - * Whether to convert images with an indexed color model - * (paletted and 1/2/4/8-bit grayscale) to use a component color model. - */ - public Builder convertIndexed(boolean convertIndexed) - { - this.convertIndexed = convertIndexed; - return this; - } - } - - /** - * Return sthe current indexed image conversion setting. - * @see Builder#convertIndexed - */ - public boolean getConvertIndexed() - { - return convertIndexed; - } - - /** - * Returns the current 16-bit reduction setting. - * @see Builder#reduce16 - */ - public boolean getReduce16() - { - return reduce16; - } - - /** - * Returns the current default gamma value. - * @see Builder#defaultGamma - */ - public float getDefaultGamma() - { - return defaultGamma; - } - - /** - * Returns the current gamma correction setting. - * @see Builder#gammaCorrect - */ - public boolean getGammaCorrect() - { - return gammaCorrect; - } - - /** - * Returns the current progressive display setting. - * @see Builder#progressive - */ - public boolean getProgressive() - { - return progressive; - } - - /** - * Returns the current display exponent. - * @see Builder#displayExponent - */ - public float getDisplayExponent() - { - return displayExponent; - } - - /** - * Returns the current read limit setting. - * @return one of - * {@link #READ_ALL READ_ALL},
- * {@link #READ_HEADER READ_HEADER},
- * {@link #READ_UNTIL_DATA READ_UNTIL_DATA},
- * {@link #READ_EXCEPT_DATA READ_EXCEPT_DATA},
- * or {@link #READ_EXCEPT_METADATA READ_EXCEPT_METADATA} - * @see Builder#readLimit - */ - public int getReadLimit() - { - return readLimit; - } - - /** - * Returns whether warnings are treated as fatal errors. - * @see Builder#warningsFatal - */ - public boolean getWarningsFatal() - { - return warningsFatal; - } - - /** - * Returns the source region to be used. - * @see Builder#sourceRegion - */ - public Rectangle getSourceRegion() - { - return (sourceRegion != null) ? new Rectangle(sourceRegion) : null; - } - - /** - * Returns the number of source columns to advance for each pixel. - * @see Builder#sourceSubsampling - */ - public int getSourceXSubsampling() - { - return subsampling[0]; - } - - /** - * Returns the number of rows to advance for each pixel. - * @see Builder#sourceSubsampling - */ - public int getSourceYSubsampling() - { - return subsampling[1]; - } - - /** - * Returns the horizontal offset of the subsampling grid. - * @see Builder#sourceSubsampling - */ - public int getSubsamplingXOffset() - { - return subsampling[2]; - } - - /** - * Returns the vertical offset of the subsampling grid. - * @see Builder#sourceSubsampling - */ - public int getSubsamplingYOffset() - { - return subsampling[3]; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/PngConstants.java b/javapng2/src/main/com/sixlegs/png/PngConstants.java deleted file mode 100644 index 321d325..0000000 --- a/javapng2/src/main/com/sixlegs/png/PngConstants.java +++ /dev/null @@ -1,308 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -/** - * This interface defines all registered chunk types and provides methods - * helper methods to examine them. It also defines all of the keys used in the property map - * of a decoded {@link PngImage}, and applicable enumerated values. - * @see PngImage#getProperty - * @see PngImage#getProperties - */ -abstract public class PngConstants -{ - - /** - * Returns {@code true} if the given chunk type has the ancillary bit set - * (the first letter is lowercase). - * An ancillary chunk is once which is not strictly necessary - * in order to meaningfully display the contents of the file. - * @param chunkType the chunk type - * @return whether the chunk type ancillary bit is set - */ - public static boolean isAncillary(int chunkType) - { - return ((chunkType & 0x20000000) != 0); - } - - /** - * Returns {@code true} if the given chunk type has the private bit set - * (the second letter is lowercase). - * All unregistered chunk types should have this bit set. - * @param chunkType the chunk type - * @return whether the chunk type private bit is set - */ - public static boolean isPrivate(int chunkType) - { - return ((chunkType & 0x00200000) != 0); - } - - /** - * Returns {@code true} if the given chunk type has the reserved bit set - * (the third letter is lowercase). - * The meaning of this bit is currently undefined, but reserved for future use. - * Images conforming to the current version of the PNG specification must - * not have this bit set. - * @param chunkType the chunk type - * @return whether the chunk type reserved bit is set - */ - public static boolean isReserved(int chunkType) - { - return ((chunkType & 0x00002000) != 0); - } - - /** - * Returns {@code true} if the given chunk type has the safe-to-copy bit set - * (the fourth letter is lowercase). - * Chunks marked as safe-to-copy may be copied to a modified PNG file - * whether or not the software recognizes the chunk type. - * @param chunkType the chunk type - * @return whether the chunk safe-to-copy bit is set - */ - public static boolean isSafeToCopy(int chunkType) - { - return ((chunkType & 0x00000020) != 0); - } - - /** - * Returns the four-character ASCII name corresponding to the given - * chunk type. For example, {@code PngConstants.getChunkName(PngConstants.IHDR)} will - * return {@code "IHDR"}. - * @param chunkType the chunk type - * @return the four-character ASCII chunk name - */ - public static String getChunkName(int chunkType) - { - return ("" + - (char)((chunkType >>> 24) & 0xFF) + - (char)((chunkType >>> 16) & 0xFF) + - (char)((chunkType >>> 8) & 0xFF) + - (char)((chunkType ) & 0xFF)); - } - - /** - * Returns the chunk type corresponding to the given four-character - * ASCII chunk name. - * @param chunkName the four-character ASCII chunk name - * @return the chunk type - * @throws NullPointerException if {@code name} is null - * @throws IndexOutOfBoundsException if {@code name} has less than four characters - */ - public static int getChunkType(String chunkName) - { - return ((((int)chunkName.charAt(0) & 0xFF) << 24) | - (((int)chunkName.charAt(1) & 0xFF) << 16) | - (((int)chunkName.charAt(2) & 0xFF) << 8) | - (((int)chunkName.charAt(3) & 0xFF) )); - } - - /** Eight byte magic number that begins all PNG images */ - public static final long SIGNATURE = 0x89504E470D0A1A0AL; - - /** Image header */ - public static final int IHDR = 0x49484452; - /** Palette */ - public static final int PLTE = 0x504c5445; - /** Image data */ - public static final int IDAT = 0x49444154; - /** Image trailer */ - public static final int IEND = 0x49454e44; - - /** Background color */ - public static final int bKGD = 0x624b4744; - /** Primary chromaticities */ - public static final int cHRM = 0x6348524d; - /** Image gamma */ - public static final int gAMA = 0x67414d41; - /** Palette histogram */ - public static final int hIST = 0x68495354; - /** Embedded ICC profile */ - public static final int iCCP = 0x69434350; - /** International textual data */ - public static final int iTXt = 0x69545874; - /** Physical pixel dimensions */ - public static final int pHYs = 0x70485973; - /** Significant bits */ - public static final int sBIT = 0x73424954; - /** Suggested palette */ - public static final int sPLT = 0x73504c54; - /** Standard RGB color space */ - public static final int sRGB = 0x73524742; - /** Textual data */ - public static final int tEXt = 0x74455874; - /** Image last-modification time */ - public static final int tIME = 0x74494d45; - /** Transparency */ - public static final int tRNS = 0x74524e53; - /** Compressed textual data */ - public static final int zTXt = 0x7a545874; - - /** Image offset */ - public static final int oFFs = 0x6f464673; - /** Calibration of pixel values */ - public static final int pCAL = 0x7043414c; - /** Physical scale of image subject */ - public static final int sCAL = 0x7343414c; - /** GIF Graphic Control Extension */ - public static final int gIFg = 0x67494667; - /** GIF Application Extension */ - public static final int gIFx = 0x67494678; - /** Indicator of Stereo Image */ - public static final int sTER = 0x73544552; - - - /** {@link #IHDR IHDR}: Bit depth */ - public static final String BIT_DEPTH = "bit_depth"; - /** {@link #IHDR IHDR}: Color type */ - public static final String COLOR_TYPE = "color_type"; - /** {@link #IHDR IHDR}: Compression method */ - public static final String COMPRESSION = "compression"; - /** {@link #IHDR IHDR}: Filter method */ - public static final String FILTER = "filter"; - /** {@link #gAMA gAMA}: Gamma */ - public static final String GAMMA = "gamma"; - /** {@link #IHDR IHDR}: Width */ - public static final String WIDTH = "width"; - /** {@link #IHDR IHDR}: Height */ - public static final String HEIGHT = "height"; - /** {@link #IHDR IHDR}: Interlace method */ - public static final String INTERLACE = "interlace"; - /** {@link #PLTE PLTE}: Palette entries */ - public static final String PALETTE = "palette"; - /** {@link #PLTE PLTE}: Palette alpha */ - public static final String PALETTE_ALPHA = "palette_alpha"; - /** {@link #tRNS tRNS}: Transparency samples */ - public static final String TRANSPARENCY = "transparency"; - /** {@link #bKGD bKGD}: Background samples */ - public static final String BACKGROUND = "background_rgb"; - /** {@link #pHYs pHYs}: Pixels per unit, X axis */ - public static final String PIXELS_PER_UNIT_X = "pixels_per_unit_x"; - /** {@link #pHYs pHYs}: Pixels per unit, Y axis */ - public static final String PIXELS_PER_UNIT_Y = "pixels_per_unit_y"; - /** {@link #sRGB sRGB}: Rendering intent */ - public static final String RENDERING_INTENT = "rendering_intent"; - /** {@link #sBIT sBIT}: Significant bits */ - public static final String SIGNIFICANT_BITS = "significant_bits"; - /** {@link #tEXt tEXt}/{@link #zTXt zTXt}/{@link #iTXt iTXt}: List of {@linkplain TextChunk text chunks} */ - public static final String TEXT_CHUNKS = "text_chunks"; - /** {@link #tIME tIME}: Image last-modification time */ - public static final String TIME = "time"; - /** {@link #pHYs pHYs}: Unit specifier */ - public static final String UNIT = "unit"; - /** {@link #cHRM cHRM}: Chromaticity */ - public static final String CHROMATICITY = "chromaticity"; - /** {@link #iCCP iCCP}: ICC profile */ - public static final String ICC_PROFILE = "icc_profile"; - /** {@link #iCCP iCCP}: ICC profile name */ - public static final String ICC_PROFILE_NAME = "icc_profile_name"; - /** {@link #hIST hIST}: Palette histogram */ - public static final String HISTOGRAM = "histogram"; - /** {@link #sPLT sPLT}: List of {@linkplain SuggestedPalette suggested palettes} */ - public static final String SUGGESTED_PALETTES = "suggested_palettes"; - - /** {@link #gIFg gIFg}: GIF disposal method */ - public static final String GIF_DISPOSAL_METHOD = "gif_disposal_method"; - /** {@link #gIFg gIFg}: GIF user input flag */ - public static final String GIF_USER_INPUT_FLAG = "gif_user_input_flag"; - /** {@link #gIFg gIFg}: GIF delay time (hundredths of a second) */ - public static final String GIF_DELAY_TIME = "gif_delay_time"; - /** {@link #sCAL sCAL}: Unit for physical scale of image subject */ - public static final String SCALE_UNIT = "scale_unit"; - /** {@link #sCAL sCAL}: Physical width of pixel */ - public static final String PIXEL_WIDTH = "pixel_width"; - /** {@link #sCAL sCAL}: Physical height of pixel */ - public static final String PIXEL_HEIGHT = "pixel_height"; - /** {@link #oFFs oFFs}: Unit for image offset */ - public static final String POSITION_UNIT = "position_unit"; - /** {@link #sTER sTER}: Indicator of stereo image */ - public static final String STEREO_MODE = "stereo_mode"; - - /** {@link #IHDR IHDR}: Grayscale color type */ - public static final int COLOR_TYPE_GRAY = 0; - /** {@link #IHDR IHDR}: Grayscale+alpha color type */ - public static final int COLOR_TYPE_GRAY_ALPHA = 4; - /** {@link #IHDR IHDR}: Palette color type */ - public static final int COLOR_TYPE_PALETTE = 3; - /** {@link #IHDR IHDR}: RGB color type */ - public static final int COLOR_TYPE_RGB = 2; - /** {@link #IHDR IHDR}: RGBA color type */ - public static final int COLOR_TYPE_RGB_ALPHA = 6; - - /** {@link #IHDR IHDR}: No interlace */ - public static final int INTERLACE_NONE = 0; - /** {@link #IHDR IHDR}: Adam7 interlace */ - public static final int INTERLACE_ADAM7 = 1; - - /** {@link #IHDR IHDR}: Adaptive filtering */ - public static final int FILTER_BASE = 0; - - /** {@link #IHDR IHDR}: Deflate/inflate compression */ - public static final int COMPRESSION_BASE = 0; - - /** {@link #pHYs pHYs}: Unit is unknown */ - public static final int UNIT_UNKNOWN = 0; - /** {@link #pHYs pHYs}: Unit is the meter */ - public static final int UNIT_METER = 1; - - /** {@link #sRGB sRGB}: Perceptual rendering intent */ - public static final int SRGB_PERCEPTUAL = 0; - /** {@link #sRGB sRGB}: Relative colorimetric rendering intent */ - public static final int SRGB_RELATIVE_COLORIMETRIC = 1; - /** {@link #sRGB sRGB}: Saturation rendering intent */ - public static final int SRGB_SATURATION_PRESERVING = 2; - /** {@link #sRGB sRGB}: Absolute colormetric rendering intent */ - public static final int SRGB_ABSOLUTE_COLORIMETRIC = 3; - - /** {@link #oFFs oFFs}: Image X position */ - public static final String POSITION_X = "position_x"; - /** {@link #oFFs oFFs}: Image Y position */ - public static final String POSITION_Y = "position_y"; - /** {@link #oFFs oFFs}: Unit is the pixel (true dimensions unspecified) */ - public static final int POSITION_UNIT_PIXEL = 0; - /** {@link #oFFs oFFs}: Unit is the micrometer (10^-6 meter) */ - public static final int POSITION_UNIT_MICROMETER = 1; - - /** {@link #sCAL sCAL}: Unit is the meter */ - public static final int SCALE_UNIT_METER = 1; - /** {@link #sCAL sCAL}: Unit is the radian */ - public static final int SCALE_UNIT_RADIAN = 2; - - /** {@link #sTER sTER}: Cross-fuse layout */ - public static final int STEREO_MODE_CROSS = 0; - /** {@link #sTER sTER}: Diverging-fuse layout */ - public static final int STEREO_MODE_DIVERGING = 1; -} diff --git a/javapng2/src/main/com/sixlegs/png/PngException.java b/javapng2/src/main/com/sixlegs/png/PngException.java deleted file mode 100644 index 7552e64..0000000 --- a/javapng2/src/main/com/sixlegs/png/PngException.java +++ /dev/null @@ -1,89 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.io.IOException; -import java.lang.reflect.Method; - -/** - * The superclass for all decoding exceptions. - */ -public class PngException -extends IOException -{ - // We use reflection for pre-1.4 JVMs - private static final Method initCause = getInitCause(); - - private static Method getInitCause() { - try { - return PngException.class.getMethod("initCause", new Class[] {Throwable.class}); - } catch (Exception e) { - return null; - } - } - - private final boolean fatal; - - PngException(String message, boolean fatal) - { - this(message, null, fatal); - } - - PngException(String message, Throwable cause, boolean fatal) - { - super(message); - this.fatal = fatal; - if (cause != null && initCause != null) { - try { - initCause.invoke(this, new Object[] {cause}); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new IllegalStateException("Error invoking initCause: " + e.getMessage()); - } - } - } - - /** - * Returns true if this exception represents a fatal decoding error. - * Most errors in non-ancillary chunks are fatal. - */ - public boolean isFatal() - { - return fatal; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/PngImage.java b/javapng2/src/main/com/sixlegs/png/PngImage.java deleted file mode 100644 index 231bb24..0000000 --- a/javapng2/src/main/com/sixlegs/png/PngImage.java +++ /dev/null @@ -1,687 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Transparency; -import java.awt.image.BufferedImage; -import java.io.*; -import java.util.*; - -/** - * A class to decode PNG images. - * The simplest use is if only a decoded {@link BufferedImage} is required: - *
BufferedImage image = new PngImage().read(new java.io.File("test.png"));
- * The {@code PngImage} instance used to read the image also stores all of the - * image metadata. For customized PNG decoding, a {@link PngConfig} object - * may be passed to the {@linkplain #PngImage(PngConfig) constructor}. - *

- * This class is not thread-safe. Do not share a {@code PngImage} instance - * among multiple threads without proper synchronization. - *

- * For more information visit http://www.sixlegs.com/ - * @author Chris Nokleberg <chris@sixlegs.com> - * @see PngConfig - */ -public class PngImage -implements Transparency -{ - private static final PngConfig DEFAULT_CONFIG = - new PngConfig.Builder().build(); - - private final PngConfig config; - private final Map props = new HashMap(); - private boolean read = false; - - /** - * Constructor which uses a default instance of {@link PngConfig}. - */ - public PngImage() - { - this(DEFAULT_CONFIG); - } - - /** - * Constructor which uses the specified configuration. - */ - public PngImage(PngConfig config) - { - this.config = config; - } - - /** - * Returns the configuration used by this object. - * @return the {@code PngConfig} instance used by this object - */ - public PngConfig getConfig() - { - return config; - } - - /** - * Reads a PNG image from the specified file. Image metadata will - * be stored in the property map of this {@code PngImage} instance, - * for retrieval via the various helper methods ({@link #getWidth}, {@link #getHeight}, etc.) - * and {@link #getProperty}. The decoded image itself is returned by this - * method but not cached. - *

- * If {@link PngConfig#getReadLimit} is anything but {@link PngConfig#READ_ALL}, - * then this method will return null instead of the decoded image. - *

- * Multiple images can be read using the same {@code PngImage} instance. - * The property map is cleared each time this method is called. - * @param file the file to read - * @return the decoded image, or null if no image was decoded - * @throws IOException if any error occurred while reading the image - * @see #read(java.io.InputStream, boolean) - * @see #createImage - * @see #handlePass - */ - public BufferedImage read(File file) - throws IOException - { - return read(new BufferedInputStream(new FileInputStream(file)), true); - } - - /** - * Reads a PNG image from the specified input stream. Image metadata will - * be stored in the property map of this {@code PngImage} instance, - * for retrieval via the various helper methods ({@link #getWidth}, {@link #getHeight}, etc.) - * and {@link #getProperty}. The decoded image itself is returned by this - * method but not cached. - *

- * If {@link PngConfig#getReadLimit} is anything but {@link PngConfig#READ_ALL}, - * then this method will return null instead of the decoded image. - *

- * Multiple images can be read using the same {@code PngImage} instance. - * A new property map is created each time this method is called. - * @param in the input stream to read - * @param close whether to close the input stream after reading - * @return the decoded image, or null if no image was decoded - * @throws IOException if any error occurred while reading the image - * @see #read(java.io.File) - * @see #createImage - * @see #handlePass - */ - public BufferedImage read(InputStream in, boolean close) - throws IOException - { - if (in == null) - throw new NullPointerException("InputStream is null"); - this.read = true; - props.clear(); - - int readLimit = config.getReadLimit(); - BufferedImage image = null; - StateMachine machine = new StateMachine(this); - try { - PngInputStream pin = new PngInputStream(in); - Set seen = new HashSet(); - while (machine.getState() != StateMachine.STATE_END) { - int type = pin.startChunk(); - machine.nextState(type); - try { - if (type == PngConstants.IDAT) { - switch (readLimit) { - case PngConfig.READ_UNTIL_DATA: - return null; - case PngConfig.READ_EXCEPT_DATA: - break; - default: - ImageDataInputStream data = new ImageDataInputStream(pin, machine); - image = createImage(data, new Dimension(getWidth(), getHeight())); - while ((type = machine.getType()) == PngConstants.IDAT) { - skipFully(data, pin.getRemaining()); - } - } - } - if (!isMultipleOK(type) && !seen.add(Integers.valueOf(type))) - throw new PngException("Multiple " + PngConstants.getChunkName(type) + " chunks are not allowed", - !PngConstants.isAncillary(type)); - try { - readChunk(type, pin, pin.getOffset(), pin.getRemaining()); - } catch (PngException e) { - throw e; - } catch (IOException e) { - throw new PngException("Malformed " + PngConstants.getChunkName(type) + " chunk", e, - !PngConstants.isAncillary(type)); - } - skipFully(pin, pin.getRemaining()); - if (type == PngConstants.IHDR && readLimit == PngConfig.READ_HEADER) - return null; - } catch (PngException exception) { - if (exception.isFatal()) - throw exception; - skipFully(pin, pin.getRemaining()); - handleWarning(exception); - } - pin.endChunk(type); - } - return image; - } finally { - if (close) - in.close(); - } - } - - /** - * A hook by which subclasses can access or manipulate the raw image data. - * All of the raw, compressed image data contained in the {@code IDAT} chunks - * of the PNG image being read is concatenated and passed to this method - * as a single input stream. The returned image will become the return value - * of the calling {@link #read(java.io.File)} or {@link #read(java.io.InputStream, boolean)} - * method. - *

- * Unlike {@link #readChunk} implementations, subclasses may read less than the correct - * amount from this stream; the remainder will be skipped. - * @param in the input stream of raw, compressed image data - * @param size the size of the image data - * @return the decoded image, or null - * @throws IOException if any error occurred while processing the image data - */ - protected BufferedImage createImage(InputStream in, Dimension size) - throws IOException - { - return ImageFactory.createImage(this, in, size); - } - - /** - * A method which subclasses may override to take some action - * after each pass has been decoded. An interlaced image has seven - * passes, and non-interlaced image only one. The {@code pass} - * arguments indicates the index of the completed - * pass, starting with zero. - *

- * For interlaced images, the state of the image data before the last - * pass is affected by the value of {@link PngConfig#getProgressive}. - *

- * Image decoding can be aborted by returning false. The default - * implementation always returns true. - * @param image the partially or fully decoded image - * @param pass the index of the completed pass - * @return false to abort image decoding - */ - protected boolean handlePass(BufferedImage image, int pass) - { - return true; - } - - /** - * Reports the approximate degree of completion of the current read - * call. This method is called periodically during - * image decoding. The degree of completion is expressed as a percentage - * varying from 0.0F to 100.0F, and is calculated using the number - * of pixels decoded. - *

- * Image decoding can be aborted by returning false. The default - * implementation returns true. - * @param image the partially or fully decoded image - * @param pct the approximate percentage of decoding that has been completed - * @return false to abort image decoding - */ - protected boolean handleProgress(BufferedImage image, float pct) - { - return true; - } - - /** - * Callback for customized handling of warnings. Whenever a - * non-fatal error is found, an instance of {@link PngException} is - * created and passed to this method. To signal that the exception - * should be treated as a fatal exception (and abort image - * processing), an implementation should re-throw the exception. - *

- * By default, this method will re-throw the warning if the - * {@link PngConfig#getWarningsFatal warningsFatal} property is true. - * @throws PngException if the warning should be treated as fatal - */ - protected void handleWarning(PngException e) - throws PngException - { - if (config.getWarningsFatal()) - throw e; - } - - /** - * Returns the image widt hin pixels. - * @throws IllegalStateException if an image has not been read - */ - public int getWidth() - { - return getInt(PngConstants.WIDTH); - } - - /** - * Returns the image height in pixels. - * @throws IllegalStateException if an image has not been read - */ - public int getHeight() - { - return getInt(PngConstants.HEIGHT); - } - - /** - * Returns the image bit depth. - * @return 1, 2, 4, 8, or 16 - * @throws IllegalStateException if an image has not been read - */ - public int getBitDepth() - { - return getInt(PngConstants.BIT_DEPTH); - } - - /** - * Returns true if the image interlace type ({@link PngConstants#INTERLACE}) - * is something other than {@link PngConstants#INTERLACE_NONE INTERLACE_NONE}. - * @return true if the image is interlaced - * @throws IllegalStateException if an image has not been read - */ - public boolean isInterlaced() - { - return getInt(PngConstants.INTERLACE) != PngConstants.INTERLACE_NONE; - } - - /** - * Returns the image color type. - * @return - * {@link PngConstants#COLOR_TYPE_GRAY COLOR_TYPE_GRAY},
- * {@link PngConstants#COLOR_TYPE_GRAY_ALPHA COLOR_TYPE_GRAY_ALPHA},
- * {@link PngConstants#COLOR_TYPE_PALETTE COLOR_TYPE_PALETTE},
- * {@link PngConstants#COLOR_TYPE_RGB COLOR_TYPE_RGB},
- * or {@link PngConstants#COLOR_TYPE_RGB_ALPHA COLOR_TYPE_RGB_ALPHA} - * @throws IllegalStateException if an image has not been read - */ - public int getColorType() - { - return getInt(PngConstants.COLOR_TYPE); - } - - /** - * Returns the type of this Transparency. - * @return the field type of this Transparency, which is either OPAQUE, BITMASK or TRANSLUCENT. - * @throws IllegalStateException if an image has not been read - */ - public int getTransparency() - { - int colorType = getColorType(); - return (colorType == PngConstants.COLOR_TYPE_RGB_ALPHA || - colorType == PngConstants.COLOR_TYPE_GRAY_ALPHA || - props.containsKey(PngConstants.TRANSPARENCY) || - props.containsKey(PngConstants.PALETTE_ALPHA)) ? - TRANSLUCENT : OPAQUE; - } - - /** - * Returns the number of samples per pixel. Gray and paletted - * images use one sample, gray+alpha uses two, RGB uses three, - * and RGB+alpha uses four. - * @return 1, 2, 3 or 4 - * @throws IllegalStateException if an image has not been read - */ - public int getSamples() - { - switch (getColorType()) { - case PngConstants.COLOR_TYPE_GRAY_ALPHA: return 2; - case PngConstants.COLOR_TYPE_RGB: return 3; - case PngConstants.COLOR_TYPE_RGB_ALPHA: return 4; - } - return 1; - } - - /** - * Returns the gamma exponent that was explicitly encoded in the image, - * if there was one, or the value of {@link PngConfig#getDefaultGamma} otherwise. - * @return the gamma exponent - * @throws IllegalStateException if an image has not been read - */ - public float getGamma() - { - assertRead(); - if (props.containsKey(PngConstants.GAMMA)) - return ((Number)getProperty(PngConstants.GAMMA, Number.class, true)).floatValue(); - return config.getDefaultGamma(); - } - - /** - * Returns a gamma table which can be used for custom gamma correction. - * The table is 256 entries unless the bit depth is 16 and - * {@link PngConfig#getReduce16} is false, in which - * case the table is 65535 entries. - *

- * The values in the table take into account {@link #getGamma} and - * {@link PngConfig#getDisplayExponent}. - * @return a table of component values to be used in gamma correction - * @throws IllegalStateException if an image has not been read - */ - public short[] getGammaTable() - { - assertRead(); - return createGammaTable(getGamma(), - config.getDisplayExponent(), - getBitDepth() == 16 && !config.getReduce16()); - } - - static short[] createGammaTable(float gamma, float displayExponent, boolean large) - { - int size = 1 << (large ? 16 : 8); - short[] gammaTable = new short[size]; - double decodingExponent = 1d / ((double)gamma * (double)displayExponent); - for (int i = 0; i < size; i++) - gammaTable[i] = (short)(Math.pow((double)i / (size - 1), decodingExponent) * (size - 1)); - return gammaTable; - } - - // TODO: gamma-correct background? - /** - * Returns the background color explicitly encoded in the image. - * For 16-bit images the components are reduced to 8-bit by shifting. - * @return the background color, or null - * @throws IllegalStateException if an image has not been read - */ - public Color getBackground() - { - int[] background = (int[])getProperty(PngConstants.BACKGROUND, int[].class, false); - if (background == null) - return null; - switch (getColorType()) { - case PngConstants.COLOR_TYPE_PALETTE: - byte[] palette = (byte[])getProperty(PngConstants.PALETTE, byte[].class, true); - int index = background[0] * 3; - return new Color(0xFF & palette[index + 0], - 0xFF & palette[index + 1], - 0xFF & palette[index + 2]); - case PngConstants.COLOR_TYPE_GRAY: - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - int gray = background[0] * 255 / ((1 << getBitDepth()) - 1); - return new Color(gray, gray, gray); - default: - if (getBitDepth() == 16) { - return new Color(background[0] >> 8, background[1] >> 8, background[2] >> 8); - } else { - return new Color(background[0], background[1], background[2]); - } - } - } - - /** - * Returns a per-image property by name. All common property names are defined in - * {@link PngConstants}; their types are listed in the following table. - * The use of the various helper methods defined in this class, such as {@link #getBackground}, - * is normally preferrable to working with the raw property values. - *

- *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
PropertyTypeDescription
{@link PngConstants#BIT_DEPTH BIT_DEPTH}{@link Integer Integer}Bit depth
{@link PngConstants#COLOR_TYPE COLOR_TYPE}{@link Integer Integer}Color type
{@link PngConstants#COMPRESSION COMPRESSION}{@link Integer Integer}Compression method
{@link PngConstants#FILTER FILTER}{@link Integer Integer}Filter method
{@link PngConstants#GAMMA GAMMA}{@link Float Float}Gamma
{@link PngConstants#WIDTH WIDTH}{@link Integer Integer}Width
{@link PngConstants#HEIGHT HEIGHT}{@link Integer Integer}Height
{@link PngConstants#INTERLACE INTERLACE}{@link Integer Integer}Interlace method
{@link PngConstants#PALETTE PALETTE}{@code byte[]}Palette entries
{@link PngConstants#PALETTE_ALPHA PALETTE_ALPHA}{@code byte[]}Palette alpha
{@link PngConstants#TRANSPARENCY TRANSPARENCY}{@code int[]}Transparency samples
{@link PngConstants#BACKGROUND BACKGROUND}{@code int[]}Background samples
{@link PngConstants#PIXELS_PER_UNIT_X PIXELS_PER_UNIT_X}{@link Integer Integer}Pixels per unit, X axis
{@link PngConstants#PIXELS_PER_UNIT_Y PIXELS_PER_UNIT_Y}{@link Integer Integer}Pixels per unit, Y axis
{@link PngConstants#UNIT UNIT}{@link Integer Integer}Unit specifier
{@link PngConstants#RENDERING_INTENT RENDERING_INTENT}{@link Integer Integer}Rendering intent
{@link PngConstants#SIGNIFICANT_BITS SIGNIFICANT_BITS}{@code byte[]}Significant bits
{@link PngConstants#TEXT_CHUNKS TEXT_CHUNKS}{@link java.util.List List}List of {@linkplain TextChunk text chunks}
{@link PngConstants#TIME TIME}{@link java.util.Date Date}Image last-modification time
{@link PngConstants#CHROMATICITY CHROMATICITY}{@code float[]}Chromaticity
{@link PngConstants#ICC_PROFILE ICC_PROFILE}{@code byte[]}ICC profile
{@link PngConstants#ICC_PROFILE_NAME ICC_PROFILE_NAME}{@link String String}ICC profile name
{@link PngConstants#HISTOGRAM HISTOGRAM}{@code int[]}Palette histogram
{@link PngConstants#SUGGESTED_PALETTES SUGGESTED_PALETTES}{@link java.util.List List}List of {@linkplain SuggestedPalette suggested palettes}
{@link PngConstants#GIF_DISPOSAL_METHOD GIF_DISPOSAL_METHOD}{@link Integer Integer}GIF disposal method
{@link PngConstants#GIF_USER_INPUT_FLAG GIF_USER_INPUT_FLAG}{@link Integer Integer}GIF user input flag
{@link PngConstants#GIF_DELAY_TIME GIF_DELAY_TIME}{@link Integer Integer}GIF delay time (hundredths of a second)
{@link PngConstants#SCALE_UNIT SCALE_UNIT}{@link Integer Integer}Unit for physical scale of image subject
{@link PngConstants#PIXEL_WIDTH PIXEL_WIDTH}{@link Double Double}Physical width of pixel
{@link PngConstants#PIXEL_HEIGHT PIXEL_HEIGHT}{@link Double Double}Physical height of pixel
{@link PngConstants#POSITION_UNIT POSITION_UNIT}{@link Integer Integer}Unit for image offset
{@link PngConstants#STEREO_MODE STEREO_MODE}{@link Integer Integer}Indicator of stereo image
- * @param name a property name - * @return the property value, or null if no such property exists - * @throws IllegalStateException if an image has not been read - */ - public Object getProperty(String name) - { - assertRead(); - return props.get(name); - } - - Object getProperty(String name, Class type, boolean required) - { - assertRead(); - Object value = props.get(name); - if (value == null) { - if (required) - throw new IllegalStateException("Image is missing property \"" + name + "\""); - } else if (!type.isAssignableFrom(value.getClass())) { - throw new IllegalStateException("Property \"" + name + "\" has type " + value.getClass().getName() + ", expected " + type.getName()); - } - return value; - } - - private int getInt(String name) - { - return ((Number)getProperty(name, Number.class, true)).intValue(); - } - - /** - * Returns the map which stores all of this image's property values. - * The map is mutable, and storing a value with the wrong type may - * result in other methods in this class throwing {@code IllegalStateException} or - * {@code ClassCastException}. - * @return the mutable map of image properties - */ - public Map getProperties() - { - return props; - } - - /** - * Returns a text chunk that uses the given keyword, if one exists. - * If multiple text chunks share the same keyword, this method - * will return the first one that was read. The full list of text - * chunks may be accessed by calling - *
{@linkplain #getProperty getProperty}({@linkplain PngConstants#TEXT_CHUNKS})
- * @param key the text chunk keyword - * @return a {@link TextChunk} implementation, or null - * @throws IllegalStateException if an image has not been read - */ - public TextChunk getTextChunk(String key) - { - List list = (List)getProperty(PngConstants.TEXT_CHUNKS, List.class, false); - if (key != null && list != null) { - for (Iterator it = list.iterator(); it.hasNext();) { - // TODO: check list value type before cast? - TextChunk chunk = (TextChunk)it.next(); - if (chunk.getKeyword().equals(key)) - return chunk; - } - } - return null; - } - - /** - * Read the chunk data from the image input stream, storing - * properties into this {@code PngImage} instance. - *

- * By default this method will handle all of the chunk types defined - * in Version 1.2 of the PNG Specification, and most of the - * registered extension chunks. - * {@code IDAT} chunks will be processed through this method only if - * {@link PngConfig#getReadLimit} is set to {@link PngConfig#READ_EXCEPT_DATA}. - *

- * Attempting to read past the end of the chunk data will result in - * an {@link EOFException}. Unread data will be skipped. - * @param type the chunk type - * @param in the chunk data - * @param offset the location of the chunk data within the entire PNG datastream - * @param length the length of the chunk data - */ - protected void readChunk(int type, DataInput in, long offset, int length) - throws IOException - { - if (type == PngConstants.IDAT) - return; - if (config.getReadLimit() == PngConfig.READ_EXCEPT_METADATA && PngConstants.isAncillary(type)) { - switch (type) { - case PngConstants.gAMA: - case PngConstants.tRNS: - break; - default: - return; - } - } - RegisteredChunks.read(type, in, length, this); - } - - /** - * Returns whether a chunk is allowed to occur multiple times. - *

- * By default this method returns {@code true} only for {@link PngConstants#sPLT sPLT}, - * {@link PngConstants#iTXt iTXt}, {@link PngConstants#tEXt tEXt}, - * {@link PngConstants#zTXt zTXt}, and {@link PngConstants#IDAT IDAT}. - * @param type the chunk type - * @return whether multiple chunks of the given type are allowed - */ - protected boolean isMultipleOK(int type) - { - switch (type) { - case PngConstants.IDAT: - case PngConstants.sPLT: - case PngConstants.iTXt: - case PngConstants.tEXt: - case PngConstants.zTXt: - return true; - } - return false; - } - - private void assertRead() - { - if (!read) - throw new IllegalStateException("Image has not been read"); - } - - private static void skipFully(InputStream in, long n) throws IOException { - while (n > 0) { - long amt = in.skip(n); - if (amt == 0) { - // Force a blocking read to avoid infinite loop - if (in.read() == -1) { - throw new EOFException(); - } - n--; - } else { - n -= amt; - } - } - } -} diff --git a/javapng2/src/main/com/sixlegs/png/PngInputStream.java b/javapng2/src/main/com/sixlegs/png/PngInputStream.java deleted file mode 100644 index b634706..0000000 --- a/javapng2/src/main/com/sixlegs/png/PngInputStream.java +++ /dev/null @@ -1,268 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.io.*; -import java.util.zip.*; - -/** - * An input stream used to read PNG chunk data. - * @see PngConstants#read - * @see #getRemaining - */ -final class PngInputStream -extends InputStream -implements DataInput -{ - private final CRC32 crc = new CRC32(); - private final InputStream in; - private final DataInputStream data; - private final byte[] tmp = new byte[0x1000]; - private long total; - private int length; - private int left; - - public PngInputStream(InputStream in) - throws IOException - { - this.in = in; - data = new DataInputStream(this); - left = 8; - long sig = readLong(); - if (sig != PngConstants.SIGNATURE) { - throw new PngException("Improper signature, expected 0x" + - Long.toHexString(PngConstants.SIGNATURE) + ", got 0x" + - Long.toHexString(sig), true); - } - total += 8; - } - - public int startChunk() - throws IOException - { - left = 8; // length, type - length = readInt(); - if (length < 0) - throw new PngException("Bad chunk length: " + (0xFFFFFFFFL & length), true); - crc.reset(); - int type = readInt(); - left = length; - total += 8; - return type; - } - - public int endChunk(int type) - throws IOException - { - if (getRemaining() != 0) - throw new PngException(PngConstants.getChunkName(type) + " read " + (length - left) + " bytes, expected " + length, true); - left = 4; - int actual = (int)crc.getValue(); - int expect = readInt(); - if (actual != expect) - throw new PngException("Bad CRC value for " + PngConstants.getChunkName(type) + " chunk", true); - total += length + 4; - return actual; - } - - ////////// count/crc InputStream methods ////////// - - public int read() - throws IOException - { - if (left == 0) - return -1; - int result = in.read(); - if (result != -1) { - crc.update(result); - left--; - } - return result; - } - - public int read(byte[] b, int off, int len) - throws IOException - { - if (len == 0) - return 0; - if (left == 0) - return -1; - int result = in.read(b, off, Math.min(left, len)); - if (result != -1) { - crc.update(b, off, result); - left -= result; - } - return result; - } - - public long skip(long n) - throws IOException - { - int result = read(tmp, 0, (int)Math.min(tmp.length, n)); - return (result < 0) ? 0 : result; - } - - public void close() - { - throw new UnsupportedOperationException("do not close me"); - } - - ////////// DataInput methods we implement directly ////////// - - public boolean readBoolean() - throws IOException - { - return readUnsignedByte() != 0; - } - - public int readUnsignedByte() - throws IOException - { - int a = read(); - if (a < 0) - throw new EOFException(); - return a; - } - - public byte readByte() - throws IOException - { - return (byte)readUnsignedByte(); - } - - public int readUnsignedShort() - throws IOException - { - int a = read(); - int b = read(); - if ((a | b) < 0) - throw new EOFException(); - return (a << 8) + (b << 0); - } - - public short readShort() - throws IOException - { - return (short)readUnsignedShort(); - } - - public char readChar() - throws IOException - { - return (char)readUnsignedShort(); - } - - public int readInt() - throws IOException - { - int a = read(); - int b = read(); - int c = read(); - int d = read(); - if ((a | b | c | d) < 0) - throw new EOFException(); - return ((a << 24) + (b << 16) + (c << 8) + (d << 0)); - } - - public long readLong() - throws IOException - { - return ((0xFFFFFFFFL & readInt()) << 32) | (0xFFFFFFFFL & readInt()); - } - - public float readFloat() - throws IOException - { - return Float.intBitsToFloat(readInt()); - } - - public double readDouble() - throws IOException - { - return Double.longBitsToDouble(readLong()); - } - - ////////// DataInput methods we delegate ////////// - - public void readFully(byte[] b) - throws IOException - { - data.readFully(b, 0, b.length); - } - - public void readFully(byte[] b, int off, int len) - throws IOException - { - data.readFully(b, off, len); - } - - public int skipBytes(int n) - throws IOException - { - return data.skipBytes(n); - } - - public String readLine() - throws IOException - { - return data.readLine(); - } - - public String readUTF() - throws IOException - { - return data.readUTF(); - } - - ////////// PNG-specific methods ////////// - - /** - * Returns the number of bytes of chunk data that the - * {@link PngConstants#read} method implementation is required to read. - * Use {@link #skipBytes} to skip the data. - * @return the number of bytes in the chunk remaining to be read - */ - public int getRemaining() - { - return left; - } - - public long getOffset() - { - return total; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/ProgressUpdater.java b/javapng2/src/main/com/sixlegs/png/ProgressUpdater.java deleted file mode 100644 index cc63732..0000000 --- a/javapng2/src/main/com/sixlegs/png/ProgressUpdater.java +++ /dev/null @@ -1,74 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.image.BufferedImage; - -final class ProgressUpdater -extends PixelProcessor -{ - private static final int STEP_PERCENT = 5; - - final private PngImage png; - final private BufferedImage image; - final private PixelProcessor pp; - final private int total; - final private int step; - private int count; - private int mod; - - public ProgressUpdater(PngImage png, BufferedImage image, PixelProcessor pp) - { - this.png = png; - this.image = image; - this.pp = pp; - total = png.getWidth() * png.getHeight(); - step = Math.max(1, total * STEP_PERCENT / 100); - } - - public boolean process(int[] row, int xOffset, int xStep, int yStep, int y, int width) - { - boolean result = pp.process(row, xOffset, xStep, yStep, y, width); - mod += width; - count += width; - if (mod > step) { - mod %= step; - result = result && png.handleProgress(image, 100f * count / total); - } - return result; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/ProgressivePixelProcessor.java b/javapng2/src/main/com/sixlegs/png/ProgressivePixelProcessor.java deleted file mode 100644 index 83e8b82..0000000 --- a/javapng2/src/main/com/sixlegs/png/ProgressivePixelProcessor.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -final class ProgressivePixelProcessor -extends PixelProcessor -{ - private final PixelProcessor pp; - private final int imgWidth; - private final int imgHeight; - private final Destination dst; - private final int samples; - private final int[] pixels; - - public ProgressivePixelProcessor(Destination dst, PixelProcessor pp, int imgWidth, int imgHeight) - { - this.pp = pp; - this.imgWidth = imgWidth; - this.imgHeight = imgHeight; - this.dst = dst; - this.samples = dst.getRaster().getNumBands(); - this.pixels = new int[samples * 8]; - } - - public boolean process(int[] row, int xOffset, int xStep, int yStep, int y, int width) - { - // run non-progressive processor first - pp.process(row, xOffset, xStep, yStep, y, width); - - // then replicate pixels across entire block - int blockHeight = xStep; - int blockWidth = xStep - xOffset; - if (blockWidth > 1 || blockHeight > 1) { - int yMax = Math.min(y + blockHeight, imgHeight); - for (int srcX = 0, dstX = xOffset; srcX < width; srcX++) { - dst.getPixel(dstX, y, pixels); - int xMax = Math.min(dstX + blockWidth, imgWidth); - int xPixels = xMax - dstX; - for (int i = samples, end = xPixels * samples; i < end; i++) - pixels[i] = pixels[i - samples]; - for (int i = y; i < yMax; i++) - dst.setPixels(dstX, i, xPixels, pixels); - dstX += xStep; - } - } - return true; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/RasterDestination.java b/javapng2/src/main/com/sixlegs/png/RasterDestination.java deleted file mode 100644 index c4ea45b..0000000 --- a/javapng2/src/main/com/sixlegs/png/RasterDestination.java +++ /dev/null @@ -1,81 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.image.WritableRaster; - -class RasterDestination -extends Destination -{ - protected final WritableRaster raster; - protected final int sourceWidth; - - public RasterDestination(WritableRaster raster, int sourceWidth) - { - this.raster = raster; - this.sourceWidth = sourceWidth; - } - - public void setPixels(int x, int y, int w, int[] pixels) - { - raster.setPixels(x, y, w, 1, pixels); - } - - public void setPixel(int x, int y, int[] pixel) - { - raster.setPixel(x, y, pixel); - } - - public void getPixel(int x, int y, int[] pixel) - { - raster.getPixel(x, y, pixel); - } - - public WritableRaster getRaster() - { - return raster; - } - - public int getSourceWidth() - { - return sourceWidth; - } - - public void done() - { - } -} diff --git a/javapng2/src/main/com/sixlegs/png/RegisteredChunks.java b/javapng2/src/main/com/sixlegs/png/RegisteredChunks.java deleted file mode 100644 index 28b351f..0000000 --- a/javapng2/src/main/com/sixlegs/png/RegisteredChunks.java +++ /dev/null @@ -1,541 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.io.*; -import java.util.*; -import java.util.zip.*; - -class RegisteredChunks -{ - private static final TimeZone TIME_ZONE = TimeZone.getTimeZone("UTC"); - private static final String ISO_8859_1 = "ISO-8859-1"; - private static final String US_ASCII = "US-ASCII"; - private static final String UTF_8 = "UTF-8"; - - public static boolean read(int type, DataInput in, int length, PngImage png) - throws IOException - { - Map props = png.getProperties(); - switch (type) { - case PngConstants.IHDR: read_IHDR(in, length, props); break; - case PngConstants.IEND: checkLength(PngConstants.IEND, length, 0); break; - case PngConstants.PLTE: read_PLTE(in, length, props, png); break; - case PngConstants.bKGD: read_bKGD(in, length, props, png); break; - case PngConstants.tRNS: read_tRNS(in, length, props, png); break; - case PngConstants.sBIT: read_sBIT(in, length, props, png); break; - case PngConstants.hIST: read_hIST(in, length, props, png); break; - case PngConstants.sPLT: read_sPLT(in, length, props, png); break; - case PngConstants.cHRM: read_cHRM(in, length, props); break; - case PngConstants.gAMA: read_gAMA(in, length, props); break; - case PngConstants.iCCP: read_iCCP(in, length, props); break; - case PngConstants.pHYs: read_pHYs(in, length, props); break; - case PngConstants.sRGB: read_sRGB(in, length, props); break; - case PngConstants.tIME: read_tIME(in, length, props); break; - case PngConstants.gIFg: read_gIFg(in, length, props); break; - case PngConstants.oFFs: read_oFFs(in, length, props); break; - case PngConstants.sCAL: read_sCAL(in, length, props); break; - case PngConstants.sTER: read_sTER(in, length, props); break; - // case PngConstants.gIFx: read_gIFx(in, length, props); break; - case PngConstants.iTXt: - case PngConstants.tEXt: - case PngConstants.zTXt: - readText(type, in, length, props, png); - break; - default: - return false; - } - return true; - } - - private static void read_IHDR(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.IHDR, length, 13); - int width = in.readInt(); - int height = in.readInt(); - if (width <= 0 || height <= 0) - throw new PngException("Bad image size: " + width + "x" + height, true); - - byte bitDepth = in.readByte(); - switch (bitDepth) { - case 1: case 2: case 4: case 8: case 16: break; - default: throw new PngException("Bad bit depth: " + bitDepth, true); - } - - byte[] sbits = null; - int colorType = in.readUnsignedByte(); - switch (colorType) { - case PngConstants.COLOR_TYPE_RGB: - case PngConstants.COLOR_TYPE_GRAY: - break; - case PngConstants.COLOR_TYPE_PALETTE: - if (bitDepth == 16) - throw new PngException("Bad bit depth for color type " + colorType + ": " + bitDepth, true); - break; - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - case PngConstants.COLOR_TYPE_RGB_ALPHA: - if (bitDepth <= 4) - throw new PngException("Bad bit depth for color type " + colorType + ": " + bitDepth, true); - break; - default: - throw new PngException("Bad color type: " + colorType, true); - } - - int compression = in.readUnsignedByte(); - if (compression != PngConstants.COMPRESSION_BASE) - throw new PngException("Unrecognized compression method: " + compression, true); - - int filter = in.readUnsignedByte(); - if (filter != PngConstants.FILTER_BASE) - throw new PngException("Unrecognized filter method: " + filter, true); - - int interlace = in.readUnsignedByte(); - switch (interlace) { - case PngConstants.INTERLACE_NONE: - case PngConstants.INTERLACE_ADAM7: - break; - default: - throw new PngException("Unrecognized interlace method: " + interlace, true); - } - - props.put(PngConstants.WIDTH, Integers.valueOf(width)); - props.put(PngConstants.HEIGHT, Integers.valueOf(height)); - props.put(PngConstants.BIT_DEPTH, Integers.valueOf(bitDepth)); - props.put(PngConstants.INTERLACE, Integers.valueOf(interlace)); - props.put(PngConstants.COMPRESSION, Integers.valueOf(compression)); - props.put(PngConstants.FILTER, Integers.valueOf(filter)); - props.put(PngConstants.COLOR_TYPE, Integers.valueOf(colorType)); - } - - private static void read_PLTE(DataInput in, int length, Map props, PngImage png) - throws IOException - { - if (length == 0) - throw new PngException("PLTE chunk cannot be empty", true); - if (length % 3 != 0) - throw new PngException("PLTE chunk length indivisible by 3: " + length, true); - int size = length / 3; - if (size > 256) - throw new PngException("Too many palette entries: " + size, true); - switch (png.getColorType()) { - case PngConstants.COLOR_TYPE_PALETTE: - if (size > (2 << (png.getBitDepth() - 1))) - throw new PngException("Too many palette entries: " + size, true); - break; - case PngConstants.COLOR_TYPE_GRAY: - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - throw new PngException("PLTE chunk found in grayscale image", false); - } - byte[] palette = new byte[length]; - in.readFully(palette); - props.put(PngConstants.PALETTE, palette); - } - - private static void read_tRNS(DataInput in, int length, Map props, PngImage png) - throws IOException - { - switch (png.getColorType()) { - case PngConstants.COLOR_TYPE_GRAY: - checkLength(PngConstants.tRNS, length, 2); - props.put(PngConstants.TRANSPARENCY, new int[]{ in.readUnsignedShort() }); - break; - case PngConstants.COLOR_TYPE_RGB: - checkLength(PngConstants.tRNS, length, 6); - props.put(PngConstants.TRANSPARENCY, new int[]{ - in.readUnsignedShort(), - in.readUnsignedShort(), - in.readUnsignedShort(), - }); - break; - case PngConstants.COLOR_TYPE_PALETTE: - int paletteSize = ((byte[])png.getProperty(PngConstants.PALETTE, byte[].class, true)).length / 3; - if (length > paletteSize) - throw new PngException("Too many transparency palette entries (" + length + " > " + paletteSize + ")", true); - byte[] trans = new byte[length]; - in.readFully(trans); - props.put(PngConstants.PALETTE_ALPHA, trans); - break; - default: - throw new PngException("tRNS prohibited for color type " + png.getColorType(), true); - } - } - - private static void read_bKGD(DataInput in, int length, Map props, PngImage png) - throws IOException - { - int[] background; - switch (png.getColorType()) { - case PngConstants.COLOR_TYPE_PALETTE: - checkLength(PngConstants.bKGD, length, 1); - background = new int[]{ in.readUnsignedByte() }; - break; - case PngConstants.COLOR_TYPE_GRAY: - case PngConstants.COLOR_TYPE_GRAY_ALPHA: - checkLength(PngConstants.bKGD, length, 2); - background = new int[]{ in.readUnsignedShort() }; - break; - default: - // truecolor - checkLength(PngConstants.bKGD, length, 6); - background = new int[]{ - in.readUnsignedShort(), - in.readUnsignedShort(), - in.readUnsignedShort(), - }; - } - props.put(PngConstants.BACKGROUND, background); - } - - private static void read_cHRM(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.cHRM, length, 32); - float[] array = new float[8]; - for (int i = 0; i < 8; i++) - array[i] = in.readInt() / 100000f; - if (!props.containsKey(PngConstants.CHROMATICITY)) - props.put(PngConstants.CHROMATICITY, array); - } - - private static void read_gAMA(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.gAMA, length, 4); - int gamma = in.readInt(); - if (gamma == 0) - throw new PngException("Meaningless zero gAMA chunk value", false); - if (!props.containsKey(PngConstants.RENDERING_INTENT)) - props.put(PngConstants.GAMMA, new Float(gamma / 100000f)); - } - - private static void read_hIST(DataInput in, int length, Map props, PngImage png) - throws IOException - { - // TODO: ensure it is divisible by three - int paletteSize = ((byte[])png.getProperty(PngConstants.PALETTE, byte[].class, true)).length / 3; - checkLength(PngConstants.hIST, length, paletteSize * 2); - int[] array = new int[paletteSize]; - for (int i = 0; i < paletteSize; i++) - array[i] = in.readUnsignedShort(); - props.put(PngConstants.HISTOGRAM, array); - } - - private static void read_iCCP(DataInput in, int length, Map props) - throws IOException - { - String name = readKeyword(in, length); - byte[] data = readCompressed(in, length - name.length() - 1, true); - props.put(PngConstants.ICC_PROFILE_NAME, name); - props.put(PngConstants.ICC_PROFILE, data); - } - - private static void read_pHYs(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.pHYs, length, 9); - int pixelsPerUnitX = in.readInt(); - int pixelsPerUnitY = in.readInt(); - int unit = in.readUnsignedByte(); - if (unit != PngConstants.UNIT_UNKNOWN && unit != PngConstants.UNIT_METER) - throw new PngException("Illegal pHYs chunk unit specifier: " + unit, false); - props.put(PngConstants.PIXELS_PER_UNIT_X, Integers.valueOf(pixelsPerUnitX)); - props.put(PngConstants.PIXELS_PER_UNIT_Y, Integers.valueOf(pixelsPerUnitY)); - props.put(PngConstants.UNIT, Integers.valueOf(unit)); - } - - private static void read_sBIT(DataInput in, int length, Map props, PngImage png) - throws IOException - { - boolean paletted = png.getColorType() == PngConstants.COLOR_TYPE_PALETTE; - int count = paletted ? 3 : png.getSamples(); - checkLength(PngConstants.sBIT, length, count); - int depth = paletted ? 8 : png.getBitDepth(); - byte[] array = new byte[count]; - for (int i = 0; i < count; i++) { - byte bits = in.readByte(); - if (bits <= 0 || bits > depth) - throw new PngException("Illegal sBIT sample depth", false); - array[i] = bits; - } - props.put(PngConstants.SIGNIFICANT_BITS, array); - } - - private static void read_sRGB(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.sRGB, length, 1); - int intent = in.readByte(); - props.put(PngConstants.RENDERING_INTENT, Integers.valueOf(intent)); - props.put(PngConstants.GAMMA, new Float(0.45455)); - props.put(PngConstants.CHROMATICITY, new float[]{ - 0.3127f, 0.329f, 0.64f, 0.33f, 0.3f, 0.6f, 0.15f, 0.06f, - }); - } - - private static void read_tIME(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.tIME, length, 7); - Calendar cal = Calendar.getInstance(TIME_ZONE); - cal.set(in.readUnsignedShort(), - check(in.readUnsignedByte(), 1, 12, "month") - 1, - check(in.readUnsignedByte(), 1, 31, "day"), - check(in.readUnsignedByte(), 0, 23, "hour"), - check(in.readUnsignedByte(), 0, 59, "minute"), - check(in.readUnsignedByte(), 0, 60, "second")); - props.put(PngConstants.TIME, cal.getTime()); - } - - private static int check(int value, int min, int max, String field) - throws PngException - { - if (value < min || value > max) - throw new PngException("tIME " + field + " value " + value + - " is out of bounds (" + min + "-" + max + ")", false); - return value; - } - - private static void read_sPLT(DataInput in, int length, Map props, PngImage png) - throws IOException - { - String name = readKeyword(in, length); - int sampleDepth = in.readByte(); - if (sampleDepth != 8 && sampleDepth != 16) - throw new PngException("Sample depth must be 8 or 16", false); - - length -= (name.length() + 2); - if ((length % ((sampleDepth == 8) ? 6 : 10)) != 0) - throw new PngException("Incorrect sPLT data length for given sample depth", false); - byte[] bytes = new byte[length]; - in.readFully(bytes); - - List palettes = (List)png.getProperty(PngConstants.SUGGESTED_PALETTES, List.class, false); - if (palettes == null) - props.put(PngConstants.SUGGESTED_PALETTES, palettes = new ArrayList()); - for (Iterator it = palettes.iterator(); it.hasNext();) { - if (name.equals(((SuggestedPalette)it.next()).getName())) - throw new PngException("Duplicate suggested palette name " + name, false); - } - palettes.add(new SuggestedPaletteImpl(name, sampleDepth, bytes)); - } - - private static void readText(int type, DataInput in, int length, Map props, PngImage png) - throws IOException - { - byte[] bytes = new byte[length]; - in.readFully(bytes); - DataInputStream data = new DataInputStream(new ByteArrayInputStream(bytes)); - - String keyword = readKeyword(data, length); - String enc = ISO_8859_1; - boolean compressed = false; - boolean readMethod = true; - String language = null; - String translated = null; - switch (type) { - case PngConstants.tEXt: - break; - case PngConstants.zTXt: - compressed = true; - break; - case PngConstants.iTXt: - enc = UTF_8; - int flag = data.readByte(); - int method = data.readByte(); - if (flag == 1) { - compressed = true; - readMethod = false; - if (method != 0) - throw new PngException("Unrecognized " + PngConstants.getChunkName(type) + " compression method: " + method, false); - } else if (flag != 0) { - throw new PngException("Illegal " + PngConstants.getChunkName(type) + " compression flag: " + flag, false); - } - language = readString(data, data.available(), US_ASCII); - // TODO: split language on hyphens, check that each component is 1-8 characters - translated = readString(data, data.available(), UTF_8); - // TODO: check for line breaks? - } - - String text; - if (compressed) { - text = new String(readCompressed(data, data.available(), readMethod), enc); - } else { - text = new String(bytes, bytes.length - data.available(), data.available(), enc); - } - if (text.indexOf('\0') >= 0) - throw new PngException("Text value contains null", false); - List chunks = (List)png.getProperty(PngConstants.TEXT_CHUNKS, List.class, false); - if (chunks == null) - props.put(PngConstants.TEXT_CHUNKS, chunks = new ArrayList()); - chunks.add(new TextChunkImpl(keyword, text, language, translated, type)); - } - - private static void read_gIFg(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.gIFg, length, 4); - int disposalMethod = in.readUnsignedByte(); - int userInputFlag = in.readUnsignedByte(); - int delayTime = in.readUnsignedShort(); - props.put(PngConstants.GIF_DISPOSAL_METHOD, Integers.valueOf(disposalMethod)); - props.put(PngConstants.GIF_USER_INPUT_FLAG, Integers.valueOf(userInputFlag)); - props.put(PngConstants.GIF_DELAY_TIME, Integers.valueOf(delayTime)); - } - - private static void read_oFFs(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.oFFs, length, 9); - int x = in.readInt(); - int y = in.readInt(); - int unit = in.readByte(); - if (unit != PngConstants.POSITION_UNIT_PIXEL && - unit != PngConstants.POSITION_UNIT_MICROMETER) - throw new PngException("Illegal oFFs chunk unit specifier: " + unit, false); - props.put(PngConstants.POSITION_X, Integers.valueOf(x)); - props.put(PngConstants.POSITION_Y, Integers.valueOf(y)); - props.put(PngConstants.POSITION_UNIT, Integers.valueOf(unit)); - } - - private static void read_sCAL(DataInput in, int length, Map props) - throws IOException - { - byte[] bytes = new byte[length]; - in.readFully(bytes); - DataInputStream data = new DataInputStream(new ByteArrayInputStream(bytes)); - - int unit = data.readByte(); - if (unit != PngConstants.SCALE_UNIT_METER && unit != PngConstants.SCALE_UNIT_RADIAN) - throw new PngException("Illegal sCAL chunk unit specifier: " + unit, false); - double width = readFloatingPoint(data, data.available()); - double height = readFloatingPoint(data, data.available()); - if (width <= 0 || height <= 0) - throw new PngException("sCAL measurements must be >= 0", false); - props.put(PngConstants.SCALE_UNIT, Integers.valueOf(unit)); - props.put(PngConstants.PIXEL_WIDTH, new Double(width)); - props.put(PngConstants.PIXEL_HEIGHT, new Double(height)); - } - - private static void read_sTER(DataInput in, int length, Map props) - throws IOException - { - checkLength(PngConstants.sTER, length, 1); - int mode = in.readByte(); - switch (mode) { - case PngConstants.STEREO_MODE_CROSS: - case PngConstants.STEREO_MODE_DIVERGING: - props.put(PngConstants.STEREO_MODE, Integers.valueOf(mode)); - break; - default: - throw new PngException("Unknown sTER mode: " + mode, false); - } - } - - public static void checkLength(int chunk, int length, int correct) - throws PngException - { - if (length != correct) - throw new PngException("Bad " + PngConstants.getChunkName(chunk) + " chunk length: " + length + " (expected " + correct + ")", true); - } - - private static byte[] readCompressed(DataInput in, int length, boolean readMethod) - throws IOException - { - if (readMethod) { - int method = in.readByte(); - if (method != 0) - throw new PngException("Unrecognized compression method: " + method, false); - length--; - } - byte[] data = new byte[length]; - in.readFully(data); - byte[] tmp = new byte[0x1000]; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Inflater inf = new Inflater(); - inf.reset(); - inf.setInput(data, 0, length); - try { - while (!inf.needsInput()) { - out.write(tmp, 0, inf.inflate(tmp)); - } - } catch (DataFormatException e) { - throw new PngException("Error reading compressed data", e, false); - } - return out.toByteArray(); - } - - private static String readString(DataInput in, int limit, String enc) - throws IOException - { - return new String(readToNull(in, limit), enc); - } - - private static String readKeyword(DataInput in, int limit) - throws IOException - { - String keyword = readString(in, limit, ISO_8859_1); - if (keyword.length() == 0 || keyword.length() > 79) - throw new PngException("Invalid keyword length: " + keyword.length(), false); - return keyword; - } - - // TODO: performance - private static byte[] readToNull(DataInput in, int limit) - throws IOException - { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - for (int i = 0; i < limit; i++) { - int c = in.readUnsignedByte(); - if (c == 0) - return out.toByteArray(); - out.write(c); - } - return out.toByteArray(); - } - - private static double readFloatingPoint(DataInput in, int limit) - throws IOException - { - String s = readString(in, limit, "US-ASCII"); - int e = Math.max(s.indexOf('e'), s.indexOf('E')); - double d = Double.valueOf(s.substring(0, (e < 0 ? s.length() : e))).doubleValue(); - if (e >= 0) - d *= Math.pow(10d, Double.valueOf(s.substring(e + 1)).doubleValue()); - return d; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/SourceRegionDestination.java b/javapng2/src/main/com/sixlegs/png/SourceRegionDestination.java deleted file mode 100644 index a46c9b6..0000000 --- a/javapng2/src/main/com/sixlegs/png/SourceRegionDestination.java +++ /dev/null @@ -1,98 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.image.WritableRaster; -import java.awt.Rectangle; - -final class SourceRegionDestination -extends Destination -{ - private final Destination dst; - private final int xoff, yoff, xlen, ylen, samples; - - public SourceRegionDestination(Destination dst, Rectangle sourceRegion) - { - this.dst = dst; - xoff = sourceRegion.x; - yoff = sourceRegion.y; - xlen = sourceRegion.width; - ylen = sourceRegion.height; - samples = dst.getRaster().getNumBands(); - } - - public void setPixels(int x, int y, int w, int[] pixels) - { - if (y >= yoff && y < yoff + ylen) { - int newx = Math.max(x, xoff); - int neww = Math.min(x + w, xoff + xlen) - newx; - if (neww > 0) { - if (newx > x) - System.arraycopy(pixels, newx * samples, pixels, 0, neww * samples); - dst.setPixels(newx - xoff, y - yoff, neww, pixels); - } - } - } - - public void setPixel(int x, int y, int[] pixel) - { - x -= xoff; - y -= yoff; - if (x >= 0 && y >= 0 && x < xlen && y < ylen) - dst.setPixel(x, y, pixel); - } - - public void getPixel(int x, int y, int[] pixel) - { - throw new UnsupportedOperationException(); - } - - public WritableRaster getRaster() - { - return dst.getRaster(); - } - - public int getSourceWidth() - { - return dst.getSourceWidth(); - } - - public void done() - { - dst.done(); - } -} diff --git a/javapng2/src/main/com/sixlegs/png/StateMachine.java b/javapng2/src/main/com/sixlegs/png/StateMachine.java deleted file mode 100644 index 2b2d82a..0000000 --- a/javapng2/src/main/com/sixlegs/png/StateMachine.java +++ /dev/null @@ -1,155 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -class StateMachine -{ - public static final int STATE_START = 0; - public static final int STATE_SAW_IHDR = 1; - public static final int STATE_SAW_IHDR_NO_PLTE = 2; - public static final int STATE_SAW_PLTE = 3; - public static final int STATE_IN_IDAT = 4; - public static final int STATE_AFTER_IDAT = 5; - public static final int STATE_END = 6; - - private PngImage png; - private int state = STATE_START; - private int type; - - public StateMachine(PngImage png) - { - this.png = png; - } - - public int getState() - { - return state; - } - - public int getType() - { - return type; - } - - public void nextState(int type) - throws PngException - { - state = nextState(png, state, this.type = type); - } - - private static int nextState(PngImage png, int state, int type) - throws PngException - { - for (int i = 0; i < 4; i++) { - int c = 0xFF & (type >>> (8 * i)); - if (c < 65 || (c > 90 && c < 97) || c > 122) - throw new PngException("Corrupted chunk type: 0x" + Integer.toHexString(type), true); - } - if (PngConstants.isPrivate(type) && !PngConstants.isAncillary(type)) - throw new PngException("Private critical chunk encountered: " + PngConstants.getChunkName(type), true); - switch (state) { - case STATE_START: - if (type == PngConstants.IHDR) - return STATE_SAW_IHDR; - throw new PngException("IHDR chunk must be first chunk", true); - case STATE_SAW_IHDR: - case STATE_SAW_IHDR_NO_PLTE: - switch (type) { - case PngConstants.PLTE: - return STATE_SAW_PLTE; - case PngConstants.IDAT: - errorIfPaletted(png); - return STATE_IN_IDAT; - case PngConstants.bKGD: - return STATE_SAW_IHDR_NO_PLTE; - case PngConstants.tRNS: - errorIfPaletted(png); - return STATE_SAW_IHDR_NO_PLTE; - case PngConstants.hIST: - throw new PngException("PLTE must precede hIST", true); - } - return state; - case STATE_SAW_PLTE: - switch (type) { - case PngConstants.cHRM: - case PngConstants.gAMA: - case PngConstants.iCCP: - case PngConstants.sBIT: - case PngConstants.sRGB: - throw new PngException(PngConstants.getChunkName(type) + " cannot appear after PLTE", true); - case PngConstants.IDAT: - return STATE_IN_IDAT; - case PngConstants.IEND: - throw new PngException("Required data chunk(s) not found", true); - } - return STATE_SAW_PLTE; - default: // STATE_IN_IDAT, STATE_AFTER_IDAT - switch (type) { - case PngConstants.PLTE: - case PngConstants.cHRM: - case PngConstants.gAMA: - case PngConstants.iCCP: - case PngConstants.sBIT: - case PngConstants.sRGB: - case PngConstants.bKGD: - case PngConstants.hIST: - case PngConstants.tRNS: - case PngConstants.pHYs: - case PngConstants.sPLT: - case PngConstants.oFFs: - case PngConstants.pCAL: - case PngConstants.sCAL: - case PngConstants.sTER: - throw new PngException(PngConstants.getChunkName(type) + " cannot appear after IDAT", true); - case PngConstants.IEND: - return STATE_END; - case PngConstants.IDAT: - if (state == STATE_IN_IDAT) - return STATE_IN_IDAT; - throw new PngException("IDAT chunks must be consecutive", true); - } - return STATE_AFTER_IDAT; - } - } - - private static void errorIfPaletted(PngImage png) - throws PngException - { - if (png.getColorType() == PngConstants.COLOR_TYPE_PALETTE) - throw new PngException("Required PLTE chunk not found", true); - } -} diff --git a/javapng2/src/main/com/sixlegs/png/SubsamplingDestination.java b/javapng2/src/main/com/sixlegs/png/SubsamplingDestination.java deleted file mode 100644 index 26ae59a..0000000 --- a/javapng2/src/main/com/sixlegs/png/SubsamplingDestination.java +++ /dev/null @@ -1,91 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -import java.awt.image.WritableRaster; - -final class SubsamplingDestination -extends RasterDestination -{ - private final int xsub; - private final int ysub; - private final int xoff; - private final int yoff; - private final int[] singlePixel; - - public SubsamplingDestination(WritableRaster raster, int sourceWidth, - int xsub, int ysub, int xoff, int yoff) - { - super(raster, sourceWidth); - this.xsub = xsub; - this.ysub = ysub; - this.xoff = xoff; - this.yoff = yoff; - singlePixel = new int[raster.getNumBands()]; - } - - public void setPixels(int x, int y, int w, int[] pixels) - { - if (((y - yoff) % ysub) == 0) { - int xdst = (x - xoff) / xsub; - int ydst = (y - yoff) / ysub; - int startSrc = xdst * xsub + xoff; - if (startSrc < x) { - xdst++; - startSrc += xsub; - } - int samples = raster.getNumBands(); - for (int i = startSrc - x, end = x + w; i < end; i += xsub) { - System.arraycopy(pixels, i * samples, singlePixel, 0, samples); - super.setPixel(xdst++, ydst, singlePixel); - } - } - } - - public void setPixel(int x, int y, int[] pixel) - { - x -= xoff; - y -= yoff; - if (x % xsub == 0 && y % ysub == 0) - super.setPixel(x / xsub, y / ysub, pixel); - } - - public void getPixel(int x, int y, int[] pixel) - { - throw new UnsupportedOperationException(); - } -} diff --git a/javapng2/src/main/com/sixlegs/png/SuggestedPalette.java b/javapng2/src/main/com/sixlegs/png/SuggestedPalette.java deleted file mode 100644 index 39521aa..0000000 --- a/javapng2/src/main/com/sixlegs/png/SuggestedPalette.java +++ /dev/null @@ -1,88 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -/** - * A suggested palette. Suggested palettes can be useful - * when the display device is not capable of displaying - * the full range of colors present in the image. - * @see PngImage#getProperty - * @see PngConstants#SUGGESTED_PALETTES - */ -public interface SuggestedPalette -{ - /** - * Returns palette name. This is any convenient name for - * referring to the palette. The name will be unique across all - * suggested palettes in the same image. - */ - String getName(); - - /** - * Returns the number of samples. - */ - int getSampleCount(); - - /** - * Returns the sample depth. This specifies the width of each color and alpha component - * of each sample in this palette. - * @return 8 or 16 - */ - int getSampleDepth(); - - /** - * Retrieve a sample value. The red, green, blue, and alpha components of the sample - * at the given index are stored into the short array. Each component is of the depth - * specified by {@link #getSampleDepth getSampleDepth}. The color samples are not - * premultiplied by alpha. An alpha value of 0 means fully transparent. - * @throws IndexOutOfBoundsException if index < 0, index >= {@link #getSampleCount getSampleCount}, or - * {@code pixel.length} is less than 4 - * @throws NullPointerException if {@code pixel} is null - * @param index the sample index - * @param pixel the array in which to store the sample components - */ - void getSample(int index, short[] pixel); - - /** - * Retrieve a sample frequency value. The frequency value is proportional to the - * fraction of pixels in the image that are closest to that palette entry in RGBA - * space. The range of individual values will reasonably fill 0 to 65535. - * Entries appear in decreasing order of frequency. - * @param index the sample index - */ - int getFrequency(int index); -} diff --git a/javapng2/src/main/com/sixlegs/png/SuggestedPaletteImpl.java b/javapng2/src/main/com/sixlegs/png/SuggestedPaletteImpl.java deleted file mode 100644 index 4abfb80..0000000 --- a/javapng2/src/main/com/sixlegs/png/SuggestedPaletteImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -class SuggestedPaletteImpl -implements SuggestedPalette -{ - private final String name; - private final int sampleDepth; - private final byte[] bytes; - private final int entrySize; - private final int sampleCount; - - public SuggestedPaletteImpl(String name, int sampleDepth, byte[] bytes) - { - this.name = name; - this.sampleDepth = sampleDepth; - this.bytes = bytes; - entrySize = (sampleDepth == 8) ? 6 : 10; - sampleCount = bytes.length / entrySize; - } - - public String getName() - { - return name; - } - - public int getSampleCount() - { - return sampleCount; - } - - public int getSampleDepth() - { - return sampleDepth; - } - - public void getSample(int index, short[] pixel) - { - int from = index * entrySize; - if (sampleDepth == 8) { - for (int j = 0; j < 4; j++) { - int a = 0xFF & bytes[from++]; - pixel[j] = (short)a; - } - } else { - for (int j = 0; j < 4; j++) { - int a = 0xFF & bytes[from++]; - int b = 0xFF & bytes[from++]; - pixel[j] = (short)((a << 8) | b); - } - } - } - - public int getFrequency(int index) - { - int from = (index + 1) * entrySize - 2; - int a = 0xFF & bytes[from]; - int b = 0xFF & bytes[from + 1]; - return ((a << 8) | b); - } -} diff --git a/javapng2/src/main/com/sixlegs/png/TextChunk.java b/javapng2/src/main/com/sixlegs/png/TextChunk.java deleted file mode 100644 index 3accef3..0000000 --- a/javapng2/src/main/com/sixlegs/png/TextChunk.java +++ /dev/null @@ -1,77 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -/** - * Common interface to all PNG text chunk data ({@link PngConstants#tEXt tEXt}, - * {@link PngConstants#zTXt zTXt}, {@link PngConstants#iTXt iTXt}). - * @see PngImage#getTextChunk - */ -public interface TextChunk -{ - /** - * Returns the Latin-1 (ISO-8859-1) encoded keyword - * of this TextChunk. - */ - String getKeyword(); - - /** - * Returns a translation of the keyword into the language - * used by this TextChunk, or null if unspecified. - */ - String getTranslatedKeyword(); - - /** - * Returns the language (RFC-1766) used by the translated - * keyword and the text, or null if unspecified. - */ - String getLanguage(); - - /** - * Returns the text of this TextChunk. - */ - String getText(); - - /** - * Returns the type of this TextChunk. - * @return - * {@link PngConstants#tEXt},
- * {@link PngConstants#zTXt},
- * or {@link PngConstants#iTXt} - */ - int getType(); -} diff --git a/javapng2/src/main/com/sixlegs/png/TextChunkImpl.java b/javapng2/src/main/com/sixlegs/png/TextChunkImpl.java deleted file mode 100644 index e08ab7a..0000000 --- a/javapng2/src/main/com/sixlegs/png/TextChunkImpl.java +++ /dev/null @@ -1,81 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -class TextChunkImpl -implements TextChunk -{ - private final String keyword; - private final String text; - private final String language; - private final String translated; - private final int type; - - public TextChunkImpl(String keyword, String text, String language, String translated, int type) - { - this.keyword = keyword; - this.text = text; - this.language = language; - this.translated = translated; - this.type = type; - } - - public String getKeyword() - { - return keyword; - } - - public String getTranslatedKeyword() - { - return translated; - } - - public String getLanguage() - { - return language; - } - - public String getText() - { - return text; - } - - public int getType() - { - return type; - } -} diff --git a/javapng2/src/main/com/sixlegs/png/TransGammaPixelProcessor.java b/javapng2/src/main/com/sixlegs/png/TransGammaPixelProcessor.java deleted file mode 100644 index c0e7fa0..0000000 --- a/javapng2/src/main/com/sixlegs/png/TransGammaPixelProcessor.java +++ /dev/null @@ -1,74 +0,0 @@ -/* -com.sixlegs.png - Java package to read and display PNG images -Copyright (C) 1998-2006 Chris Nokleberg - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package com.sixlegs.png; - -final class TransGammaPixelProcessor -extends BasicPixelProcessor -{ - final private short[] gammaTable; - final private int[] trans; - final private int shift; - final private int max; - final private int samplesNoAlpha; - final private int[] temp; - - public TransGammaPixelProcessor(Destination dst, short[] gammaTable, int[] trans, int shift) - { - super(dst, dst.getRaster().getNumBands()); - this.gammaTable = gammaTable; - this.trans = trans; - this.shift = shift; - max = gammaTable.length - 1; - samplesNoAlpha = samples - 1; - temp = new int[samples * dst.getSourceWidth()]; - } - - public boolean process(int[] row, int xOffset, int xStep, int yStep, int y, int width) - { - int total = width * samplesNoAlpha; - for (int i1 = 0, i2 = 0; i1 < total; i1 += samplesNoAlpha, i2 += samples) { - boolean opaque = false; - for (int j = 0; j < samplesNoAlpha; j++) { - int sample = row[i1 + j]; - opaque = opaque || (sample != trans[j]); - temp[i2 + j] = 0xFFFF & gammaTable[sample >> shift]; - } - temp[i2 + samplesNoAlpha] = opaque ? max : 0; - } - return super.process(temp, xOffset, xStep, yStep, y, width); - } -} diff --git a/javapng2/src/test/BrokenGenerator.java b/javapng2/src/test/BrokenGenerator.java deleted file mode 100644 index 05ad3a4..0000000 --- a/javapng2/src/test/BrokenGenerator.java +++ /dev/null @@ -1,685 +0,0 @@ -import java.io.*; -import java.util.*; -import java.util.zip.*; -import org.apache.tools.bzip2.CBZip2OutputStream; - -public class BrokenGenerator -{ - private static final int IHDR = 0x49484452; - private static final int PLTE = 0x504c5445; - private static final int IDAT = 0x49444154; - private static final int IEND = 0x49454e44; - private static final int bKGD = 0x624b4744; - private static final int cHRM = 0x6348524d; - private static final int gAMA = 0x67414d41; - private static final int hIST = 0x68495354; - private static final int iCCP = 0x69434350; - private static final int iTXt = 0x69545874; - private static final int pHYs = 0x70485973; - private static final int sBIT = 0x73424954; - private static final int sPLT = 0x73504c54; - private static final int sRGB = 0x73524742; - private static final int tEXt = 0x74455874; - private static final int tIME = 0x74494d45; - private static final int tRNS = 0x74524e53; - private static final int zTXt = 0x7a545874; - private static final int oFFs = 0x6f464673; - private static final int pCAL = 0x7043414c; - private static final int sCAL = 0x7343414c; - private static final int gIFg = 0x67494667; - private static final int gIFx = 0x67494678; - private static final int sTER = 0x73544552; - - // private types - private static final int heRB = 0x68655242; - - // bad types - private static final int GaMA = 0x47614d41; - private static final int gAM_ = 0x67614d5f; - - public static void main(String[] args) - throws Exception - { - gen("suite/basn3p08.png", "broken/missing_ihdr.png", swap(IHDR, gAMA)); - gen("suite/basn3p08.png", "broken/missing_idat.png", remove(find(IDAT))); - gen("suite/basn3p08.png", "broken/missing_plte.png", remove(find(PLTE))); - gen("suite/tbbn3p08.png", "broken/missing_plte_2.png", remove(find(PLTE))); - - gen("suite/basn3p08.png", "broken/chunk_private_critical.png", setType(find(gAMA), GaMA)); - gen("suite/basn3p08.png", "broken/chunk_type.png", setType(find(gAMA), gAM_)); - gen("suite/basn3p08.png", "broken/chunk_crc.png", setCRC(find(IHDR), 0x12345678)); - gen("suite/basn3p08.png", "broken/chunk_length.png", setLength(find(gAMA), -20, false)); - - gen("suite/basn3p08.png", "broken/nonconsecutive_idat.png", - addAfter(find(IDAT), new Chunk(heRB, new byte[0])), - addAfter(find(heRB), find(IDAT))); - - gen("suite/basn3p08.png", "broken/multiple_gama.png", duplicate(gAMA)); - gen("suite/basn3p08.png", "broken/multiple_plte.png", duplicate(PLTE)); - gen("suite/basn3p08.png", "broken/multiple_ihdr.png", duplicate(IHDR)); - gen("suite/ccwn2c08.png", "broken/multiple_chrm.png", duplicate(cHRM)); - gen("suite/cs5n2c08.png", "broken/multiple_sbit.png", duplicate(sBIT)); - gen("suite/bggn4a16.png", "broken/multiple_bkgd.png", duplicate(bKGD)); - gen("suite/ch1n3p04.png", "broken/multiple_hist.png", duplicate(hIST)); - gen("suite/tbbn1g04.png", "broken/multiple_trns.png", duplicate(tRNS)); - gen("suite/cdun2c08.png", "broken/multiple_phys.png", duplicate(pHYs)); - gen("suite/cm0n0g04.png", "broken/multiple_time.png", duplicate(tIME)); - gen("misc/iccp-cc99ff.png", "broken/multiple_iccp.png", duplicate(iCCP)); - gen("misc/srgb-cc99ff.png", "broken/multiple_srgb.png", duplicate(sRGB)); - gen("misc/pngtest.png", "broken/multiple_offs.png", duplicate(oFFs)); - gen("misc/pngtest.png", "broken/multiple_pcal.png", duplicate(pCAL)); - gen("misc/pngtest.png", "broken/multiple_scal.png", duplicate(sCAL)); - gen("suite/basn3p08.png", "broken/multiple_ster.png", - addAfter(find(IHDR), new Chunk(sTER, new byte[]{ 0 })), duplicate(sTER)); - - gen("suite/ch1n3p04.png", "broken/hist_before_plte.png", swap(hIST, PLTE)); - gen("suite/ccwn3p08.png", "broken/chrm_after_plte.png", swap(cHRM, PLTE)); - gen("suite/basn3p02.png", "broken/sbit_after_plte.png", swap(sBIT, PLTE)); - gen("suite/basn3p08.png", "broken/gama_after_plte.png", swap(gAMA, PLTE)); - gen("misc/srgb-cc99ff.png", "broken/srgb_after_plte.png", swap(sRGB, PLTE)); - gen("misc/iccp-cc99ff.png", "broken/iccp_after_plte.png", swap(iCCP, PLTE)); - - gen("suite/basn3p08.png", "broken/plte_after_idat.png", swap(PLTE, IDAT)); - gen("suite/basn0g01.png", "broken/gama_after_idat.png", swap(gAMA, IDAT)); - gen("suite/basn3p08.png", "broken/ster_after_idat.png", - addAfter(find(IDAT), new Chunk(sTER, new byte[]{ 0 }))); - gen("suite/ccwn2c08.png", "broken/chrm_after_idat.png", swap(cHRM, IDAT)); - gen("suite/cs5n2c08.png", "broken/sbit_after_idat.png", swap(sBIT, IDAT)); - gen("suite/bggn4a16.png", "broken/bkgd_after_idat.png", swap(bKGD, IDAT)); - gen("suite/ch1n3p04.png", "broken/hist_after_idat.png", swap(hIST, IDAT)); - gen("suite/tbbn1g04.png", "broken/trns_after_idat.png", swap(tRNS, bKGD), swap(tRNS, IDAT)); - gen("suite/cdun2c08.png", "broken/phys_after_idat.png", swap(pHYs, IDAT)); - gen("misc/ps2n2c16.png", "broken/splt_after_idat.png", swap(sPLT, IDAT)); - - gen("misc/pngtest.png", "broken/offs_after_idat.png", swap(oFFs, zTXt)); - gen("misc/pngtest.png", "broken/pcal_after_idat.png", swap(pCAL, zTXt)); - gen("misc/pngtest.png", "broken/scal_after_idat.png", swap(sCAL, zTXt)); - - gen("suite/basn0g01.png", "broken/length_sbit_2.png", - addAfter(find(IHDR), extract("suite/basn3p02.png", sBIT))); - gen("suite/basn2c08.png", "broken/iccp_after_idat.png", - remove(find(gAMA)), addAfter(find(IDAT), extract("misc/ntsciccp.png", iCCP))); - gen("suite/basn2c08.png", "broken/srgb_after_idat.png", - remove(find(gAMA)), addAfter(find(IDAT), extract("misc/srgbsrgb.png", sRGB))); - - gen("suite/basn3p08.png", "broken/ihdr_image_size.png", - replaceHeader(-32, -32, 8, 3, 0, 0, 0)); - gen("suite/basn3p08.png", "broken/ihdr_bit_depth.png", - replaceHeader(32, 32, 7, 3, 0, 0, 0)); - gen("suite/basn3p08.png", "broken/ihdr_color_type.png", - replaceHeader(32, 32, 8, 1, 0, 0, 0)); - gen("suite/basn3p08.png", "broken/ihdr_16bit_palette.png", - replaceHeader(32, 32, 16, 3, 0, 0, 0)); - gen("suite/basn6a08.png", "broken/ihdr_1bit_alpha.png", - replaceHeader(32, 32, 1, 6, 0, 0, 0)); - gen("suite/basn3p08.png", "broken/ihdr_compression_method.png", - replaceHeader(32, 32, 8, 3, 1, 0, 0)); - gen("suite/basn3p08.png", "broken/ihdr_filter_method.png", - replaceHeader(32, 32, 8, 3, 0, 1, 0)); - gen("suite/basn3p08.png", "broken/ihdr_interlace_method.png", - replaceHeader(32, 32, 8, 3, 0, 0, 2)); - - gen("suite/basn3p08.png", "broken/private_compression_method.png", - replaceHeader(32, 32, 8, 3, 128, 0, 0), BZIP2); - gen("suite/basn3p08.png", "broken/private_filter_method.png", - replaceHeader(32, 32, 8, 3, 0, 128, 0)); - gen("suite/basn3p08.png", "broken/private_interlace_method.png", - replaceHeader(32, 32, 8, 3, 0, 0, 128)); - gen("suite/basn0g01.png", "broken/private_filter_type.png", changeDataByte(0, 128)); - - gen("suite/basn3p08.png", "broken/plte_length_mod_three.png", - replace(find(PLTE), new Chunk(PLTE, new byte[2]))); - gen("suite/basn3p08.png", "broken/plte_empty.png", - replace(find(PLTE), new Chunk(PLTE, new byte[0]))); - gen("suite/basn3p04.png", "broken/plte_too_many_entries.png", - replace(find(PLTE), new Chunk(PLTE, new byte[17 * 3]))); - gen("suite/basn2c08.png", "broken/plte_too_many_entries_2.png", - addAfter(find(gAMA), new Chunk(PLTE, new byte[257 * 3]))); - gen("suite/basn0g08.png", "broken/plte_in_grayscale.png", - addAfter(find(gAMA), new Chunk(PLTE, new byte[3]))); - - Chunk trns = extract("suite/tbbn1g04.png", tRNS); - gen("suite/basn6a08.png", "broken/trns_bad_color_type.png", - addAfter(find(gAMA), trns)); - gen("suite/tp1n3p08.png", "broken/trns_too_many_entries.png", - replace(find(tRNS), new Chunk(tRNS, new byte[200]))); - - gen("suite/f01n2c08.png", "broken/gama_zero.png", - addAfter(find(IHDR), new Chunk(gAMA, new byte[4]))); - - // example of scal chunk without exponent - gen("misc/pngtest.png", "misc/scal_no_exp.png", - changeByte(find(sCAL), 15, (byte)'0'), - changeByte(find(sCAL), 16, (byte)'0')); - - gen("suite/basn3p08.png", "misc/herbio.png", addAfter(find(IHDR), createPrivateChunk())); - - gen("suite/f01n2c08.png", "misc/itxt_valid.png", - addAfter(find(IHDR), createIntlText("Vegetable", 0, 0, "en-us", "", "Cucumber"))); - gen("suite/f01n2c08.png", "misc/itxt_compress.png", - addAfter(find(IHDR), createIntlText("Author", 1, 0, "sv-sw", "f\u00f6rfattare", "Christopher J. N\u00f6kleberg"))); - gen("suite/f01n2c08.png", "broken/itxt_compression_flag.png", - addAfter(find(IHDR), createIntlText("Vegetable", 2, 0, "en-us", "", "Cucumber"))); - gen("suite/f01n2c08.png", "broken/itxt_compression_method.png", - addAfter(find(IHDR), createIntlText("Vegetable", 1, 1, "en-us", "", "Cucumber"))); - gen("suite/f01n2c08.png", "broken/itxt_keyword_length.png", - addAfter(find(IHDR), createIntlText("", 0, 0, "en-us", "", "Cucumber"))); - gen("suite/f01n2c08.png", "broken/itxt_keyword_length_2.png", - addAfter(find(IHDR), createIntlText("01234567890123456789012345678901234567890123456789012345678901234567890123456789", 0, 0, "en-us", "", "Cucumber"))); - gen("misc/pngtest.png", "broken/scal_floating_point.png", changeByte(find(sCAL), 1, (byte)'Q')); - gen("misc/pngtest.png", "broken/scal_unit_specifier.png", changeByte(find(sCAL), 0, 3)); - gen("suite/basn3p08.png", "broken/scal_zero.png", - addAfter(find(IHDR), new Chunk(sCAL, new byte[]{ 1, '0', 0, '0'}))); - gen("suite/basn3p08.png", "broken/scal_negative.png", - addAfter(find(IHDR), new Chunk(sCAL, new byte[]{ 1, '1', 0, '-', '1'}))); - - gen("suite/cdun2c08.png", "broken/phys_unit_specifier.png", changeByte(find(pHYs), 8, 2)); - gen("misc/pngtest.png", "broken/offs_unit_specifier.png", changeByte(find(oFFs), 8, 2)); - gen("suite/cs5n2c08.png", "broken/sbit_sample_depth.png", changeByte(find(sBIT), 0, -1)); - gen("suite/cs5n2c08.png", "broken/sbit_sample_depth_2.png", changeByte(find(sBIT), 0, 9)); - gen("suite/basn3p08.png", "broken/ster_mode.png", - addAfter(find(IHDR), new Chunk(sTER, new byte[]{ 2 }))); - - gen("suite/basn3p08.png", "broken/splt_sample_depth.png", - addAfter(find(IHDR), createSuggestedPalette("Bad suggestion", 4, new byte[0]))); - gen("suite/basn3p08.png", "broken/splt_length_mod_6.png", - addAfter(find(IHDR), createSuggestedPalette("Bad suggestion", 8, new byte[10]))); - gen("suite/basn3p08.png", "broken/splt_length_mod_10.png", - addAfter(find(IHDR), createSuggestedPalette("Bad suggestion", 16, new byte[6]))); - Chunk suggested = createSuggestedPalette("Lemonade", 8, new byte[0]); - gen("suite/basn3p08.png", "broken/splt_duplicate_name.png", - addAfter(find(IHDR), suggested), - addAfter(find(IHDR), suggested)); - - gen("suite/cm0n0g04.png", "broken/time_value_range.png", changeByte(find(tIME), 2, 0)); - gen("suite/basn3p08.png", "broken/length_ihdr.png", setLength(find(IHDR), 14)); - gen("suite/basn3p08.png", "broken/length_iend.png", setLength(find(IEND), 1)); - gen("suite/basn3p08.png", "broken/length_ster.png", - addAfter(find(IHDR), new Chunk(sTER, new byte[]{ 0, 0 }))); - gen("misc/srgb-cc99ff.png", "broken/length_srgb.png", setLength(find(sRGB), 2)); - gen("suite/basn3p08.png", "broken/length_gama.png", setLength(find(gAMA), 3)); - gen("suite/cdun2c08.png", "broken/length_phys.png", setLength(find(pHYs), 8)); - gen("suite/cm0n0g04.png", "broken/length_time.png", setLength(find(tIME), 6)); - gen("misc/pngtest.png", "broken/length_offs.png", setLength(find(oFFs), 8)); - gen("suite/ccwn2c08.png", "broken/length_chrm.png", setLength(find(cHRM), 31)); - gen("suite/ch1n3p04.png", "broken/length_hist.png", setLength(find(hIST), 28)); - gen("suite/basn3p02.png", "broken/length_sbit.png", setLength(find(sBIT), 4)); - gen("suite/tbbn1g04.png", "broken/length_trns_gray.png", setLength(find(tRNS), 0)); - gen("suite/tbrn2c08.png", "broken/length_trns_rgb.png", setLength(find(tRNS), 0)); - gen("suite/tbbn3p08.png", "broken/length_trns_palette.png", setLength(find(tRNS), 174)); - gen("misc/anigif.png", "broken/length_gifg.png", setLength(find(gIFg), 5)); - - gen("suite/bgbn4a08.png", "broken/length_bkgd_gray.png", setLength(find(bKGD), 6)); - gen("suite/bgwn6a08.png", "broken/length_bkgd_rgb.png", setLength(find(bKGD), 2)); - gen("suite/tbbn3p08.png", "broken/length_bkgd_palette.png", setLength(find(bKGD), 6)); - - gen("suite/ctzn0g04.png", "broken/ztxt_compression_method.png", changeByte(find(zTXt), 10, 3)); - gen("suite/ctzn0g04.png", "broken/ztxt_data_format.png", changeByte(find(zTXt), 11, 3)); - gen("suite/ct1n0g04.png", "broken/text_trailing_null.png", append(find(tEXt), new byte[1])); - - gen("suite/basn3p08.png", "broken/truncate_zlib.png", truncate(find(IDAT), 20)); - gen("misc/pngtest.png", "broken/truncate_zlib_2.png", truncate(find(IDAT), 6000)); - gen("suite/basn0g01.png", "broken/truncate_idat_0.png", setDataLength(0)); - gen("suite/basn0g01.png", "broken/truncate_idat_1.png", setDataLength(1)); - - gen("suite/basn0g01.png", "broken/unknown_filter_type.png", changeDataByte(0, 5)); - } - - private static void gen(String src, String dst, Processor... processors) - throws IOException - { - List chunks = readChunks(new File(src)); - for (Processor p : processors) - p.process(chunks); - writeChunks(new File(dst), chunks); - } - - private static Processor append(final Query q, final byte[] append) - { - return new Processor(){ - public void process(List chunks) throws IOException { - Chunk chunk = q.query(chunks); - byte[] data = new byte[chunk.length + append.length]; - System.arraycopy(chunk.data, 0, data, 0, chunk.length); - System.arraycopy(append, 0, data, chunk.length, append.length); - chunk.data = data; - chunk.length = data.length; - chunk.crc = crc(chunk.type, chunk.data); - } - }; - } - - private static Processor setDataLength(final int length) - { - return new DataProcessor(){ - public byte[] process(byte[] data) { - byte[] replace = new byte[length]; - System.arraycopy(data, 0, replace, 0, length); - return replace; - } - }; - } - - private static final Processor BZIP2 = new DataProcessor(){ - @Override protected byte[] compress(byte[] data) throws IOException { - ByteArrayInputStream in = new ByteArrayInputStream(data); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - OutputStream out = new CBZip2OutputStream(baos); - pipe(in, out, new byte[0x2000]); - out.close(); - return baos.toByteArray(); - } - public byte[] process(byte[] data) { - return data; - } - }; - - private static Processor changeDataByte(final int offset, final int value) - { - return new DataProcessor(){ - public byte[] process(byte[] data) { - data[offset] = (byte)value; - return data; - } - }; - } - - private static Processor changeByte(final Query q, final int offset, final int value) - { - return new Processor(){ - public void process(List chunks) throws IOException { - Chunk chunk = q.query(chunks); - chunk.data[offset] = (byte)value; - chunk.crc = crc(chunk.type, chunk.data); - } - }; - } - - private static Processor replaceHeader(int width, int height, int bitDepth, int colorType, - int compression, int filter, int interlace) - throws IOException - { - return replace(find(IHDR), - createHeader(width, height, bitDepth, colorType, - compression, filter, interlace)); - } - - private static Chunk extract(String src, int type) - throws IOException - { - return find(type).query(readChunks(new File(src))); - } - - private static Processor swap(int t1, int t2) - { - return swap(find(t1), find(t2)); - } - - private static Processor duplicate(int type) - { - return addAfter(find(type), find(type)); - } - - private static Processor replace(final Query oldChunk, final Query newChunk) - { - return new Processor(){ - public void process(List chunks) { - chunks.set(chunks.indexOf(oldChunk.query(chunks)), newChunk.query(chunks)); - } - }; - } - - private static Processor addAfter(final Query after, final Query chunk) - { - return new Processor(){ - public void process(List chunks) { - chunks.add(chunks.indexOf(after.query(chunks)) + 1, chunk.query(chunks)); - } - }; - } - - private static Processor setLength(Query q, int length) - { - return setLength(q, length, true); - } - - private static Processor setLength(final Query q, final int length, final boolean consistent) - { - return new Processor(){ - public void process(List chunks) throws IOException { - Chunk chunk = q.query(chunks); - chunk.length = length; - if (consistent) { - byte[] data = new byte[length]; - System.arraycopy(chunk.data, 0, data, 0, Math.min(data.length, chunk.data.length)); - chunk.data = data; - chunk.crc = crc(chunk.type, data); - } - } - }; - } - - private static Processor setCRC(final Query q, final int crc) - { - return new Processor(){ - public void process(List chunks) { - q.query(chunks).crc = crc; - } - }; - } - - private static Processor setType(final Query q, final int type) - { - return new Processor(){ - public void process(List chunks) throws IOException { - Chunk chunk = q.query(chunks); - chunk.type = type; - chunk.crc = crc(type, chunk.data); - } - }; - } - - private static Processor remove(final Query q) - { - return new Processor(){ - public void process(List chunks) { - chunks.remove(q.query(chunks)); - } - }; - } - - private static Processor swap(final Query q1, final Query q2) - { - return new Processor(){ - public void process(List chunks) { - Collections.swap(chunks, - chunks.indexOf(q1.query(chunks)), - chunks.indexOf(q2.query(chunks))); - } - }; - } - - private static Processor truncate(final Query q, final int offset) - { - return new Processor(){ - public void process(List chunks) { - Chunk chunk = q.query(chunks); - int index = chunks.indexOf(chunk); - while (chunks.size() > index) - chunks.remove(index); - - byte[] data = new byte[offset]; - System.arraycopy(chunk.data, 0, data, 0, offset); - Chunk replace = new Chunk(chunk.type, data, chunk.crc); - replace.length = chunk.length; - chunks.add(replace); - } - }; - } - - private static Query find(int type) - { - return find(type, 0); - } - - private static Query find(final int type, final int index) - { - return new Query(){ - public Chunk query(List chunks) { - int count = 0; - for (Chunk chunk : chunks) { - if (chunk.type == type && index == count++) - return chunk; - } - return null; - } - }; - } - - abstract private static class DataProcessor - implements Processor - { - public void process(List chunks) - throws IOException - { - List dataList = new ArrayList(); - int length = 0; - int index = chunks.indexOf(find(IDAT).query(chunks)); - for (Iterator it = chunks.iterator(); it.hasNext();) { - Chunk chunk = it.next(); - if (chunk.type == IDAT) { - it.remove(); - dataList.add(chunk.data); - length += chunk.length; - } - } - byte[] concat = new byte[length]; - int pos = 0; - for (byte[] data : dataList) { - System.arraycopy(data, 0, concat, pos, data.length); - pos += data.length; - } - - concat = compress(process(decompress(concat))); - chunks.add(index, new Chunk(IDAT, concat, crc(IDAT, concat))); - } - - protected byte[] decompress(byte[] data) throws IOException { - return inflate(data); - } - - protected byte[] compress(byte[] data) throws IOException { - return deflate(data); - } - - abstract public byte[] process(byte[] data); - } - - private static byte[] inflate(byte[] data) - throws IOException - { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - pipe(new InflaterInputStream(new ByteArrayInputStream(data)), out, new byte[0x2000]); - return out.toByteArray(); - } - - private static byte[] deflate(byte[] data) - throws IOException - { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - DeflaterOutputStream defl = new DeflaterOutputStream(out); - pipe(new ByteArrayInputStream(data), defl, new byte[0x2000]); - defl.close(); - return out.toByteArray(); - } - - private static void pipe(InputStream in, OutputStream out, byte[] buf) - throws IOException - { - for (;;) { - int amt = in.read(buf); - if (amt < 0) - break; - out.write(buf, 0, amt); - } - } - - private interface Query - { - Chunk query(List chunks); - } - - private interface Processor - { - void process(List chunks) throws IOException; - } - - private static class Chunk - implements Query - { - public int type; - public byte[] data; - public int crc; - public int length; - - public Chunk(int type, byte[] data) - throws IOException - { - this(type, data, crc(type, data)); - } - - public Chunk(int type, byte[] data, int crc) - { - this.type = type; - this.data = data; - this.crc = crc; - this.length = data.length; - } - - public Chunk query(List chunks) - { - return this; - } - - public String toString() - { - return "Chunk" + "(type=" + type + - ",len=" + length + ",actual=" + data.length + ",crc=" + crc + ")"; - } - } - - private static int crc(int type, byte[] bytes) - throws IOException - { - CheckedOutputStream checked = new CheckedOutputStream(new NullOutputStream(), new CRC32()); - DataOutputStream data = new DataOutputStream(checked); - data.writeInt(type); - data.write(bytes); - data.flush(); - return (int)checked.getChecksum().getValue(); - } - - private static List readChunks(File src) - throws IOException - { - List chunks = new ArrayList(); - FileInputStream in = new FileInputStream(src); - try { - DataInputStream data = new DataInputStream(new BufferedInputStream(in)); - data.readLong(); // signature - int type; - do { - byte[] bytes = new byte[data.readInt()]; - type = data.readInt(); - data.readFully(bytes); - int crc = data.readInt(); - chunks.add(new Chunk(type, bytes, crc)); - } while (type != IEND); - return chunks; - } finally { - in.close(); - } - } - - private static void writeChunks(File dst, List chunks) - throws IOException - { - FileOutputStream out = new FileOutputStream(dst); - try { - DataOutputStream data = new DataOutputStream(out); - data.writeLong(0x89504E470D0A1A0AL); - for (Chunk chunk : chunks) { - data.writeInt(chunk.length); - data.writeInt(chunk.type); - data.write(chunk.data); - data.writeInt(chunk.crc); - } - data.flush(); - } finally { - out.close(); - } - } - - private static class NullOutputStream extends OutputStream - { - public void write(int b) { } - public void write(byte[] b) { } - public void write(byte[] b, int off, int len) { } - } - - private static Chunk createHeader(int width, int height, int bitDepth, int colorType, - int compression, int filter, int interlace) - throws IOException - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(baos); - data.writeInt(width); - data.writeInt(height); - data.writeByte((byte)bitDepth); - data.writeByte((byte)colorType); - data.writeByte((byte)compression); - data.writeByte((byte)filter); - data.writeByte((byte)interlace); - data.flush(); - return new Chunk(IHDR, baos.toByteArray()); - } - - private static Chunk createIntlText(String keyword, int compressionFlag, int compressionMethod, - String languageTag, String translatedKeyword, String text) - throws IOException - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(baos); - data.write(keyword.getBytes("ISO-8859-1")); - data.writeByte(0); - data.writeByte(compressionFlag); - data.writeByte(compressionMethod); - data.write(languageTag.getBytes("US-ASCII")); - data.writeByte(0); - data.write(translatedKeyword.getBytes("UTF-8")); - data.writeByte(0); - if (compressionFlag == 1) { - DeflaterOutputStream deflater = new DeflaterOutputStream(data); - deflater.write(text.getBytes("UTF-8")); - deflater.finish(); - } else { - data.write(text.getBytes("UTF-8")); - } - data.flush(); - return new Chunk(iTXt, baos.toByteArray()); - } - - private static Chunk createSuggestedPalette(String keyword, int sampleDepth, byte[] bytes) - throws IOException - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(baos); - data.write(keyword.getBytes("ISO-8859-1")); - data.writeByte(0); - data.writeByte((byte)sampleDepth); - data.write(bytes); - data.flush(); - return new Chunk(sPLT, baos.toByteArray()); - } - - private static Chunk createPrivateChunk() - throws IOException - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(baos); - data.writeBoolean(true); - data.writeBoolean(false); - data.writeByte((byte)250); - data.writeByte((byte)250); - data.writeShort((short)50000); - data.writeShort((short)50000); - data.writeChar('Z'); - data.writeFloat((float)Math.PI); - data.writeDouble(Math.PI); - data.writeBytes("Chris\n"); - data.writeUTF("Nokleberg"); - data.writeInt(2000000000); - data.flush(); - return new Chunk(heRB, baos.toByteArray()); - } -} diff --git a/javapng2/src/test/com/sixlegs/png/Benchmark.java b/javapng2/src/test/com/sixlegs/png/Benchmark.java deleted file mode 100644 index 7528840..0000000 --- a/javapng2/src/test/com/sixlegs/png/Benchmark.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.sixlegs.png; - -import java.awt.*; -import java.io.*; -import java.util.*; -import java.util.List; -import javax.imageio.ImageIO; - -public class Benchmark -{ - abstract static class PngReader - { - abstract public void read(File file) throws IOException; - } - - private static PngReader SIXLEGS2 = new PngReader(){ - private PngConfig config = new PngConfig.Builder().build();; - public void read(File file) throws IOException { - new PngImage(config).read(file); - } - }; - - private static PngReader SIXLEGS1 = new PngReader(){ - public void read(File file) throws IOException { - new com.sixlegs.image.png.PngImage(file.toURL()).getEverything(); - } - }; - - private static PngReader IMAGEIO = new PngReader(){ - public void read(File file) throws IOException { - ImageIO.read(file); - } - }; - - private static PngReader TOOLKIT = new PngReader(){ - private MediaTracker tracker = new MediaTracker(new Component(){}); - private Toolkit toolkit = Toolkit.getDefaultToolkit(); - public void read(File file) throws IOException { - try { - tracker.addImage(toolkit.createImage(file.toURL()), 0); - tracker.waitForID(0); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - }; - - public static void main(String[] args) - throws Exception - { - int loop = (args.length > 0) ? Integer.parseInt(args[0]) : 1; - BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); - List list = new ArrayList(); - String line; - while ((line = r.readLine()) != null) - list.add(new File(line)); - File[] files = (File[])list.toArray(new File[list.size()]); - benchmark(files, loop, TOOLKIT, " Toolkit"); - benchmark(files, loop, IMAGEIO, " ImageIO"); - benchmark(files, loop, SIXLEGS1, "Sixlegs1"); - benchmark(files, loop, SIXLEGS2, "Sixlegs2"); - } - - private static void benchmark(File[] files, int loop, PngReader reader, String desc) - throws IOException - { - File cur = null; - try { - long t = System.currentTimeMillis(); - for (int i = 0; i < loop; i++) { - for (int j = 0; j < files.length; j++) { - reader.read(cur = files[j]); - } - } - t = System.currentTimeMillis() - t; - if (desc != null) - System.err.println(desc + ": read " + (files.length * loop) + " images in " + t + " ms"); - } catch (IOException e) { - System.err.println("Error reading " + cur); - throw e; - } - } -} diff --git a/javapng2/src/test/com/sixlegs/png/PngTestCase.java b/javapng2/src/test/com/sixlegs/png/PngTestCase.java deleted file mode 100644 index d6bfcc3..0000000 --- a/javapng2/src/test/com/sixlegs/png/PngTestCase.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.sixlegs.png; - -import java.lang.reflect.Constructor; -import java.io.*; -import java.util.*; -import java.util.zip.Checksum; -import junit.framework.*; - -abstract public class PngTestCase -extends TestCase -{ - private static final String TEST_METHODS = "testmethods"; - private static final String DELIMITER = ","; - - protected PngTestCase(String name) - { - super(name); - } - - protected static TestSuite getSuite(Class testClass) - { - if (!TestCase.class.isAssignableFrom(testClass)) - throw new IllegalArgumentException("Must pass in a subclass of TestCase"); - String testMethods = System.getProperty(TEST_METHODS); - if (testMethods == null || testMethods.length() == 0) - return new TestSuite(testClass); - - TestSuite suite = new TestSuite(); - try { - Constructor constructor = testClass.getConstructor(new Class[] {String.class}); - List testCaseNames = getTestCaseNames(testMethods); - for (Iterator testCases = testCaseNames.iterator(); testCases.hasNext();) { - String testCaseName = (String)testCases.next(); - suite.addTest((TestCase)constructor.newInstance(new Object[] {testCaseName})); - } - } catch (Exception e) { - throw new RuntimeException(testClass.getName() + " doesn't have the proper constructor"); - } - return suite; - } - - private static List getTestCaseNames(String testMethods) - { - List testMethodNames = new ArrayList(); - StringTokenizer tokenizer = new StringTokenizer(testMethods, DELIMITER); - while (tokenizer.hasMoreTokens()) { - testMethodNames.add(tokenizer.nextToken()); - } - return testMethodNames; - } - - public static long getChecksum(Checksum checksum, File file, byte[] buf) - throws IOException - { - checksum.reset(); - InputStream in = new FileInputStream(file); - try { - for (;;) { - int amt = in.read(buf); - if (amt < 0) - break; - checksum.update(buf, 0, amt); - } - } finally { - in.close(); - } - return checksum.getValue(); - } - - public static void skipFully(DataInput in, int n) - throws IOException - { - while (n > 0) { - int amt = in.skipBytes(n); - if (amt == 0) { - in.readByte(); - n--; - } else { - n -= amt; - } - } - } -} diff --git a/javapng2/src/test/com/sixlegs/png/SuiteLoop.java b/javapng2/src/test/com/sixlegs/png/SuiteLoop.java deleted file mode 100644 index c0f2d8b..0000000 --- a/javapng2/src/test/com/sixlegs/png/SuiteLoop.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.sixlegs.png; - -import java.io.*; - -public class SuiteLoop -{ - public static void main(String[] args) - throws Exception - { - String[] empty = new String[0]; - int count = Integer.parseInt(args[0]); - while (count-- > 0) { - SuiteViewer.main(empty); - } - } -} diff --git a/javapng2/src/test/com/sixlegs/png/SuiteViewer.java b/javapng2/src/test/com/sixlegs/png/SuiteViewer.java deleted file mode 100644 index c721344..0000000 --- a/javapng2/src/test/com/sixlegs/png/SuiteViewer.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.sixlegs.png; - -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.*; -import javax.imageio.ImageIO; - -public class SuiteViewer -{ - private static final String[] IMAGES = { - "basi0g01", "basi0g02", "basi0g04", "basi0g08", "basi0g16", - "basi2c08", "basi2c16", "basi3p01", "basi3p02", "basi3p04", - "basi3p08", "basi4a08", "basi4a16", "basi6a08", "basi6a16", null, - "basn0g01", "basn0g02", "basn0g04", "basn0g08", "basn0g16", - "basn2c08", "basn2c16", "basn3p01", "basn3p02", "basn3p04", - "basn3p08", "basn4a08", "basn4a16", "basn6a08", "basn6a16", null, - "bgai4a08", "bgai4a16", "bgan6a08", "bgan6a16", - "bgbn4a08", "bggn4a16", "bgwn6a08", "bgyn6a16", null, - "ccwn2c08", "ccwn3p08", "ch1n3p04", "ch2n3p08", - "cdfn2c08", "cdhn2c08", "cdsn2c08", "cdun2c08", null, - "cs3n2c16", "cs3n3p08", "cs5n2c08", "cs5n3p08", "cs8n2c08", "cs8n3p08", - "cm0n0g04", "cm7n0g04", "cm9n0g04", "ct0n0g04", "ct1n0g04", "ctzn0g04", null, - "f00n0g08", "f01n0g08", "f02n0g08", "f03n0g08", "f04n0g08", - "f00n2c08", "f01n2c08", "f02n2c08", "f03n2c08", "f04n2c08", null, - "g03n0g16", "g04n0g16", "g05n0g16", "g07n0g16", "g10n0g16", "g25n0g16", null, - "g03n2c08", "g04n2c08", "g05n2c08", "g07n2c08", "g10n2c08", "g25n2c08", null, - "g03n3p04", "g04n3p04", "g05n3p04", "g07n3p04", "g10n3p04", "g25n3p04", null, - "oi1n0g16", "oi1n2c16", "oi2n0g16", "oi2n2c16", - "oi4n0g16", "oi4n2c16", "oi9n0g16", "oi9n2c16", null, - "s01i3p01", "s02i3p01", "s03i3p01", "s04i3p01", - "s05i3p02", "s06i3p02", "s07i3p02", "s08i3p02", "s09i3p02", null, - "s01n3p01", "s02n3p01", "s03n3p01", "s04n3p01", - "s05n3p02", "s06n3p02", "s07n3p02", "s08n3p02", "s09n3p02", null, - "s32i3p04", "s33i3p04", "s34i3p04", "s35i3p04", - "s36i3p04", "s37i3p04", "s38i3p04", "s39i3p04", "s40i3p04", null, - "s32n3p04", "s33n3p04", "s34n3p04", "s35n3p04", - "s36n3p04", "s37n3p04", "s38n3p04", "s39n3p04", "s40n3p04", null, - "tbbn1g04", "tbbn2c16", "tbbn3p08", "tbgn2c16", "tbgn3p08", - "tbrn2c08", "tbwn1g16", "tbwn3p08", "tbyn3p08", "tp0n1g08", - "tp0n2c08", "tp0n3p08", "tp1n3p08", null, - "z00n2c08", "z03n2c08", "z06n2c08", "z09n2c08", - "pp0n2c16", "pp0n6a08", "ps1n0g08", "ps1n2c16", "ps2n0g08", "ps2n2c16", - }; - - private static final int PADDING = 8; - private static final int ACROSS = 15; - private static final int DOWN = 16; - - final private PngConfig config; - - public SuiteViewer() - { - this(new PngConfig.Builder() - .readLimit(PngConfig.READ_EXCEPT_METADATA) - .build()); - } - - public SuiteViewer(PngConfig config) - { - this.config = config; - } - - public static void main(String[] args) - throws Exception - { - ImageIO.write(new SuiteViewer().render(true), "PNG", new File(args[0])); - } - - public BufferedImage render(boolean createImage) - throws IOException - { - int w = (32 + PADDING) * ACROSS; - int h = (32 + PADDING) * DOWN; - BufferedImage test = null; - Graphics2D g = null; - if (createImage) { - test = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); - g = test.createGraphics(); - g.setPaint(Color.gray); - g.fillRect(0, 0, w, h); - } - int i = 0, ix = 0, iy = 0; - while (i < IMAGES.length) { - if (IMAGES[i] == null) { - i++; - iy++; - ix = 0; - } - int x = (32 + PADDING) * ix + PADDING / 2; - int y = (32 + PADDING) * iy + PADDING / 2; - String resource = "/images/suite/" + IMAGES[i] + ".png"; - PngImage png = new PngImage(config); - BufferedImage img = png.read(SuiteViewer.class.getResourceAsStream(resource), true); - if (createImage) { - Color bg = png.getBackground(); - if (bg != null) { - g.setPaint(bg); - g.fillRect(x, y, img.getWidth(), img.getHeight()); - } - g.drawImage(img, x, y, null); - } - i++; - ix++; - } - if (createImage) { - g.dispose(); - return test; - } - return null; - } -} diff --git a/javapng2/src/test/com/sixlegs/png/TestData.java b/javapng2/src/test/com/sixlegs/png/TestData.java deleted file mode 100644 index 4d9b5d6..0000000 --- a/javapng2/src/test/com/sixlegs/png/TestData.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.sixlegs.png; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.AlphaComposite; -import java.awt.image.*; -import java.io.*; -import java.security.MessageDigest; -import junit.framework.*; - -public class TestData -extends PngTestCase -{ - public void testImages() - throws Exception - { - BufferedImage argb = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB); - Raster raster = argb.getRaster(); - int[] data = new int[800 * 600]; - byte[] pixbuf = new byte[4]; - - PngConfig config = new PngConfig.Builder().warningsFatal(true).build(); - MessageDigest md5 = MessageDigest.getInstance("MD5"); - BufferedReader r = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/images.txt"))); - boolean fail = false; - String line; - while ((line = r.readLine()) != null) { - line = line.trim(); - if (line.equals("") || line.startsWith("#")) - continue; - int space = line.indexOf(' '); - String name = line.substring(0, space).trim(); - String result = line.substring(space + 1).trim(); - try { - InputStream in = getClass().getResourceAsStream(name); - if (in == null) - fail("Cannot find image \"" + name + "\""); - BufferedImage image = new PngImage(config).read(in, true); - Graphics2D g = argb.createGraphics(); - g.setPaint(new Color(255, 255, 255, 0)); - g.setComposite(AlphaComposite.Src); - g.fillRect(0, 0, argb.getWidth(), argb.getHeight()); - g.drawImage(image, null, 0, 0); - raster.getDataElements(0, 0, image.getWidth(), image.getHeight(), data); - for (int i = 0, y = 0, h = image.getHeight(); y < h; y++) { - for (int x = 0, w = image.getWidth(); x < w; x++, i++) { - int pixel = data[i]; - pixbuf[3] = (byte)(0xFF & pixel); - pixbuf[2] = (byte)(0xFF & (pixel >>> 8)); - pixbuf[1] = (byte)(0xFF & (pixel >>> 16)); - pixbuf[0] = (byte)(0xFF & (pixel >>> 24)); -// if (i < 10) -// System.err.println("pixel " + i + " = [" + (0xFF&pixbuf[1]) + "," + (0xFF&pixbuf[2]) + "," + (0xFF&pixbuf[3]) + "," + (0xFF&pixbuf[0]) + "]"); - md5.update(pixbuf); - } - } - String hash = toHexString(md5.digest()); - if (!result.equals(hash)) { - System.err.println("Expected digest 0x" + result + " for image " + name + ", got 0x" + hash); - fail = true; - } - } catch (Exception e) { - if (!result.equals(e.getMessage())) { - System.err.println("Caught exception while processing image " + name + ":"); - e.printStackTrace(System.err); - fail = true; - } - } - } - if (fail) - fail("Failures detected."); - } - - private static String toHexString(byte[] b) - { - StringBuffer hex = new StringBuffer(2 * b.length); - for (int i = 0; i < b.length; i++) { - byte n = b[i]; - if (n >= 0 && n <= 15) - hex.append("0"); - hex.append(Integer.toHexString(0xFF & n)); - } - return hex.toString().toUpperCase(); - } - - public TestData(String name) - { - super(name); - } - - public static Test suite() - { - return getSuite(TestData.class); - } -} diff --git a/javapng2/src/test/com/sixlegs/png/TestPngSuite.java b/javapng2/src/test/com/sixlegs/png/TestPngSuite.java deleted file mode 100644 index 9755d90..0000000 --- a/javapng2/src/test/com/sixlegs/png/TestPngSuite.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.sixlegs.png; - -import java.io.*; -import junit.framework.*; - -public class TestPngSuite -extends PngTestCase -{ - public void testRead() - throws Exception - { - long t = System.currentTimeMillis(); - new SuiteViewer().render(false); - t = System.currentTimeMillis() - t; - System.err.println("Read PngSuite in " + t + " ms"); - } - - public void testNoReduce() - throws Exception - { - PngConfig config = new PngConfig.Builder() - .gammaCorrect(false) - .reduce16(false) - .build(); - new SuiteViewer(config).render(false); - } - - public void testConvertIndexed() - throws Exception - { - PngConfig config = new PngConfig.Builder() - .convertIndexed(true) - .build(); - new SuiteViewer(config).render(false); - } - - public TestPngSuite(String name) - { - super(name); - } - - public static Test suite() - { - return getSuite(TestPngSuite.class); - } -} diff --git a/javapng2/src/test/com/sixlegs/png/TestSimple.java b/javapng2/src/test/com/sixlegs/png/TestSimple.java deleted file mode 100644 index 38db288..0000000 --- a/javapng2/src/test/com/sixlegs/png/TestSimple.java +++ /dev/null @@ -1,547 +0,0 @@ -package com.sixlegs.png; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.image.BufferedImage; -import java.io.*; -import java.util.*; -import javax.imageio.*; -import junit.framework.*; - -// TODO: reduce reliance on ImageIO for checksum calc -public class TestSimple -extends PngTestCase -{ - private static final int msOG_type = PngConstants.getChunkType("msOG"); - private static final int heRB_type = PngConstants.getChunkType("heRB"); - private byte[] buf = new byte[0x2000]; - - public void testNonFatalWarning() - throws Exception - { - new PngImage().read(getClass().getResourceAsStream("/images/broken/gama_zero.png"), true); - } - - public void testReadSuggestedPalette() - throws Exception - { - PngImage png = readResource("/images/misc/ps2n2c16.png"); - SuggestedPalette splt = - (SuggestedPalette)((List)png.getProperty(PngConstants.SUGGESTED_PALETTES)).get(0); - assertEquals("six-cube", splt.getName()); - assertEquals(16, splt.getSampleDepth()); - assertEquals(216, splt.getSampleCount()); - short[] pixel = new short[4]; - splt.getSample(1, pixel); - assertEquals(0, pixel[0]); - assertEquals(0, pixel[1]); - assertEquals(51, pixel[2]); - assertEquals(255, pixel[3]); - assertEquals(0, splt.getFrequency(0)); - assertEquals(0, splt.getFrequency(1)); - } - - public void testGetBackground() - throws Exception - { - assertEquals(Color.yellow, readResource("/images/suite/bgyn6a16.png").getBackground()); - assertEquals(Color.black, readResource("/images/suite/bgbn4a08.png").getBackground()); - assertEquals(Color.white, readResource("/images/suite/bgwn6a08.png").getBackground()); - assertEquals(new Color(0xABABAB), readResource("/images/suite/tbgn3p08.png").getBackground()); - assertNull(readResource("/images/suite/basn0g01.png").getBackground()); - } - - public void testReadExceptMultipleDataChunks() - throws Exception - { - readResource("/images/suite/oi4n0g16.png", - new PngImage(new PngConfig.Builder().readLimit(PngConfig.READ_EXCEPT_DATA).build())); - } - - public void testReadTextChunk() - throws Exception - { - PngImage png = readResource("/images/suite/ct1n0g04.png"); - TextChunk title = png.getTextChunk("Title"); - assertEquals("Title", title.getKeyword()); - assertNull(title.getTranslatedKeyword()); - assertNull(title.getLanguage()); - assertEquals("PngSuite", title.getText()); - assertEquals(PngConstants.tEXt, title.getType()); - - assertNull(png.getTextChunk("foobar")); - } - - public void testSubsampling() - throws Exception - { - subsamplingHelper("/images/misc/penguin.png", 3, 3, 923164955L); - subsamplingHelper("/images/misc/pngtest.png", 3, 3, 1930297805L); - try { - readResource("/images/suite/s02n3p01.png", - new PngImage(new PngConfig.Builder().sourceSubsampling(3, 3, 2, 2).build())); - fail("expected exception"); - } catch (IllegalStateException ignore) { } - } - - private BufferedImage subsamplingHelper(String path, int xsub, int ysub, long expect) - throws Exception - { - PngImage png = new PngImage(new PngConfig.Builder() - .sourceSubsampling(xsub, ysub, 0, 0) - .build()); - BufferedImage image = png.read(getClass().getResourceAsStream(path), true); - assertChecksum(expect, image, "subsample"); - return image; - } - - public void testSourceRegions() - throws Exception - { - regionHelper("/images/misc/penguin.png", new Rectangle(75, 0, 105, 125), 490287408L); - regionHelper("/images/misc/pngtest.png", new Rectangle(10, 20, 30, 40), 2689440455L); - try { - regionHelper("/images/misc/pngtest.png", new Rectangle(10, 20, 100, 100), 0L); - fail("expected exception"); - } catch (IllegalStateException ignore) { } - } - - private void regionHelper(String path, Rectangle region, long expect) - throws Exception - { - PngImage png = new PngImage(new PngConfig.Builder().sourceRegion(region).build()); - BufferedImage image = png.read(getClass().getResourceAsStream(path), true); - assertEquals(region.width, image.getWidth()); - assertEquals(region.height, image.getHeight()); - assertChecksum(expect, image, "region"); - } - - private void assertChecksum(long expect, BufferedImage image, String desc) - throws Exception - { - File file = File.createTempFile(desc, ".png"); - javax.imageio.ImageIO.write(image, "PNG", file); - assertEquals(expect, getChecksum(new java.util.zip.CRC32(), file, buf)); - file.delete(); - } - - public void testRecolorMonochrome() - throws Exception - { - PngImage png = new PngImage(){ - protected BufferedImage createImage(InputStream in, Dimension size) throws IOException { - if (getBitDepth() == 1 && - getColorType() == PngConstants.COLOR_TYPE_GRAY) { - Map props = getProperties(); - props.put(PngConstants.COLOR_TYPE, - new Integer(PngConstants.COLOR_TYPE_PALETTE)); - props.put(PngConstants.PALETTE, new byte[]{ - (byte)255, 0, 0, - (byte)255, (byte)255, 0 - }); - } - return super.createImage(in, size); - } - }; - InputStream in = getClass().getResourceAsStream("/images/suite/basn0g01.png"); - File file = File.createTempFile("recolor", ".png"); - javax.imageio.ImageIO.write(png.read(in, true), "PNG", file); - assertEquals(2661639413L, getChecksum(new java.util.zip.CRC32(), file, buf)); - new PngImage().read(file); // test reading from a file - file.delete(); - } - - abstract private static class PrivateChunkReader - extends PngImage - { - private final int type; - public PrivateChunkReader(int type) { this.type = type; } - - abstract protected void readChunk(DataInput in) throws IOException; - @Override protected void readChunk(int type, DataInput in, long off, int len) throws IOException { - if (type == this.type) { - readChunk(in); - } else { - super.readChunk(type, in, off, len); - } - } - } - - public void testDataInputMethods() - throws Exception - { - readResource("/images/misc/herbio.png", new PrivateChunkReader(heRB_type){ - protected void readChunk(DataInput in) throws IOException { - assertEquals(true, in.readBoolean()); - assertEquals(false, in.readBoolean()); - assertEquals(250, in.readUnsignedByte()); - assertEquals((byte)250, in.readByte()); - assertEquals(50000, in.readUnsignedShort()); - assertEquals((short)50000, in.readShort()); - assertEquals('Z', in.readChar()); - assertEquals((float)Math.PI, in.readFloat()); - assertEquals(Math.PI, in.readDouble()); - assertEquals("Chris", in.readLine()); - assertEquals("Nokleberg", in.readUTF()); - assertEquals(2000000000, in.readInt()); - } - }); - readResource("/images/misc/herbio.png", new PrivateChunkReader(heRB_type){ - protected void readChunk(DataInput in) throws IOException { - skipFully(in, 39); - assertEquals(2000000000, in.readInt()); - } - }); - try { - readResource("/images/misc/herbio.png", new PrivateChunkReader(heRB_type){ - protected void readChunk(DataInput in) throws IOException { - skipFully(in, 40); - in.readInt(); - fail("expected exception"); - } - }); - } catch (EOFException ignore) { } - try { - readResource("/images/misc/herbio.png", new PrivateChunkReader(heRB_type){ - protected void readChunk(DataInput in) throws IOException { - skipFully(in, 42); - in.readShort(); - fail("expected exception"); - } - }); - } catch (EOFException ignore) { } - try { - readResource("/images/misc/herbio.png", new PrivateChunkReader(heRB_type){ - protected void readChunk(DataInput in) throws IOException { - skipFully(in, 43); - in.readByte(); - fail("expected exception"); - } - }); - } catch (EOFException ignore) { } - } - - public void testPrivateChunk() - throws Exception - { - final String ORIGINAL_GIF = "original_gif"; - PngImage png = readResource("/images/misc/anigif.png", new PngImage(){ - @Override protected void readChunk(int type, DataInput in, long off, int len) throws IOException { - if (type == msOG_type) { - byte[] bytes = new byte[len]; - in.readFully(bytes); - getProperties().put(ORIGINAL_GIF, bytes); - } else { - super.readChunk(type, in, off, len); - } - } - }); - byte[] bytes = (byte[])png.getProperty(ORIGINAL_GIF); - - assertEquals("MSOFFICE9.0", new String(bytes, 0, 11, "US-ASCII")); - - File file = File.createTempFile("msog", ".gif"); - OutputStream out = new FileOutputStream(file); - out.write(bytes, 11, bytes.length - 11); - out.close(); - assertEquals(916473047L, getChecksum(new java.util.zip.CRC32(), file, buf)); - file.delete(); - } - - public void testRead() - throws Exception - { - PngImage png = readResource("/images/misc/cc1.png"); - assertEquals(138, png.getWidth()); - assertEquals(180, png.getHeight()); - } - - public void testProgressBar() - throws Exception - { - final List progress = new ArrayList(); - readResource("/images/misc/cc1.png", new PngImage(){ - protected boolean handleProgress(BufferedImage image, float pct) { - progress.add(new Float(pct)); - return pct < 60f; - } - }); - assertEquals(Arrays.asList(new Float[]{ - new Float(5.5555553f), - new Float(10.555555f), - new Float(15.555555f), - new Float(20.555555f), - new Float(25.555555f), - new Float(30.555555f), - new Float(35.555557f), - new Float(40.555557f), - new Float(45.555557f), - new Float(50.555557f), - new Float(55.555557f), - new Float(60.555557f), - }), progress); - } - - public void testAbort() - throws Exception - { - readResource("/images/suite/basi3p04.png", new PngImage(){ - protected boolean handleFrame(BufferedImage image, int framesLeft) { - if (framesLeft != 6) - throw new IllegalStateException("Should have aborted after first frame"); - return false; - } - }); - } - - public void testReadAncillary() - throws Exception - { - PngImage png = readResource("/images/misc/anigif.png"); - assertEquals(32, png.getWidth()); - assertEquals(32, png.getHeight()); - // TODO: check gif chunks - } - - public void testSkipCriticalChunk() - throws Exception - { - try { - readResource("/images/misc/penguin.png", new PngImage(){ - @Override protected void readChunk(int type, DataInput in, long off, int len) throws IOException { - if (type == PngConstants.PLTE) - return; - super.readChunk(type, in, off, len); - } - }); - fail("expected exception"); - } catch (IllegalStateException ignore) { } - } - - public void testCoverage() - throws Exception - { - try { - new PngImage().read(null, true); - fail("expected exception"); - } catch (NullPointerException ignore) { } - - try { - new PngImage().getWidth(); - fail("expected exception"); - } catch (IllegalStateException ignore) { } - - try { - new PngConfig.Builder().sourceRegion(new Rectangle(-1, 0, 1, 1)); - fail("expected exception"); - } catch (IllegalArgumentException ignore) { } - - try { - new PngConfig.Builder().sourceSubsampling(0, 2, 0, 0); - fail("expected exception"); - } catch (IllegalArgumentException ignore) { } - - try { - new PngConfig.Builder() - .sourceRegion(new Rectangle(0, 0, 10, 10)) - .progressive(true) - .build(); - fail("expected exception"); - } catch (IllegalStateException ignore) { } - - try { - new PngConfig.Builder() - .sourceSubsampling(2, 2, 0, 0) - .progressive(true) - .build(); - fail("expected exception"); - } catch (IllegalStateException ignore) { } - - assertTrue(PngConstants.isReserved(PngConstants.getChunkType("HErB"))); - assertTrue(PngConstants.isSafeToCopy(PngConstants.getChunkType("HERb"))); - - readResource("/images/suite/tbbn2c16.png", - new PngImage(new PngConfig.Builder().gammaCorrect(false).build())); - - readResource("/images/suite/basi0g01.png", - new PngImage(new PngConfig.Builder().progressive(true).build())); - - PngConfig readHeader = new PngConfig.Builder() - .sourceRegion(null) // for coverage - .readLimit(PngConfig.READ_HEADER) - .build(); - assertEquals(32, readResource("/images/suite/basn0g01.png", new PngImage(readHeader)).getWidth()); - assertEquals(PngConfig.READ_HEADER, new PngConfig.Builder(readHeader).build().getReadLimit()); - - PngConfig readUntilData = new PngConfig.Builder().readLimit(PngConfig.READ_UNTIL_DATA).build(); - assertNotNull(readResource("/images/suite/basn3p01.png", new PngImage(readUntilData)).getProperty(PngConstants.PALETTE)); - - PngConfig readExceptData = new PngConfig.Builder().readLimit(PngConfig.READ_EXCEPT_DATA).build(); - assertEquals(32, readResource("/images/suite/basn0g01.png", new PngImage(readExceptData)).getWidth()); - } - - public void testErrors() - throws Exception - { - errorHelper("/images/broken/x00n0g01.png"); - errorHelper("/images/broken/xcrn0g04.png"); - errorHelper("/images/broken/xlfn0g04.png"); - - errorHelper("/images/broken/bkgd_after_idat.png"); - errorHelper("/images/broken/chrm_after_idat.png"); - errorHelper("/images/broken/chrm_after_plte.png"); - errorHelper("/images/broken/chunk_crc.png"); - errorHelper("/images/broken/chunk_length.png"); - errorHelper("/images/broken/chunk_private_critical.png"); - errorHelper("/images/broken/chunk_type.png"); - errorHelper("/images/broken/gama_after_idat.png"); - errorHelper("/images/broken/gama_after_plte.png"); - errorHelper("/images/broken/gama_zero.png"); - errorHelper("/images/broken/hist_after_idat.png"); - errorHelper("/images/broken/hist_before_plte.png"); - errorHelper("/images/broken/iccp_after_idat.png"); - errorHelper("/images/broken/iccp_after_plte.png"); - errorHelper("/images/broken/ihdr_16bit_palette.png"); - errorHelper("/images/broken/ihdr_1bit_alpha.png"); - errorHelper("/images/broken/ihdr_bit_depth.png"); - errorHelper("/images/broken/ihdr_color_type.png"); - errorHelper("/images/broken/ihdr_compression_method.png"); - errorHelper("/images/broken/ihdr_filter_method.png"); - errorHelper("/images/broken/ihdr_image_size.png"); - errorHelper("/images/broken/ihdr_interlace_method.png"); - errorHelper("/images/broken/itxt_compression_flag.png"); - errorHelper("/images/broken/itxt_compression_method.png"); - errorHelper("/images/broken/itxt_keyword_length.png"); - errorHelper("/images/broken/itxt_keyword_length_2.png"); - errorHelper("/images/broken/missing_idat.png"); - errorHelper("/images/broken/missing_ihdr.png"); - errorHelper("/images/broken/missing_plte.png"); - errorHelper("/images/broken/missing_plte_2.png"); - errorHelper("/images/broken/multiple_bkgd.png"); - errorHelper("/images/broken/multiple_chrm.png"); - errorHelper("/images/broken/multiple_gama.png"); - errorHelper("/images/broken/multiple_hist.png"); - errorHelper("/images/broken/multiple_iccp.png"); - errorHelper("/images/broken/multiple_ihdr.png"); - errorHelper("/images/broken/multiple_offs.png"); - errorHelper("/images/broken/multiple_pcal.png"); - errorHelper("/images/broken/multiple_phys.png"); - errorHelper("/images/broken/multiple_plte.png"); - errorHelper("/images/broken/multiple_sbit.png"); - errorHelper("/images/broken/multiple_scal.png"); - errorHelper("/images/broken/multiple_srgb.png"); - errorHelper("/images/broken/multiple_ster.png"); - errorHelper("/images/broken/multiple_time.png"); - errorHelper("/images/broken/multiple_trns.png"); - errorHelper("/images/broken/nonconsecutive_idat.png"); - errorHelper("/images/broken/offs_after_idat.png"); - errorHelper("/images/broken/pcal_after_idat.png"); - errorHelper("/images/broken/phys_after_idat.png"); - errorHelper("/images/broken/plte_after_idat.png"); - errorHelper("/images/broken/plte_empty.png"); - errorHelper("/images/broken/plte_in_grayscale.png"); - errorHelper("/images/broken/plte_length_mod_three.png"); - errorHelper("/images/broken/plte_too_many_entries.png"); - errorHelper("/images/broken/plte_too_many_entries_2.png"); - errorHelper("/images/broken/sbit_after_idat.png"); - errorHelper("/images/broken/sbit_after_plte.png"); - errorHelper("/images/broken/scal_after_idat.png"); - errorHelper("/images/broken/splt_after_idat.png"); - errorHelper("/images/broken/srgb_after_idat.png"); - errorHelper("/images/broken/srgb_after_plte.png"); - errorHelper("/images/broken/ster_after_idat.png"); - errorHelper("/images/broken/time_value_range.png"); - errorHelper("/images/broken/trns_after_idat.png"); - errorHelper("/images/broken/trns_bad_color_type.png"); - errorHelper("/images/broken/trns_too_many_entries.png"); - errorHelper("/images/broken/phys_unit_specifier.png"); - errorHelper("/images/broken/offs_unit_specifier.png"); - errorHelper("/images/broken/scal_unit_specifier.png"); - errorHelper("/images/broken/scal_floating_point.png"); - errorHelper("/images/broken/scal_negative.png"); - errorHelper("/images/broken/scal_zero.png"); - errorHelper("/images/broken/sbit_sample_depth.png"); - errorHelper("/images/broken/sbit_sample_depth_2.png"); - errorHelper("/images/broken/ster_mode.png"); - errorHelper("/images/broken/splt_sample_depth.png"); - errorHelper("/images/broken/splt_length_mod_6.png"); - errorHelper("/images/broken/splt_length_mod_10.png"); - errorHelper("/images/broken/splt_duplicate_name.png"); - errorHelper("/images/broken/ztxt_compression_method.png"); - errorHelper("/images/broken/ztxt_data_format.png"); - - errorHelper("/images/broken/length_ihdr.png"); - errorHelper("/images/broken/length_iend.png"); - errorHelper("/images/broken/length_ster.png"); - errorHelper("/images/broken/length_srgb.png"); - errorHelper("/images/broken/length_gama.png"); - errorHelper("/images/broken/length_phys.png"); - errorHelper("/images/broken/length_time.png"); - errorHelper("/images/broken/length_offs.png"); - errorHelper("/images/broken/length_chrm.png"); - errorHelper("/images/broken/length_gifg.png"); - errorHelper("/images/broken/length_trns_gray.png"); - errorHelper("/images/broken/length_trns_rgb.png"); - errorHelper("/images/broken/length_trns_palette.png"); - errorHelper("/images/broken/length_hist.png"); - errorHelper("/images/broken/length_sbit.png"); - errorHelper("/images/broken/length_sbit_2.png"); - errorHelper("/images/broken/length_bkgd_gray.png"); - errorHelper("/images/broken/length_bkgd_rgb.png"); - errorHelper("/images/broken/length_bkgd_palette.png"); - errorHelper("/images/broken/truncate_zlib.png"); - errorHelper("/images/broken/truncate_zlib_2.png"); - errorHelper("/images/broken/truncate_idat_0.png"); - errorHelper("/images/broken/truncate_idat_1.png"); - errorHelper("/images/broken/unknown_filter_type.png"); - errorHelper("/images/broken/text_trailing_null.png"); - - errorHelper("/images/broken/private_compression_method.png"); - errorHelper("/images/broken/private_filter_method.png"); - errorHelper("/images/broken/private_interlace_method.png"); - errorHelper("/images/broken/private_filter_type.png"); - } - - public void errorHelper(String path) - throws Exception - { - try { - readResource(path); - fail("Expected exception in " + path); - } catch (Exception e) { - System.err.println(new File(path).getName() + ": " + e.getMessage()); - // StackTraceElement stack = e.getStackTrace()[0]; - // System.err.println("\t" + stack.getFileName() + ":" + stack.getLineNumber()); - if (e.getMessage() == null) - e.printStackTrace(System.err); - } - } - - private static final PngConfig WARNINGS_FATAL = - new PngConfig.Builder().warningsFatal(true).build(); - - private PngImage readResource(String path) - throws IOException - { - return readResource(path, new PngImage(WARNINGS_FATAL)); - } - - private PngImage readResource(String path, PngImage png) - throws IOException - { - InputStream in = getClass().getResourceAsStream(path); - png.read(in, true); - return png; - } - - public TestSimple(String name) - { - super(name); - } - - public static Test suite() - { - return getSuite(TestSimple.class); - } -} diff --git a/javapng2/src/test/com/sixlegs/png/iio/IIOTestCase.java b/javapng2/src/test/com/sixlegs/png/iio/IIOTestCase.java deleted file mode 100644 index 84aa033..0000000 --- a/javapng2/src/test/com/sixlegs/png/iio/IIOTestCase.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.sixlegs.png.iio; - -import java.awt.image.BufferedImage; -import java.io.*; -import java.lang.reflect.Constructor; -import java.util.*; -import javax.imageio.*; -import javax.imageio.metadata.*; -import javax.imageio.stream.ImageInputStream; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -abstract public class IIOTestCase -extends TestCase -{ - public static final List SUITE = Collections.unmodifiableList(Arrays.asList(transform(new String[]{ - "basi0g01", "basi0g02", "basi0g04", "basi0g08", - "basi0g16", "basi2c08", "basi2c16", "basi3p01", - "basi3p02", "basi3p04", "basi3p08", "basi4a08", - "basi4a16", "basi6a08", "basi6a16", "basn0g01", - "basn0g02", "basn0g04", "basn0g08", "basn0g16", - "basn2c08", "basn2c16", "basn3p01", "basn3p02", - "basn3p04", "basn3p08", "basn4a08", "basn4a16", - "basn6a08", "basn6a16", "bgai4a08", "bgai4a16", - "bgan6a08", "bgan6a16", "bgbn4a08", "bggn4a16", - "bgwn6a08", "bgyn6a16", "ccwn2c08", "ccwn3p08", - "cdfn2c08", "cdhn2c08", "cdsn2c08", "cdun2c08", - "ch1n3p04", "ch2n3p08", "cm0n0g04", "cm7n0g04", - "cm9n0g04", "cs3n2c16", "cs3n3p08", "cs5n2c08", - "cs5n3p08", "cs8n2c08", "cs8n3p08", "ct0n0g04", - "ct1n0g04", "ctzn0g04", "f00n0g08", "f00n2c08", - "f01n0g08", "f01n2c08", "f02n0g08", "f02n2c08", - "f03n0g08", "f03n2c08", "f04n0g08", "f04n2c08", - "g03n0g16", "g03n2c08", "g03n3p04", "g04n0g16", - "g04n2c08", "g04n3p04", "g05n0g16", "g05n2c08", - "g05n3p04", "g07n0g16", "g07n2c08", "g07n3p04", - "g10n0g16", "g10n2c08", "g10n3p04", "g25n0g16", - "g25n2c08", "g25n3p04", "oi1n0g16", "oi1n2c16", - "oi2n0g16", "oi2n2c16", "oi4n0g16", "oi4n2c16", - "oi9n0g16", "oi9n2c16", "pp0n2c16", "pp0n6a08", - "ps1n0g08", "ps1n2c16", "ps2n0g08", "ps2n2c16", - "s01i3p01", "s01n3p01", "s02i3p01", "s02n3p01", - "s03i3p01", "s03n3p01", "s04i3p01", "s04n3p01", - "s05i3p02", "s05n3p02", "s06i3p02", "s06n3p02", - "s07i3p02", "s07n3p02", "s08i3p02", "s08n3p02", - "s09i3p02", "s09n3p02", "s32i3p04", "s32n3p04", - "s33i3p04", "s33n3p04", "s34i3p04", "s34n3p04", - "s35i3p04", "s35n3p04", "s36i3p04", "s36n3p04", - "s37i3p04", "s37n3p04", "s38i3p04", "s38n3p04", - "s39i3p04", "s39n3p04", "s40i3p04", "s40n3p04", - "tbbn1g04", "tbbn2c16", "tbbn3p08", "tbgn2c16", - "tbgn3p08", "tbrn2c08", "tbwn1g16", "tbwn3p08", - "tbyn3p08", "tp0n1g08", "tp0n2c08", "tp0n3p08", - "tp1n3p08", "z00n2c08", "z03n2c08", "z06n2c08", - "z09n2c08", - }, "/images/suite/", ".png"))); - - public static String[] transform(String[] array, String before, String after) - { - for (int i = 0; i < array.length; i++) - array[i] = before + array[i] + after; - return array; - } - - protected String name; - - public IIOTestCase(String name) - { - super("test"); - this.name = name; - } - - public static Test createSuite(Class subclass) - throws Exception - { - return createSuite(subclass, SUITE); - } - - public static Test createSuite(Class subclass, Collection images) - throws Exception - { - TestSuite suite = new TestSuite(); - Constructor cstruct = subclass.getConstructor(new Class[]{ String.class }); - for (Iterator it = images.iterator(); it.hasNext();) { - suite.addTest((IIOTestCase)cstruct.newInstance(new Object[]{ (String)it.next() })); - } - return suite; - } - - protected ImageReader sunIR = null; - - public void test() - throws Exception - { - // Initialise sun's plugin - sunIR = new com.sun.imageio.plugins.png.PNGImageReader( - new com.sun.imageio.plugins.png.PNGImageReaderSpi()); - sunIR.setInput(ImageIO.createImageInputStream( - getClass().getResourceAsStream(name))); - - InputStream in = getClass().getResourceAsStream(name); - ImageInputStream iis = ImageIO.createImageInputStream(in); - PngImageReaderSpi spi = new PngImageReaderSpi(); - assertTrue(spi.canDecodeInput(iis)); - PngImageReader ir = new PngImageReader(spi); - ir.setInput(iis); - BufferedImage bi = ir.read(0); - assertTrue(bi != null); - test(name, ir, bi); - } - - public String toString() - { - return name + "(" + getClass().getName() + ")"; - } - - abstract protected void test(String name, PngImageReader ir, BufferedImage bi) throws Exception; -} diff --git a/javapng2/src/test/com/sixlegs/png/iio/MetadataTestCase.java b/javapng2/src/test/com/sixlegs/png/iio/MetadataTestCase.java deleted file mode 100644 index 5488e87..0000000 --- a/javapng2/src/test/com/sixlegs/png/iio/MetadataTestCase.java +++ /dev/null @@ -1,186 +0,0 @@ -package com.sixlegs.png.iio; - -import java.awt.image.BufferedImage; -import javax.imageio.metadata.*; -import junit.framework.Test; -import org.w3c.dom.*; -import com.megginson.sax.DataWriter; -import org.xml.sax.helpers.AttributesImpl; - -abstract public class MetadataTestCase -extends IIOTestCase -{ - public MetadataTestCase(String name) - { - super(name); - } - - protected abstract Node getSunsTree() throws Exception; - - protected void test(String name, PngImageReader ir, BufferedImage bi) - throws Exception - { - System.out.print("================== "); - System.out.println(name); - System.out.println(""); - - IIOMetadata iiom = ir.getImageMetadata(0); - Node n = iiom.getAsTree(getFormatName()); - writeNode(n); - - java.io.PrintStream stderr = System.err; - System.setErr(System.out); - Node sunTree = null; - try { - sunTree = getSunsTree(); - } catch (Exception e) { - System.out.println("Exception getting Sun's tree, no comparison will be done:"); - e.printStackTrace(System.out); - } finally { - System.setErr(stderr); - } - if (sunTree != null && compare(n, sunTree) == false) { - System.out.println(">>>>>>>> Sun's is different! <<<<<<<<"); - System.out.println(""); - writeNode(sunTree); - fail("Sun's metadata is different."); - } - System.out.println(""); - } - - protected void writeNode(Node n) - throws Exception - { - DataWriter dw = new DataWriter(); - dw.setIndentStep(4); - dw.startDocument(); - writeNode(dw, n); - dw.endDocument(); - } - - abstract protected String getFormatName(); - - private void writeNode(DataWriter dw, Node n) - throws Exception - { - AttributesImpl attr = new AttributesImpl(); - NamedNodeMap map = n.getAttributes(); - if (map != null) - { - int len = map.getLength(); - for (int i=0; i"); - return; - } - SwingUtilities.invokeLater(new Runnable() { - public void run() { - new Viewer(args); - } - }); - } - - private Viewer(String[] args) - { - BufferedImage image = readPngResource("checker.png"); - Rectangle rect = new Rectangle(0, 0, image.getWidth(), image.getHeight()); - checker = new TexturePaint(image, rect); - - JFrame.setDefaultLookAndFeelDecorated(true); - JFrame frame = new JFrame("PNG Viewer"); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - imagePanel = new ImagePanel(); - Dimension size = new Dimension(400, 300); - File file = (args.length > 0) ? new File(args[0]) : null; - if (file != null) { - try { - PngImage png = readHeader(file); - size.setSize(png.getWidth(), png.getHeight()); - } catch (IOException e) { - // ignore here, open will re-throw - } - } - imagePanel.setStretchMode(ImagePanel.STRETCH_PRESERVE); - imagePanel.setBackgroundPaint(checker); - imagePanel.setPreferredSize(size); -// JScrollPane scrollPane = new JScrollPane(imagePanel); -// frame.getContentPane().add(scrollPane, BorderLayout.CENTER); - frame.getContentPane().add(imagePanel, BorderLayout.CENTER); - // TODO: toolbar, menus - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - if (file != null) - open(file); - } - - private void open(File file) - { - new Thread(new ReadPngAction(new AnimatedPngImage(config){ - protected boolean handlePass(final BufferedImage image, int pass) { - if (isAnimated()) - return true; - SwingUtilities.invokeLater(new UpdateImageAction(imagePanel, image)); - if (progressiveDelay > 0 && (pass == 6 || !isInterlaced())) { - try { - Thread.sleep(progressiveDelay); - } catch (InterruptedException e) { - // ignore - } - } - return true; - } - }, file, imagePanel)).start(); - } - - private static PngImage readHeader(File file) - throws IOException - { - PngImage png = new PngImage(new PngConfig.Builder().readLimit(PngConfig.READ_HEADER).build()); - png.read(file); - return png; - } - - private BufferedImage readPngResource(String path) - { - try { - return new PngImage().read(getClass().getResourceAsStream(path), true); - } catch (IOException e) { - throw new Error(e.getMessage()); - } - } - - private static class ReadPngAction - implements Runnable - { - private AnimatedPngImage png; - private File file; - private ImagePanel panel; - - public ReadPngAction(AnimatedPngImage png, File file, ImagePanel panel) - { - this.png = png; - this.file = file; - this.panel = panel; - } - - public void run() - { - try { - // TODO: disable loading - BufferedImage[] frames = png.readAllFrames(file); - if (png.isAnimated()) { - panel.setPreferredSize(new Dimension(png.getWidth(), png.getHeight())); - final BufferedImage target = - panel.getGraphicsConfiguration().createCompatibleImage(png.getWidth(), png.getHeight(), - Transparency.TRANSLUCENT); - final Animator animator = new Animator(png, frames, target); - Timer timer = new Timer(50, null); - timer.setInitialDelay(0); - timer.addActionListener(animator); - timer.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - panel.setImage(target); - } - }); - timer.start(); - } - } catch (IOException e) { - // TODO: error dialog - e.printStackTrace(System.err); - } finally { - // TODO: re-enable loading - } - } - } - - private static class UpdateImageAction - implements Runnable - { - private ImagePanel panel; - private BufferedImage image; - - public UpdateImageAction(ImagePanel panel, BufferedImage image) - { - this.panel = panel; - this.image = image; - } - - public void run() - { - Dimension size = new Dimension(image.getWidth(), image.getHeight()); - panel.setPreferredSize(size); - panel.setImage(image); - } - } -} diff --git a/javapng2/src/viewer/com/sixlegs/png/viewer/checker.png b/javapng2/src/viewer/com/sixlegs/png/viewer/checker.png deleted file mode 100644 index 4e1aad8..0000000 Binary files a/javapng2/src/viewer/com/sixlegs/png/viewer/checker.png and /dev/null differ