1020 ReaderUtil.computeUpdatedPixels(sourceRegion,
1021 destinationOffset,
1022 dstMinX, dstMinY,
1023 dstMaxX, dstMaxY,
1024 sourceXSubsampling,
1025 sourceYSubsampling,
1026 xStart, yStart,
1027 passWidth, passHeight,
1028 xStep, yStep);
1029 int updateMinX = vals[0];
1030 int updateMinY = vals[1];
1031 int updateWidth = vals[2];
1032 int updateXStep = vals[4];
1033 int updateYStep = vals[5];
1034
1035 int bitDepth = metadata.IHDR_bitDepth;
1036 int inputBands = inputBandsForColorType[metadata.IHDR_colorType];
1037 int bytesPerPixel = (bitDepth == 16) ? 2 : 1;
1038 bytesPerPixel *= inputBands;
1039
1040 int bytesPerRow = (inputBands*passWidth*bitDepth + 7)/8;
1041 int eltsPerRow = (bitDepth == 16) ? bytesPerRow/2 : bytesPerRow;
1042
1043 // If no pixels need updating, just skip the input data
1044 if (updateWidth == 0) {
1045 for (int srcY = 0; srcY < passHeight; srcY++) {
1046 // Update count of pixels read
1047 updateImageProgress(passWidth);
1048 /*
1049 * If read has been aborted, just return
1050 * processReadAborted will be called later
1051 */
1052 if (abortRequested()) {
1053 return;
1054 }
1055 // Skip filter byte and the remaining row bytes
1056 pixelStream.skipBytes(1 + bytesPerRow);
1057 }
1058 return;
1059 }
1060
|
1020 ReaderUtil.computeUpdatedPixels(sourceRegion,
1021 destinationOffset,
1022 dstMinX, dstMinY,
1023 dstMaxX, dstMaxY,
1024 sourceXSubsampling,
1025 sourceYSubsampling,
1026 xStart, yStart,
1027 passWidth, passHeight,
1028 xStep, yStep);
1029 int updateMinX = vals[0];
1030 int updateMinY = vals[1];
1031 int updateWidth = vals[2];
1032 int updateXStep = vals[4];
1033 int updateYStep = vals[5];
1034
1035 int bitDepth = metadata.IHDR_bitDepth;
1036 int inputBands = inputBandsForColorType[metadata.IHDR_colorType];
1037 int bytesPerPixel = (bitDepth == 16) ? 2 : 1;
1038 bytesPerPixel *= inputBands;
1039
1040 /*
1041 * When we multiply passWidth with inputBands/bitDepth if the
1042 * resultant value exceeds maximum value for int, bufferoverflow happens
1043 * and the value will be invalid. So until we calculate bytesPerRow
1044 * value by dividing it by 8 we can maintain bitsPerRow value in long
1045 * so that final bytesPerRow value is valid.
1046 */
1047 long bitsPerRow = ((long)inputBands) * passWidth * bitDepth;
1048 int bytesPerRow = (int)((bitsPerRow + 7)/8);
1049 int eltsPerRow = (bitDepth == 16) ? bytesPerRow/2 : bytesPerRow;
1050
1051 // If no pixels need updating, just skip the input data
1052 if (updateWidth == 0) {
1053 for (int srcY = 0; srcY < passHeight; srcY++) {
1054 // Update count of pixels read
1055 updateImageProgress(passWidth);
1056 /*
1057 * If read has been aborted, just return
1058 * processReadAborted will be called later
1059 */
1060 if (abortRequested()) {
1061 return;
1062 }
1063 // Skip filter byte and the remaining row bytes
1064 pixelStream.skipBytes(1 + bytesPerRow);
1065 }
1066 return;
1067 }
1068
|