Skip to content

Commit

Permalink
v1.0.1 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianscar committed Mar 2, 2023
1 parent 06c74d5 commit 824ebe1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
```groovy
dependencies {
...
implementation 'com.tianscar.imageio:apng-imageio:1.0.0'
implementation 'com.tianscar.imageio:imageio-apng:1.0.1'
}
```

Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ ext {
libraryGroupName = 'com.tianscar.imageio'
libraryVendorName = 'Tianscar'

libraryVersionCode = 1
libraryVersionName = '1.0.0'
libraryVersionCode = 2
libraryVersionName = '1.0.1'

librarySourceCompatibility = JavaVersion.VERSION_1_8
libraryTargetCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -51,7 +51,7 @@ publishing {
pom {
name = libraryName
description = 'Java ImageIO APNG Plug-in'
url = 'https://github.com/Tianscar/apng-imageio'
url = 'https://github.com/Tianscar/imageio-apng'
licenses {
license {
name = 'GNU General Public License, version 2, with the Classpath Exception'
Expand All @@ -66,9 +66,9 @@ publishing {
}
}
scm {
connection = 'scm:git:[email protected]/Tianscar/apng-imageio.git'
developerConnection = 'scm:git:[email protected]/Tianscar/apng-imageio.git'
url = 'https://github.com/Tianscar/apng-imageio'
connection = 'scm:git:[email protected]/Tianscar/imageio-apng.git'
developerConnection = 'scm:git:[email protected]/Tianscar/imageio-apng.git'
url = 'https://github.com/Tianscar/imageio-apng'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = 'apng-imageio'
rootProject.name = 'imageio-apng'

36 changes: 16 additions & 20 deletions src/main/java/com/tianscar/imageio/plugins/png/PNG.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
package com.tianscar.imageio.plugins.png;

public final class PNG {
public interface PNG {

private PNG() {
throw new UnsupportedOperationException();
}
int PNG_COLOR_GRAY = 0;
int PNG_COLOR_RGB = 2;
int PNG_COLOR_PALETTE = 3;
int PNG_COLOR_GRAY_ALPHA = 4;
int PNG_COLOR_RGB_ALPHA = 6;

public static final int PNG_COLOR_GRAY = 0;
public static final int PNG_COLOR_RGB = 2;
public static final int PNG_COLOR_PALETTE = 3;
public static final int PNG_COLOR_GRAY_ALPHA = 4;
public static final int PNG_COLOR_RGB_ALPHA = 6;
int PNG_FILTER_NONE = 0;
int PNG_FILTER_SUB = 1;
int PNG_FILTER_UP = 2;
int PNG_FILTER_AVERAGE = 3;
int PNG_FILTER_PAETH = 4;

public static final int PNG_FILTER_NONE = 0;
public static final int PNG_FILTER_SUB = 1;
public static final int PNG_FILTER_UP = 2;
public static final int PNG_FILTER_AVERAGE = 3;
public static final int PNG_FILTER_PAETH = 4;
int APNG_DISPOSE_OP_NONE = 0;
int APNG_DISPOSE_OP_BACKGROUND = 1;
int APNG_DISPOSE_OP_PREVIOUS = 2;

public static final int APNG_DISPOSE_OP_NONE = 0;
public static final int APNG_DISPOSE_OP_BACKGROUND = 1;
public static final int APNG_DISPOSE_OP_PREVIOUS = 2;

public static final int APNG_BLEND_OP_SOURCE = 0;
public static final int APNG_BLEND_OP_OVER = 1;
int APNG_BLEND_OP_SOURCE = 0;
int APNG_BLEND_OP_OVER = 1;

}
Original file line number Diff line number Diff line change
Expand Up @@ -798,14 +798,14 @@ else if (isAnimated && chunkType == fcTL_TYPE) {
parse_fcTL_chunk();
}
else if (isAnimated && chunkType == fdAT_TYPE) {
int seqNumber = stream.readInt();
int sequenceNumber = stream.readInt();
stream.skipBytes(-12);
int index = nextImageIndex - 1;
if (!frameImageStartPositions.containsKey(index)) {
if (!frameMetadata.containsKey(index)) throw new IIOException("Required fcTL chunk missing");
PNGMetadata metadata = frameMetadata.get(index);
metadata.fdAT_present = true;
metadata.fdAT_sequence_number = seqNumber;
metadata.fdAT_sequence_number = sequenceNumber;
frameImageStartPositions.put(index, stream.getStreamPosition());
}
}
Expand Down Expand Up @@ -876,7 +876,7 @@ else if (chunkType == IDAT_TYPE) {
parse_fcTL_chunk();
break;
case fdAT_TYPE:
int seqNumber = stream.readInt();
int sequenceNumber = stream.readInt();

/*
* The PNG specification mandates that if colorType is
Expand All @@ -895,7 +895,7 @@ else if (chunkType == IDAT_TYPE) {
if (!frameMetadata.containsKey(index)) throw new IIOException("Required fcTL chunk missing");
PNGMetadata metadata = frameMetadata.get(index);
metadata.fdAT_present = true;
metadata.fdAT_sequence_number = seqNumber;
metadata.fdAT_sequence_number = sequenceNumber;
frameImageStartPositions.put(index, stream.getStreamPosition() - 12);
}
// Move to the CRC byte location.
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/tianscar/imageio/plugins/png/PNGImageWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ final class PNGfdATOutputStream extends PNGImageOutputStream {
(byte)'f', (byte)'d', (byte)'A', (byte)'T'
};

public int seqNumber;
private final byte[] seqNumberBuf = new byte[4];
public int sequenceNumber;
private final byte[] sequenceNumberBuf = new byte[4];

PNGfdATOutputStream(ImageOutputStream stream, int chunkLength, int deflaterLevel, int seqNumber) throws IOException {
PNGfdATOutputStream(ImageOutputStream stream, int chunkLength, int deflaterLevel, int sequenceNumber) throws IOException {
super(stream, chunkLength, deflaterLevel);
this.seqNumber = seqNumber;
this.sequenceNumber = sequenceNumber;

startChunk();
}
Expand All @@ -326,14 +326,14 @@ protected void startChunk() throws IOException {
crc.update(chunkType, 0, 4);
stream.write(chunkType, 0, 4);

seqNumberBuf[0] = (byte)(seqNumber >>> 24);
seqNumberBuf[1] = (byte)(seqNumber >>> 16);
seqNumberBuf[2] = (byte)(seqNumber >>> 8);
seqNumberBuf[3] = (byte)(seqNumber >>> 0);
sequenceNumberBuf[0] = (byte)(sequenceNumber >>> 24);
sequenceNumberBuf[1] = (byte)(sequenceNumber >>> 16);
sequenceNumberBuf[2] = (byte)(sequenceNumber >>> 8);
sequenceNumberBuf[3] = (byte)(sequenceNumber >>> 0);

crc.update(seqNumberBuf, 0, 4);
stream.writeInt(seqNumber);
seqNumber ++;
crc.update(sequenceNumberBuf, 0, 4);
stream.writeInt(sequenceNumber);
sequenceNumber ++;

this.bytesRemaining = chunkLength;
}
Expand Down Expand Up @@ -1204,7 +1204,7 @@ private void write_fdAT(RenderedImage image, int deflaterLevel, int currentSeque
}
} finally {
fos.finish();
nextSequenceNumber = fos.seqNumber;
nextSequenceNumber = fos.sequenceNumber;
}
}

Expand Down

0 comments on commit 824ebe1

Please sign in to comment.