mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 12:05:29 -04:00
WebP minor bugfix and optimization.
(cherry picked from commit 1794e336dea71fe33cccccc3ce442d64de3f0ab8)
This commit is contained in:
parent
67b9e7df11
commit
f27b5700e8
@ -140,11 +140,10 @@ public final class VP8LDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a source raster into a destination raster with settings applied.
|
* Copy a source raster into a destination raster with optional settings applied.
|
||||||
*/
|
*/
|
||||||
public static void copyIntoRasterWithParams(final Raster srcRaster, final WritableRaster dstRaster,
|
public static void copyIntoRasterWithParams(final Raster srcRaster, final WritableRaster dstRaster, final ImageReadParam param) {
|
||||||
final ImageReadParam param) {
|
Rectangle sourceRegion = param != null && param.getSourceRegion() != null ? param.getSourceRegion() : srcRaster.getBounds();
|
||||||
Rectangle sourceRegion = param != null && param.getSourceRegion() != null ? param.getSourceRegion() : dstRaster.getBounds();
|
|
||||||
int sourceXSubsampling = param != null ? param.getSourceXSubsampling() : 1;
|
int sourceXSubsampling = param != null ? param.getSourceXSubsampling() : 1;
|
||||||
int sourceYSubsampling = param != null ? param.getSourceYSubsampling() : 1;
|
int sourceYSubsampling = param != null ? param.getSourceYSubsampling() : 1;
|
||||||
int subsamplingXOffset = param != null ? param.getSubsamplingXOffset() : 0;
|
int subsamplingXOffset = param != null ? param.getSubsamplingXOffset() : 0;
|
||||||
@ -156,13 +155,13 @@ public final class VP8LDecoder {
|
|||||||
dstRaster.setRect(destinationOffset.x, destinationOffset.y, srcRaster);
|
dstRaster.setRect(destinationOffset.x, destinationOffset.y, srcRaster);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Manual copy, more efficient way might exist
|
// Subsampled case
|
||||||
byte[] rgba = new byte[4];
|
byte[] rgba = new byte[4];
|
||||||
int xEnd = dstRaster.getWidth() + dstRaster.getMinX();
|
int xEnd = dstRaster.getWidth() + dstRaster.getMinX();
|
||||||
int yEnd = dstRaster.getHeight() + dstRaster.getMinY();
|
int yEnd = dstRaster.getHeight() + dstRaster.getMinY();
|
||||||
|
|
||||||
for (int xDst = destinationOffset.x, xSrc = sourceRegion.x + subsamplingXOffset; xDst < xEnd; xDst++, xSrc += sourceXSubsampling) {
|
for (int yDst = destinationOffset.y, ySrc = sourceRegion.y + subsamplingYOffset; yDst < yEnd; yDst++, ySrc += sourceYSubsampling) {
|
||||||
for (int yDst = destinationOffset.y, ySrc = sourceRegion.y + subsamplingYOffset; yDst < yEnd; yDst++, ySrc += sourceYSubsampling) {
|
for (int xDst = destinationOffset.x, xSrc = sourceRegion.x + subsamplingXOffset; xDst < xEnd; xDst++, xSrc += sourceXSubsampling) {
|
||||||
srcRaster.getDataElements(xSrc, ySrc, rgba);
|
srcRaster.getDataElements(xSrc, ySrc, rgba);
|
||||||
dstRaster.setDataElements(xDst, yDst, rgba);
|
dstRaster.setDataElements(xDst, yDst, rgba);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user