src/share/classes/javax/imageio/IIOParam.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2001, 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


 420      * @see ImageReadParam#setDestinationBands
 421      * @see ImageReader#checkReadParamBandSettings
 422      */
 423     public void setSourceBands(int[] sourceBands) {
 424         if (sourceBands == null) {
 425             this.sourceBands = null;
 426         } else {
 427             int numBands = sourceBands.length;
 428             for (int i = 0; i < numBands; i++) {
 429                 int band = sourceBands[i];
 430                 if (band < 0) {
 431                     throw new IllegalArgumentException("Band value < 0!");
 432                 }
 433                 for (int j = i + 1; j < numBands; j++) {
 434                     if (band == sourceBands[j]) {
 435                         throw new IllegalArgumentException("Duplicate band value!");
 436                     }
 437                 }
 438 
 439             }
 440             this.sourceBands = (int[])(sourceBands.clone());
 441         }
 442     }
 443 
 444     /**
 445      * Returns the set of of source bands to be used. The returned
 446      * value is that set by the most recent call to
 447      * <code>setSourceBands</code>, or <code>null</code> if there have
 448      * been no calls to <code>setSourceBands</code>.
 449      *
 450      * <p> Semantically, the array returned is a copy; changes to
 451      * array contents subsequent to this call have no effect on this
 452      * <code>IIOParam</code>.
 453      *
 454      * @return the set of source bands to be used, or
 455      * <code>null</code>.
 456      *
 457      * @see #setSourceBands
 458      */
 459     public int[] getSourceBands() {
 460         if (sourceBands == null) {
 461             return null;
 462         }
 463         return (int[])(sourceBands.clone());
 464     }
 465 
 466     /**
 467      * Sets the desired image type for the destination image, using an
 468      * <code>ImageTypeSpecifier</code>.
 469      *
 470      * <p> When reading, if the layout of the destination has been set
 471      * using this method, each call to an <code>ImageReader</code>
 472      * <code>read</code> method will return a new
 473      * <code>BufferedImage</code> using the format specified by the
 474      * supplied type specifier.  As a side effect, any destination
 475      * <code>BufferedImage</code> set by
 476      * <code>ImageReadParam.setDestination(BufferedImage)</code> will
 477      * no longer be set as the destination.  In other words, this
 478      * method may be thought of as calling
 479      * <code>setDestination((BufferedImage)null)</code>.
 480      *
 481      * <p> When writing, the destination type maybe used to determine
 482      * the color type of the image.  The <code>SampleModel</code>
 483      * information will be ignored, and may be <code>null</code>.  For


   1 /*
   2  * Copyright (c) 2000, 2014, 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


 420      * @see ImageReadParam#setDestinationBands
 421      * @see ImageReader#checkReadParamBandSettings
 422      */
 423     public void setSourceBands(int[] sourceBands) {
 424         if (sourceBands == null) {
 425             this.sourceBands = null;
 426         } else {
 427             int numBands = sourceBands.length;
 428             for (int i = 0; i < numBands; i++) {
 429                 int band = sourceBands[i];
 430                 if (band < 0) {
 431                     throw new IllegalArgumentException("Band value < 0!");
 432                 }
 433                 for (int j = i + 1; j < numBands; j++) {
 434                     if (band == sourceBands[j]) {
 435                         throw new IllegalArgumentException("Duplicate band value!");
 436                     }
 437                 }
 438 
 439             }
 440             this.sourceBands = (sourceBands.clone());
 441         }
 442     }
 443 
 444     /**
 445      * Returns the set of of source bands to be used. The returned
 446      * value is that set by the most recent call to
 447      * <code>setSourceBands</code>, or <code>null</code> if there have
 448      * been no calls to <code>setSourceBands</code>.
 449      *
 450      * <p> Semantically, the array returned is a copy; changes to
 451      * array contents subsequent to this call have no effect on this
 452      * <code>IIOParam</code>.
 453      *
 454      * @return the set of source bands to be used, or
 455      * <code>null</code>.
 456      *
 457      * @see #setSourceBands
 458      */
 459     public int[] getSourceBands() {
 460         if (sourceBands == null) {
 461             return null;
 462         }
 463         return (sourceBands.clone());
 464     }
 465 
 466     /**
 467      * Sets the desired image type for the destination image, using an
 468      * <code>ImageTypeSpecifier</code>.
 469      *
 470      * <p> When reading, if the layout of the destination has been set
 471      * using this method, each call to an <code>ImageReader</code>
 472      * <code>read</code> method will return a new
 473      * <code>BufferedImage</code> using the format specified by the
 474      * supplied type specifier.  As a side effect, any destination
 475      * <code>BufferedImage</code> set by
 476      * <code>ImageReadParam.setDestination(BufferedImage)</code> will
 477      * no longer be set as the destination.  In other words, this
 478      * method may be thought of as calling
 479      * <code>setDestination((BufferedImage)null)</code>.
 480      *
 481      * <p> When writing, the destination type maybe used to determine
 482      * the color type of the image.  The <code>SampleModel</code>
 483      * information will be ignored, and may be <code>null</code>.  For