diff options
author | Sven Gothel <[email protected]> | 2012-04-07 15:28:37 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-04-07 15:28:37 +0200 |
commit | 40830196070013432bc5f453eb31cfe4c64e0510 (patch) | |
tree | ca31a1e1e27adf9996963176c4f92b84e25623e9 /src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java | |
parent | 865c0588de57c9a020a435bc3f08be0f3f6ba162 (diff) |
Merge PNGJ 0.85 into namespace
PNGJ Version 0.85 (1 April 2012)
Apache 2.0 License
http://code.google.com/p/pngj/
Merged code:
- Changed namespace ar.com.hjg.pngj -> jogamp.opengl.util.pngj
to avoid collision when using a different version of PNGJ.
- Removed test and lossy packages and helper classes
to reduce footprint.
License information is added in main LICENSE.txt file.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java new file mode 100644 index 000000000..b0f02ea37 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java @@ -0,0 +1,67 @@ +package jogamp.opengl.util.pngj.chunks;
+
+import jogamp.opengl.util.pngj.ImageInfo;
+import jogamp.opengl.util.pngj.PngHelper;
+import jogamp.opengl.util.pngj.PngjException;
+
+/*
+ */
+public class PngChunkHIST extends PngChunk {
+ // http://www.w3.org/TR/PNG/#11hIST
+ // only for palette images
+
+ private int[] hist = new int[0]; // should have same lenght as palette
+
+ public PngChunkHIST(ImageInfo info) {
+ super(ChunkHelper.hIST, info);
+ }
+
+ @Override
+ public boolean mustGoBeforeIDAT() {
+ return true;
+ }
+
+ @Override
+ public boolean mustGoAfterPLTE() {
+ return true;
+ }
+
+ @Override
+ public void parseFromChunk(ChunkRaw c) {
+ if (!imgInfo.indexed)
+ throw new PngjException("only indexed images accept a HIST chunk");
+ int nentries = c.data.length / 2;
+ hist = new int[nentries];
+ for (int i = 0; i < hist.length; i++) {
+ hist[i] = PngHelper.readInt2fromBytes(c.data, i * 2);
+ }
+ }
+
+ @Override
+ public ChunkRaw createChunk() {
+ if (!imgInfo.indexed)
+ throw new PngjException("only indexed images accept a HIST chunk");
+ ChunkRaw c = null;
+ c = createEmptyChunk(hist.length * 2, true);
+ for (int i = 0; i < hist.length; i++) {
+ PngHelper.writeInt2tobytes(hist[i], c.data, i * 2);
+ }
+ return c;
+ }
+
+ @Override
+ public void cloneDataFromRead(PngChunk other) {
+ PngChunkHIST otherx = (PngChunkHIST) other;
+ hist = new int[otherx.hist.length];
+ System.arraycopy(otherx.hist, 0, hist, 0, otherx.hist.length);
+ }
+
+ public int[] getHist() {
+ return hist;
+ }
+
+ public void setHist(int[] hist) {
+ this.hist = hist;
+ }
+
+}
|