src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
changeset 49996 39dc39093c5e
parent 47216 71c04702a3d5
equal deleted inserted replaced
49995:6f595ec05539 49996:39dc39093c5e
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   649         if (metadata.bKGD_present) {
   649         if (metadata.bKGD_present) {
   650             ChunkStream cs = new ChunkStream(PNGImageReader.bKGD_TYPE, stream);
   650             ChunkStream cs = new ChunkStream(PNGImageReader.bKGD_TYPE, stream);
   651             int colorType = metadata.IHDR_colorType & 0x3;
   651             int colorType = metadata.IHDR_colorType & 0x3;
   652             int chunkType = metadata.bKGD_colorType;
   652             int chunkType = metadata.bKGD_colorType;
   653 
   653 
       
   654             int chunkRed = metadata.bKGD_red;
       
   655             int chunkGreen = metadata.bKGD_green;
       
   656             int chunkBlue = metadata.bKGD_blue;
   654             // Special case: image is RGB(A) and chunk is Gray
   657             // Special case: image is RGB(A) and chunk is Gray
   655             // Promote chunk contents to RGB
   658             // Promote chunk contents to RGB
   656             int chunkRed = metadata.bKGD_red;
       
   657             int chunkGreen = metadata.bKGD_red;
       
   658             int chunkBlue = metadata.bKGD_red;
       
   659             if (colorType == PNGImageReader.PNG_COLOR_RGB &&
   659             if (colorType == PNGImageReader.PNG_COLOR_RGB &&
   660                 chunkType == PNGImageReader.PNG_COLOR_GRAY) {
   660                 chunkType == PNGImageReader.PNG_COLOR_GRAY) {
   661                 // Make a gray bKGD chunk look like RGB
   661                 // Make a gray bKGD chunk look like RGB
   662                 chunkType = colorType;
   662                 chunkType = colorType;
   663                 chunkRed = chunkGreen = chunkBlue =
   663                 chunkRed = chunkGreen = chunkBlue =