mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-01-24 00:00:05 -05:00
fix webp decoding using source region without subsampling
This commit is contained in:
committed by
Harald Kuhr
parent
355a916225
commit
340e79eb8a
@@ -148,8 +148,7 @@ public final class VP8LDecoder {
|
|||||||
if (param.getSourceRegion() != null && !param.getSourceRegion().contains(bounds) ||
|
if (param.getSourceRegion() != null && !param.getSourceRegion().contains(bounds) ||
|
||||||
param.getSourceXSubsampling() != 1 || param.getSourceYSubsampling() != 1) {
|
param.getSourceXSubsampling() != 1 || param.getSourceYSubsampling() != 1) {
|
||||||
// Can't reuse existing
|
// Can't reuse existing
|
||||||
return Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, bounds.width, bounds.height,
|
return createCompatibleRaster(raster, bounds.width, bounds.height);
|
||||||
4 * bounds.width, 4, new int[] {0, 1, 2, 3}, null);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bounds.setLocation(param.getDestinationOffset());
|
bounds.setLocation(param.getDestinationOffset());
|
||||||
@@ -159,8 +158,7 @@ public final class VP8LDecoder {
|
|||||||
|
|
||||||
if (!raster.getBounds().contains(bounds)) {
|
if (!raster.getBounds().contains(bounds)) {
|
||||||
// Can't reuse existing
|
// Can't reuse existing
|
||||||
return Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, bounds.width, bounds.height, 4 * bounds.width,
|
return createCompatibleRaster(raster, bounds.width, bounds.height);
|
||||||
4, new int[] {0, 1, 2, 3}, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return originSet ?
|
return originSet ?
|
||||||
@@ -169,6 +167,11 @@ public final class VP8LDecoder {
|
|||||||
raster;
|
raster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static WritableRaster createCompatibleRaster(WritableRaster src, int width, int height) {
|
||||||
|
SampleModel sampleModel = src.getSampleModel().createCompatibleSampleModel(width, height);
|
||||||
|
return Raster.createWritableRaster(sampleModel, sampleModel.createDataBuffer(), null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a source raster into a destination raster with optional settings applied.
|
* Copy a source raster into a destination raster with optional settings applied.
|
||||||
*/
|
*/
|
||||||
@@ -182,7 +185,8 @@ public final class VP8LDecoder {
|
|||||||
|
|
||||||
if (sourceXSubsampling == 1 && sourceYSubsampling == 1) {
|
if (sourceXSubsampling == 1 && sourceYSubsampling == 1) {
|
||||||
// Only apply offset (and limit to requested region)
|
// Only apply offset (and limit to requested region)
|
||||||
dstRaster.setRect(destinationOffset.x, destinationOffset.y, srcRaster);
|
dstRaster.setRect(destinationOffset.x, destinationOffset.y, srcRaster.createChild(
|
||||||
|
sourceRegion.x, sourceRegion.y, sourceRegion.width, sourceRegion.height, 0, 0, null));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Subsampled case
|
// Subsampled case
|
||||||
|
|||||||
Reference in New Issue
Block a user