117 } 118 119 vals[offset] = firstDst; 120 121 // If we never saw a valid pixel, set width to 0 122 if (!gotPixel) { 123 vals[offset + 2] = 0; 124 } else { 125 vals[offset + 2] = lastDst - firstDst + 1; 126 } 127 128 // The period is given by the difference of any two adjacent pixels 129 vals[offset + 4] = Math.max(secondDst - firstDst, 1); 130 } 131 132 /** 133 * A utility method that computes the exact set of destination 134 * pixels that will be written during a particular decoding pass. 135 * The intent is to simplify the work done by readers in combining 136 * the source region, source subsampling, and destination offset 137 * information obtained from the <code>ImageReadParam</code> with 138 * the offsets and periods of a progressive or interlaced decoding 139 * pass. 140 * 141 * @param sourceRegion a <code>Rectangle</code> containing the 142 * source region being read, offset by the source subsampling 143 * offsets, and clipped against the source bounds, as returned by 144 * the <code>getSourceRegion</code> method. 145 * @param destinationOffset a <code>Point</code> containing the 146 * coordinates of the upper-left pixel to be written in the 147 * destination. 148 * @param dstMinX the smallest X coordinate (inclusive) of the 149 * destination <code>Raster</code>. 150 * @param dstMinY the smallest Y coordinate (inclusive) of the 151 * destination <code>Raster</code>. 152 * @param dstMaxX the largest X coordinate (inclusive) of the destination 153 * <code>Raster</code>. 154 * @param dstMaxY the largest Y coordinate (inclusive) of the destination 155 * <code>Raster</code>. 156 * @param sourceXSubsampling the X subsampling factor. 157 * @param sourceYSubsampling the Y subsampling factor. 158 * @param passXStart the smallest source X coordinate (inclusive) 159 * of the current progressive pass. 160 * @param passYStart the smallest source Y coordinate (inclusive) 161 * of the current progressive pass. 162 * @param passWidth the width in pixels of the current progressive 163 * pass. 164 * @param passHeight the height in pixels of the current progressive 165 * pass. 166 * @param passPeriodX the X period (horizontal spacing between 167 * pixels) of the current progressive pass. 168 * @param passPeriodY the Y period (vertical spacing between 169 * pixels) of the current progressive pass. 170 * 171 * @return an array of 6 <code>int</code>s containing the 172 * destination min X, min Y, width, height, X period and Y period 173 * of the region that will be updated. 174 */ 175 public static int[] computeUpdatedPixels(Rectangle sourceRegion, 176 Point destinationOffset, 177 int dstMinX, 178 int dstMinY, 179 int dstMaxX, 180 int dstMaxY, 181 int sourceXSubsampling, 182 int sourceYSubsampling, 183 int passXStart, 184 int passYStart, 185 int passWidth, 186 int passHeight, 187 int passPeriodX, 188 int passPeriodY) 189 { 190 int[] vals = new int[6]; 191 computeUpdatedPixels(sourceRegion.x, sourceRegion.width, | 117 } 118 119 vals[offset] = firstDst; 120 121 // If we never saw a valid pixel, set width to 0 122 if (!gotPixel) { 123 vals[offset + 2] = 0; 124 } else { 125 vals[offset + 2] = lastDst - firstDst + 1; 126 } 127 128 // The period is given by the difference of any two adjacent pixels 129 vals[offset + 4] = Math.max(secondDst - firstDst, 1); 130 } 131 132 /** 133 * A utility method that computes the exact set of destination 134 * pixels that will be written during a particular decoding pass. 135 * The intent is to simplify the work done by readers in combining 136 * the source region, source subsampling, and destination offset 137 * information obtained from the {@code ImageReadParam} with 138 * the offsets and periods of a progressive or interlaced decoding 139 * pass. 140 * 141 * @param sourceRegion a {@code Rectangle} containing the 142 * source region being read, offset by the source subsampling 143 * offsets, and clipped against the source bounds, as returned by 144 * the {@code getSourceRegion} method. 145 * @param destinationOffset a {@code Point} containing the 146 * coordinates of the upper-left pixel to be written in the 147 * destination. 148 * @param dstMinX the smallest X coordinate (inclusive) of the 149 * destination {@code Raster}. 150 * @param dstMinY the smallest Y coordinate (inclusive) of the 151 * destination {@code Raster}. 152 * @param dstMaxX the largest X coordinate (inclusive) of the destination 153 * {@code Raster}. 154 * @param dstMaxY the largest Y coordinate (inclusive) of the destination 155 * {@code Raster}. 156 * @param sourceXSubsampling the X subsampling factor. 157 * @param sourceYSubsampling the Y subsampling factor. 158 * @param passXStart the smallest source X coordinate (inclusive) 159 * of the current progressive pass. 160 * @param passYStart the smallest source Y coordinate (inclusive) 161 * of the current progressive pass. 162 * @param passWidth the width in pixels of the current progressive 163 * pass. 164 * @param passHeight the height in pixels of the current progressive 165 * pass. 166 * @param passPeriodX the X period (horizontal spacing between 167 * pixels) of the current progressive pass. 168 * @param passPeriodY the Y period (vertical spacing between 169 * pixels) of the current progressive pass. 170 * 171 * @return an array of 6 {@code int}s containing the 172 * destination min X, min Y, width, height, X period and Y period 173 * of the region that will be updated. 174 */ 175 public static int[] computeUpdatedPixels(Rectangle sourceRegion, 176 Point destinationOffset, 177 int dstMinX, 178 int dstMinY, 179 int dstMaxX, 180 int dstMaxY, 181 int sourceXSubsampling, 182 int sourceYSubsampling, 183 int passXStart, 184 int passYStart, 185 int passWidth, 186 int passHeight, 187 int passPeriodX, 188 int passPeriodY) 189 { 190 int[] vals = new int[6]; 191 computeUpdatedPixels(sourceRegion.x, sourceRegion.width, |