TJ/xform: Check crop region against dest. image

Lossless cropping is performed after other lossless transform
operations, so the cropping region must be specified relative to the
destination image dimensions and level of chrominance subsampling, not
the source image dimensions and level of chrominance subsampling.

More specifically, if the lossless transform operation swaps the X and Y
axes, or if the image is converted to grayscale, then that changes the
cropping region requirements.
This commit is contained in:
DRC
2024-08-31 12:41:13 -04:00
parent 8456d2b98c
commit 9983840eb6
13 changed files with 54 additions and 35 deletions

View File

@@ -165,10 +165,11 @@ public class TJTransform extends Rectangle {
*
* @param x the left boundary of the cropping region. This must be evenly
* divisible by the iMCU width (see {@link TJ#getMCUWidth TJ.getMCUWidth()})
* of the destination image.
*
* @param y the upper boundary of the cropping region. This must be evenly
* divisible by the iMCU height (see {@link TJ#getMCUHeight
* TJ.getMCUHeight()})
* TJ.getMCUHeight()}) of the destination image.
*
* @param w the width of the cropping region. Setting this to 0 is the
* equivalent of setting it to (width of the source JPEG image -