1 /*
2 * Copyright (c) 1997, 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
200 * @param childMinX X coordinate of the upper left corner of
201 * the returned WritableRaster.
202 * @param childMinY Y coordinate of the upper left corner of
203 * the returned WritableRaster.
204 * @param bandList Array of band indices, or null to use all bands.
205 * @return a {@code WritableRaster} sharing all or part of the
206 * {@code DataBuffer} of this {@code WritableRaster}.
207 * @exception RasterFormatException if the subregion is outside of the
208 * raster bounds.
209 * @throws RasterFormatException if {@code w} or
210 * {@code h}
211 * is less than or equal to zero, or computing any of
212 * {@code parentX + w}, {@code parentY + h},
213 * {@code childMinX + w}, or
214 * {@code childMinY + h} results in integer
215 * overflow
216 */
217 public WritableRaster createWritableChild(int parentX, int parentY,
218 int w, int h,
219 int childMinX, int childMinY,
220 int bandList[]) {
221 if (parentX < this.minX) {
222 throw new RasterFormatException("parentX lies outside raster");
223 }
224 if (parentY < this.minY) {
225 throw new RasterFormatException("parentY lies outside raster");
226 }
227 if ((parentX+w < parentX) || (parentX+w > this.width + this.minX)) {
228 throw new RasterFormatException("(parentX + width) is outside raster");
229 }
230 if ((parentY+h < parentY) || (parentY+h > this.height + this.minY)) {
231 throw new RasterFormatException("(parentY + height) is outside raster");
232 }
233
234 SampleModel sm;
235 // Note: the SampleModel for the child Raster should have the same
236 // width and height as that for the parent, since it represents
237 // the physical layout of the pixel data. The child Raster's width
238 // and height represent a "virtual" view of the pixel data, so
239 // they may be different than those of the SampleModel.
240 if (bandList != null) {
487 dData);
488 setPixels(dstOffX, dstOffY+startY, width, 1, dData);
489 }
490 break;
491 }
492 }
493
494 /**
495 * Sets a pixel in the DataBuffer using an int array of samples for input.
496 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
497 * not in bounds.
498 * However, explicit bounds checking is not guaranteed.
499 * @param x The X coordinate of the pixel location.
500 * @param y The Y coordinate of the pixel location.
501 * @param iArray The input samples in a int array.
502 *
503 * @throws NullPointerException if iArray is null.
504 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
505 * in bounds, or if iArray is too small to hold the input.
506 */
507 public void setPixel(int x, int y, int iArray[]) {
508 sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
509 iArray,dataBuffer);
510 }
511
512 /**
513 * Sets a pixel in the DataBuffer using a float array of samples for input.
514 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
515 * not in bounds.
516 * However, explicit bounds checking is not guaranteed.
517 * @param x The X coordinate of the pixel location.
518 * @param y The Y coordinate of the pixel location.
519 * @param fArray The input samples in a float array.
520 *
521 * @throws NullPointerException if fArray is null.
522 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
523 * in bounds, or if fArray is too small to hold the input.
524 */
525 public void setPixel(int x, int y, float fArray[]) {
526 sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
527 fArray,dataBuffer);
528 }
529
530 /**
531 * Sets a pixel in the DataBuffer using a double array of samples for input.
532 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
533 * not in bounds.
534 * However, explicit bounds checking is not guaranteed.
535 * @param x The X coordinate of the pixel location.
536 * @param y The Y coordinate of the pixel location.
537 * @param dArray The input samples in a double array.
538 *
539 * @throws NullPointerException if dArray is null.
540 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
541 * in bounds, or if dArray is too small to hold the input.
542 */
543 public void setPixel(int x, int y, double dArray[]) {
544 sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
545 dArray,dataBuffer);
546 }
547
548 /**
549 * Sets all samples for a rectangle of pixels from an int array containing
550 * one sample per array element.
551 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
552 * not in bounds.
553 * However, explicit bounds checking is not guaranteed.
554 * @param x The X coordinate of the upper left pixel location.
555 * @param y The Y coordinate of the upper left pixel location.
556 * @param w Width of the pixel rectangle.
557 * @param h Height of the pixel rectangle.
558 * @param iArray The input int pixel array.
559 *
560 * @throws NullPointerException if iArray is null.
561 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
562 * in bounds, or if iArray is too small to hold the input.
563 */
564 public void setPixels(int x, int y, int w, int h, int iArray[]) {
565 sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
566 w,h,iArray,dataBuffer);
567 }
568
569 /**
570 * Sets all samples for a rectangle of pixels from a float array containing
571 * one sample per array element.
572 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
573 * not in bounds.
574 * However, explicit bounds checking is not guaranteed.
575 * @param x The X coordinate of the upper left pixel location.
576 * @param y The Y coordinate of the upper left pixel location.
577 * @param w Width of the pixel rectangle.
578 * @param h Height of the pixel rectangle.
579 * @param fArray The input float pixel array.
580 *
581 * @throws NullPointerException if fArray is null.
582 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
583 * in bounds, or if fArray is too small to hold the input.
584 */
585 public void setPixels(int x, int y, int w, int h, float fArray[]) {
586 sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
587 w,h,fArray,dataBuffer);
588 }
589
590 /**
591 * Sets all samples for a rectangle of pixels from a double array containing
592 * one sample per array element.
593 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
594 * not in bounds.
595 * However, explicit bounds checking is not guaranteed.
596 * @param x The X coordinate of the upper left pixel location.
597 * @param y The Y coordinate of the upper left pixel location.
598 * @param w Width of the pixel rectangle.
599 * @param h Height of the pixel rectangle.
600 * @param dArray The input double pixel array.
601 *
602 * @throws NullPointerException if dArray is null.
603 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
604 * in bounds, or if dArray is too small to hold the input.
605 */
606 public void setPixels(int x, int y, int w, int h, double dArray[]) {
607 sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
608 w,h,dArray,dataBuffer);
609 }
610
611 /**
612 * Sets a sample in the specified band for the pixel located at (x,y)
613 * in the DataBuffer using an int for input.
614 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
615 * not in bounds.
616 * However, explicit bounds checking is not guaranteed.
617 * @param x The X coordinate of the pixel location.
618 * @param y The Y coordinate of the pixel location.
619 * @param b The band to set.
620 * @param s The input sample.
621 *
622 * @throws ArrayIndexOutOfBoundsException if the coordinates or
623 * the band index are not in bounds.
624 */
625 public void setSample(int x, int y, int b, int s) {
626 sampleModel.setSample(x-sampleModelTranslateX,
668
669 /**
670 * Sets the samples in the specified band for the specified rectangle
671 * of pixels from an int array containing one sample per array element.
672 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
673 * not in bounds.
674 * However, explicit bounds checking is not guaranteed.
675 * @param x The X coordinate of the upper left pixel location.
676 * @param y The Y coordinate of the upper left pixel location.
677 * @param w Width of the pixel rectangle.
678 * @param h Height of the pixel rectangle.
679 * @param b The band to set.
680 * @param iArray The input int sample array.
681 *
682 * @throws NullPointerException if iArray is null.
683 * @throws ArrayIndexOutOfBoundsException if the coordinates or
684 * the band index are not in bounds, or if iArray is too small to
685 * hold the input.
686 */
687 public void setSamples(int x, int y, int w, int h, int b,
688 int iArray[]) {
689 sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
690 w,h,b,iArray,dataBuffer);
691 }
692
693 /**
694 * Sets the samples in the specified band for the specified rectangle
695 * of pixels from a float array containing one sample per array element.
696 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
697 * not in bounds.
698 * However, explicit bounds checking is not guaranteed.
699 * @param x The X coordinate of the upper left pixel location.
700 * @param y The Y coordinate of the upper left pixel location.
701 * @param w Width of the pixel rectangle.
702 * @param h Height of the pixel rectangle.
703 * @param b The band to set.
704 * @param fArray The input float sample array.
705 *
706 * @throws NullPointerException if fArray is null.
707 * @throws ArrayIndexOutOfBoundsException if the coordinates or
708 * the band index are not in bounds, or if fArray is too small to
709 * hold the input.
710 */
711 public void setSamples(int x, int y, int w, int h, int b,
712 float fArray[]) {
713 sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
714 w,h,b,fArray,dataBuffer);
715 }
716
717 /**
718 * Sets the samples in the specified band for the specified rectangle
719 * of pixels from a double array containing one sample per array element.
720 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
721 * not in bounds.
722 * However, explicit bounds checking is not guaranteed.
723 * @param x The X coordinate of the upper left pixel location.
724 * @param y The Y coordinate of the upper left pixel location.
725 * @param w Width of the pixel rectangle.
726 * @param h Height of the pixel rectangle.
727 * @param b The band to set.
728 * @param dArray The input double sample array.
729 *
730 * @throws NullPointerException if dArray is null.
731 * @throws ArrayIndexOutOfBoundsException if the coordinates or
732 * the band index are not in bounds, or if dArray is too small to
733 * hold the input.
734 */
735 public void setSamples(int x, int y, int w, int h, int b,
736 double dArray[]) {
737 sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
738 w,h,b,dArray,dataBuffer);
739 }
740
741 }
|
1 /*
2 * Copyright (c) 1997, 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
200 * @param childMinX X coordinate of the upper left corner of
201 * the returned WritableRaster.
202 * @param childMinY Y coordinate of the upper left corner of
203 * the returned WritableRaster.
204 * @param bandList Array of band indices, or null to use all bands.
205 * @return a {@code WritableRaster} sharing all or part of the
206 * {@code DataBuffer} of this {@code WritableRaster}.
207 * @exception RasterFormatException if the subregion is outside of the
208 * raster bounds.
209 * @throws RasterFormatException if {@code w} or
210 * {@code h}
211 * is less than or equal to zero, or computing any of
212 * {@code parentX + w}, {@code parentY + h},
213 * {@code childMinX + w}, or
214 * {@code childMinY + h} results in integer
215 * overflow
216 */
217 public WritableRaster createWritableChild(int parentX, int parentY,
218 int w, int h,
219 int childMinX, int childMinY,
220 int[] bandList) {
221 if (parentX < this.minX) {
222 throw new RasterFormatException("parentX lies outside raster");
223 }
224 if (parentY < this.minY) {
225 throw new RasterFormatException("parentY lies outside raster");
226 }
227 if ((parentX+w < parentX) || (parentX+w > this.width + this.minX)) {
228 throw new RasterFormatException("(parentX + width) is outside raster");
229 }
230 if ((parentY+h < parentY) || (parentY+h > this.height + this.minY)) {
231 throw new RasterFormatException("(parentY + height) is outside raster");
232 }
233
234 SampleModel sm;
235 // Note: the SampleModel for the child Raster should have the same
236 // width and height as that for the parent, since it represents
237 // the physical layout of the pixel data. The child Raster's width
238 // and height represent a "virtual" view of the pixel data, so
239 // they may be different than those of the SampleModel.
240 if (bandList != null) {
487 dData);
488 setPixels(dstOffX, dstOffY+startY, width, 1, dData);
489 }
490 break;
491 }
492 }
493
494 /**
495 * Sets a pixel in the DataBuffer using an int array of samples for input.
496 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
497 * not in bounds.
498 * However, explicit bounds checking is not guaranteed.
499 * @param x The X coordinate of the pixel location.
500 * @param y The Y coordinate of the pixel location.
501 * @param iArray The input samples in a int array.
502 *
503 * @throws NullPointerException if iArray is null.
504 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
505 * in bounds, or if iArray is too small to hold the input.
506 */
507 public void setPixel(int x, int y, int[] iArray) {
508 sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
509 iArray,dataBuffer);
510 }
511
512 /**
513 * Sets a pixel in the DataBuffer using a float array of samples for input.
514 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
515 * not in bounds.
516 * However, explicit bounds checking is not guaranteed.
517 * @param x The X coordinate of the pixel location.
518 * @param y The Y coordinate of the pixel location.
519 * @param fArray The input samples in a float array.
520 *
521 * @throws NullPointerException if fArray is null.
522 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
523 * in bounds, or if fArray is too small to hold the input.
524 */
525 public void setPixel(int x, int y, float[] fArray) {
526 sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
527 fArray,dataBuffer);
528 }
529
530 /**
531 * Sets a pixel in the DataBuffer using a double array of samples for input.
532 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
533 * not in bounds.
534 * However, explicit bounds checking is not guaranteed.
535 * @param x The X coordinate of the pixel location.
536 * @param y The Y coordinate of the pixel location.
537 * @param dArray The input samples in a double array.
538 *
539 * @throws NullPointerException if dArray is null.
540 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
541 * in bounds, or if dArray is too small to hold the input.
542 */
543 public void setPixel(int x, int y, double[] dArray) {
544 sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
545 dArray,dataBuffer);
546 }
547
548 /**
549 * Sets all samples for a rectangle of pixels from an int array containing
550 * one sample per array element.
551 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
552 * not in bounds.
553 * However, explicit bounds checking is not guaranteed.
554 * @param x The X coordinate of the upper left pixel location.
555 * @param y The Y coordinate of the upper left pixel location.
556 * @param w Width of the pixel rectangle.
557 * @param h Height of the pixel rectangle.
558 * @param iArray The input int pixel array.
559 *
560 * @throws NullPointerException if iArray is null.
561 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
562 * in bounds, or if iArray is too small to hold the input.
563 */
564 public void setPixels(int x, int y, int w, int h, int[] iArray) {
565 sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
566 w,h,iArray,dataBuffer);
567 }
568
569 /**
570 * Sets all samples for a rectangle of pixels from a float array containing
571 * one sample per array element.
572 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
573 * not in bounds.
574 * However, explicit bounds checking is not guaranteed.
575 * @param x The X coordinate of the upper left pixel location.
576 * @param y The Y coordinate of the upper left pixel location.
577 * @param w Width of the pixel rectangle.
578 * @param h Height of the pixel rectangle.
579 * @param fArray The input float pixel array.
580 *
581 * @throws NullPointerException if fArray is null.
582 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
583 * in bounds, or if fArray is too small to hold the input.
584 */
585 public void setPixels(int x, int y, int w, int h, float[] fArray) {
586 sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
587 w,h,fArray,dataBuffer);
588 }
589
590 /**
591 * Sets all samples for a rectangle of pixels from a double array containing
592 * one sample per array element.
593 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
594 * not in bounds.
595 * However, explicit bounds checking is not guaranteed.
596 * @param x The X coordinate of the upper left pixel location.
597 * @param y The Y coordinate of the upper left pixel location.
598 * @param w Width of the pixel rectangle.
599 * @param h Height of the pixel rectangle.
600 * @param dArray The input double pixel array.
601 *
602 * @throws NullPointerException if dArray is null.
603 * @throws ArrayIndexOutOfBoundsException if the coordinates are not
604 * in bounds, or if dArray is too small to hold the input.
605 */
606 public void setPixels(int x, int y, int w, int h, double[] dArray) {
607 sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
608 w,h,dArray,dataBuffer);
609 }
610
611 /**
612 * Sets a sample in the specified band for the pixel located at (x,y)
613 * in the DataBuffer using an int for input.
614 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
615 * not in bounds.
616 * However, explicit bounds checking is not guaranteed.
617 * @param x The X coordinate of the pixel location.
618 * @param y The Y coordinate of the pixel location.
619 * @param b The band to set.
620 * @param s The input sample.
621 *
622 * @throws ArrayIndexOutOfBoundsException if the coordinates or
623 * the band index are not in bounds.
624 */
625 public void setSample(int x, int y, int b, int s) {
626 sampleModel.setSample(x-sampleModelTranslateX,
668
669 /**
670 * Sets the samples in the specified band for the specified rectangle
671 * of pixels from an int array containing one sample per array element.
672 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
673 * not in bounds.
674 * However, explicit bounds checking is not guaranteed.
675 * @param x The X coordinate of the upper left pixel location.
676 * @param y The Y coordinate of the upper left pixel location.
677 * @param w Width of the pixel rectangle.
678 * @param h Height of the pixel rectangle.
679 * @param b The band to set.
680 * @param iArray The input int sample array.
681 *
682 * @throws NullPointerException if iArray is null.
683 * @throws ArrayIndexOutOfBoundsException if the coordinates or
684 * the band index are not in bounds, or if iArray is too small to
685 * hold the input.
686 */
687 public void setSamples(int x, int y, int w, int h, int b,
688 int[] iArray) {
689 sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
690 w,h,b,iArray,dataBuffer);
691 }
692
693 /**
694 * Sets the samples in the specified band for the specified rectangle
695 * of pixels from a float array containing one sample per array element.
696 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
697 * not in bounds.
698 * However, explicit bounds checking is not guaranteed.
699 * @param x The X coordinate of the upper left pixel location.
700 * @param y The Y coordinate of the upper left pixel location.
701 * @param w Width of the pixel rectangle.
702 * @param h Height of the pixel rectangle.
703 * @param b The band to set.
704 * @param fArray The input float sample array.
705 *
706 * @throws NullPointerException if fArray is null.
707 * @throws ArrayIndexOutOfBoundsException if the coordinates or
708 * the band index are not in bounds, or if fArray is too small to
709 * hold the input.
710 */
711 public void setSamples(int x, int y, int w, int h, int b,
712 float[] fArray) {
713 sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
714 w,h,b,fArray,dataBuffer);
715 }
716
717 /**
718 * Sets the samples in the specified band for the specified rectangle
719 * of pixels from a double array containing one sample per array element.
720 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
721 * not in bounds.
722 * However, explicit bounds checking is not guaranteed.
723 * @param x The X coordinate of the upper left pixel location.
724 * @param y The Y coordinate of the upper left pixel location.
725 * @param w Width of the pixel rectangle.
726 * @param h Height of the pixel rectangle.
727 * @param b The band to set.
728 * @param dArray The input double sample array.
729 *
730 * @throws NullPointerException if dArray is null.
731 * @throws ArrayIndexOutOfBoundsException if the coordinates or
732 * the band index are not in bounds, or if dArray is too small to
733 * hold the input.
734 */
735 public void setSamples(int x, int y, int w, int h, int b,
736 double[] dArray) {
737 sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
738 w,h,b,dArray,dataBuffer);
739 }
740
741 }
|