gwlucastrig commented on code in PR #334:
URL: https://github.com/apache/commons-imaging/pull/334#discussion_r1391160794
##########
src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java:
##########
@@ -452,9 +454,21 @@ public void visitSos(final int marker, final byte[]
markerBytes, final byte[] im
Allocator.check(Integer.BYTES * sofnSegment.width *
sofnSegment.height);
switch (sofnSegment.numberOfComponents) {
case 4:
- colorModel = new DirectColorModel(24, 0x00ff0000, 0x0000ff00,
0x000000ff);
- final int[] bandMasks = { 0x00ff0000, 0x0000ff00, 0x000000ff };
- raster = Raster.createPackedRaster(DataBuffer.TYPE_INT,
sofnSegment.width, sofnSegment.height, bandMasks, null);
+ // Special handling for the application-RGB case: TIFF files
with
+ // JPEG compression can support an alpha channel. This
extension
+ // to the JPEG standard is implemented by specifying a color
model
+ // with a fourth channel for alpha.
+ if (useTiffRgb) {
+ colorModel = new DirectColorModel(32, 0x00ff0000,
0x0000ff00, 0x000000ff, 0xff000000);
+ final int[] bandMasks = {0x00ff0000, 0x0000ff00,
0x000000ff, 0xff000000};
Review Comment:
These do operate as constants, so I will define these masks as static final
constants. I wanted to change as little code as possible and maintain the
coding style used in the original. Should I also modify the legacy code?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]