Skip to content

Commit

Permalink
#772 Fix WebP animation transparent frame issue
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldk committed Jun 5, 2023
1 parent c785f69 commit 822b5da
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ private void readVP8Extended(BufferedImage destination, ImageReadParam param, lo
}

private void readVP8Extended(BufferedImage destination, ImageReadParam param, long streamEnd, final int width, final int height) throws IOException {
boolean seenALPH = false;

while (imageInput.getStreamPosition() < streamEnd) {
int nextChunk = imageInput.readInt();
long chunkLength = imageInput.readUnsignedInt();
Expand All @@ -484,6 +486,12 @@ private void readVP8Extended(BufferedImage destination, ImageReadParam param, lo
case WebP.CHUNK_VP8_:
readVP8(RasterUtils.asByteRaster(destination.getRaster())
.createWritableChild(0, 0, destination.getWidth(), destination.getHeight(), 0, 0, new int[] {0, 1, 2}), param);

if (header.containsALPH && !seenALPH) {
// May happen for animation frames, if some frames are fully opaque
opaqueAlpha(destination.getAlphaRaster());
}

break;

case WebP.CHUNK_VP8L:
Expand Down

0 comments on commit 822b5da

Please sign in to comment.