1 7 8 package javax.imageio; 9 10 import java.awt.Dimension ; 11 import java.awt.image.BufferedImage ; 12 13 113 public class ImageReadParam extends IIOParam { 114 115 125 protected boolean canSetSourceRenderSize = false; 126 127 135 protected Dimension sourceRenderSize = null; 136 137 142 protected BufferedImage destination = null; 143 144 149 protected int[] destinationBands = null; 150 151 160 protected int minProgressivePass = 0; 161 162 174 protected int numProgressivePasses = Integer.MAX_VALUE; 175 176 179 public ImageReadParam() {} 180 181 public void setDestinationType(ImageTypeSpecifier destinationType) { 183 super.setDestinationType(destinationType); 184 setDestination(null); 185 } 186 187 214 public void setDestination(BufferedImage destination) { 215 this.destination = destination; 216 } 217 218 227 public BufferedImage getDestination() { 228 return destination; 229 } 230 231 264 public void setDestinationBands(int[] destinationBands) { 265 if (destinationBands == null) { 266 this.destinationBands = null; 267 } else { 268 int numBands = destinationBands.length; 269 for (int i = 0; i < numBands; i++) { 270 int band = destinationBands[i]; 271 if (band < 0) { 272 throw new IllegalArgumentException ("Band value < 0!"); 273 } 274 for (int j = i + 1; j < numBands; j++) { 275 if (band == destinationBands[j]) { 276 throw new IllegalArgumentException ("Duplicate band value!"); 277 } 278 } 279 } 280 this.destinationBands = (int[])destinationBands.clone(); 281 } 282 } 283 284 294 public int[] getDestinationBands() { 295 if (destinationBands == null) { 296 return null; 297 } else { 298 return (int[])(destinationBands.clone()); 299 } 300 } 301 302 316 public boolean canSetSourceRenderSize() { 317 return canSetSourceRenderSize; 318 } 319 320 355 public void setSourceRenderSize(Dimension size) 356 throws UnsupportedOperationException { 357 if (!canSetSourceRenderSize()) { 358 throw new UnsupportedOperationException 359 ("Can't set source render size!"); 360 } 361 362 if (size == null) { 363 this.sourceRenderSize = null; 364 } else { 365 if (size.width <= 0 || size.height <= 0) { 366 throw new IllegalArgumentException ("width or height <= 0!"); 367 } 368 this.sourceRenderSize = (Dimension )size.clone(); 369 } 370 } 371 372 383 public Dimension getSourceRenderSize() { 384 return (sourceRenderSize == null) ? 385 null : (Dimension )sourceRenderSize.clone(); 386 } 387 388 428 public void setSourceProgressivePasses(int minPass, int numPasses) { 429 if (minPass < 0) { 430 throw new IllegalArgumentException ("minPass < 0!"); 431 } 432 if (numPasses <= 0) { 433 throw new IllegalArgumentException ("numPasses <= 0!"); 434 } 435 if ((numPasses != Integer.MAX_VALUE) && 436 (((minPass + numPasses - 1) & 0x80000000) != 0)) { 437 throw new IllegalArgumentException 438 ("minPass + numPasses - 1 > INTEGER.MAX_VALUE!"); 439 } 440 441 this.minProgressivePass = minPass; 442 this.numProgressivePasses = numPasses; 443 } 444 445 455 public int getSourceMinProgressivePass() { 456 return minProgressivePass; 457 } 458 459 469 public int getSourceMaxProgressivePass() { 470 if (numProgressivePasses == Integer.MAX_VALUE) { 471 return Integer.MAX_VALUE; 472 } else { 473 return minProgressivePass + numProgressivePasses - 1; 474 } 475 } 476 477 488 public int getSourceNumProgressivePasses() { 489 return numProgressivePasses; 490 } 491 } 492 | Popular Tags |