< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1031           ReaderUtil.computeUpdatedPixels(sourceRegion,
1032                                           destinationOffset,
1033                                           dstMinX, dstMinY,
1034                                           dstMaxX, dstMaxY,
1035                                           sourceXSubsampling,
1036                                           sourceYSubsampling,
1037                                           xStart, yStart,
1038                                           passWidth, passHeight,
1039                                           xStep, yStep);
1040         int updateMinX = vals[0];
1041         int updateMinY = vals[1];
1042         int updateWidth = vals[2];
1043         int updateXStep = vals[4];
1044         int updateYStep = vals[5];
1045 
1046         int bitDepth = metadata.IHDR_bitDepth;
1047         int inputBands = inputBandsForColorType[metadata.IHDR_colorType];
1048         int bytesPerPixel = (bitDepth == 16) ? 2 : 1;
1049         bytesPerPixel *= inputBands;
1050 
1051         int bytesPerRow = (inputBands*passWidth*bitDepth + 7)/8;

1052         int eltsPerRow = (bitDepth == 16) ? bytesPerRow/2 : bytesPerRow;
1053 
1054         // If no pixels need updating, just skip the input data
1055         if (updateWidth == 0) {
1056             for (int srcY = 0; srcY < passHeight; srcY++) {
1057                 // Update count of pixels read
1058                 updateImageProgress(passWidth);
1059                 /*
1060                  * If read has been aborted, just return
1061                  * processReadAborted will be called later
1062                  */
1063                 if (abortRequested()) {
1064                     return;
1065                 }
1066                 // Skip filter byte and the remaining row bytes
1067                 pixelStream.skipBytes(1 + bytesPerRow);
1068             }
1069             return;
1070         }
1071 


   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1031           ReaderUtil.computeUpdatedPixels(sourceRegion,
1032                                           destinationOffset,
1033                                           dstMinX, dstMinY,
1034                                           dstMaxX, dstMaxY,
1035                                           sourceXSubsampling,
1036                                           sourceYSubsampling,
1037                                           xStart, yStart,
1038                                           passWidth, passHeight,
1039                                           xStep, yStep);
1040         int updateMinX = vals[0];
1041         int updateMinY = vals[1];
1042         int updateWidth = vals[2];
1043         int updateXStep = vals[4];
1044         int updateYStep = vals[5];
1045 
1046         int bitDepth = metadata.IHDR_bitDepth;
1047         int inputBands = inputBandsForColorType[metadata.IHDR_colorType];
1048         int bytesPerPixel = (bitDepth == 16) ? 2 : 1;
1049         bytesPerPixel *= inputBands;
1050 
1051         int bitsPerRow = Math.multiplyExact((inputBands * bitDepth), passWidth);
1052         int bytesPerRow = (bitsPerRow + 7) / 8;
1053         int eltsPerRow = (bitDepth == 16) ? bytesPerRow/2 : bytesPerRow;
1054 
1055         // If no pixels need updating, just skip the input data
1056         if (updateWidth == 0) {
1057             for (int srcY = 0; srcY < passHeight; srcY++) {
1058                 // Update count of pixels read
1059                 updateImageProgress(passWidth);
1060                 /*
1061                  * If read has been aborted, just return
1062                  * processReadAborted will be called later
1063                  */
1064                 if (abortRequested()) {
1065                     return;
1066                 }
1067                 // Skip filter byte and the remaining row bytes
1068                 pixelStream.skipBytes(1 + bytesPerRow);
1069             }
1070             return;
1071         }
1072 


< prev index next >