#772 Fix WebP animation transparent frame issue

(cherry picked from commit 822b5da631a581d1493e1ab0bbc3b847cecdef3c)
This commit is contained in:
Harald Kuhr 2023-06-05 11:41:03 +02:00
parent 5f1e746411
commit e5a82216d2

View File

@ -465,6 +465,8 @@ final class WebPImageReader extends ImageReaderBase {
} }
private void readVP8Extended(BufferedImage destination, ImageReadParam param, long streamEnd, final int width, final int height) throws IOException { private void readVP8Extended(BufferedImage destination, ImageReadParam param, long streamEnd, final int width, final int height) throws IOException {
boolean seenALPH = false;
while (imageInput.getStreamPosition() < streamEnd) { while (imageInput.getStreamPosition() < streamEnd) {
int nextChunk = imageInput.readInt(); int nextChunk = imageInput.readInt();
long chunkLength = imageInput.readUnsignedInt(); long chunkLength = imageInput.readUnsignedInt();
@ -484,6 +486,12 @@ final class WebPImageReader extends ImageReaderBase {
case WebP.CHUNK_VP8_: case WebP.CHUNK_VP8_:
readVP8(RasterUtils.asByteRaster(destination.getRaster()) readVP8(RasterUtils.asByteRaster(destination.getRaster())
.createWritableChild(0, 0, destination.getWidth(), destination.getHeight(), 0, 0, new int[] {0, 1, 2}), param); .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; break;
case WebP.CHUNK_VP8L: case WebP.CHUNK_VP8L: