< prev index next >

src/java.desktop/share/classes/java/awt/image/SinglePixelPackedSampleModel.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 64,80 **** */ public class SinglePixelPackedSampleModel extends SampleModel { /** Bit masks for all bands of the image data. */ ! private int bitMasks[]; /** Bit Offsets for all bands of the image data. */ ! private int bitOffsets[]; /** Bit sizes for all the bands of the image data. */ ! private int bitSizes[]; /** Maximum bit size. */ private int maxBitSize; /** Line stride of the region of image data described by this --- 64,80 ---- */ public class SinglePixelPackedSampleModel extends SampleModel { /** Bit masks for all bands of the image data. */ ! private int[] bitMasks; /** Bit Offsets for all bands of the image data. */ ! private int[] bitOffsets; /** Bit sizes for all the bands of the image data. */ ! private int[] bitSizes; /** Maximum bit size. */ private int maxBitSize; /** Line stride of the region of image data described by this
*** 104,114 **** * either {@code DataBuffer.TYPE_BYTE}, * {@code DataBuffer.TYPE_USHORT}, or * {@code DataBuffer.TYPE_INT} */ public SinglePixelPackedSampleModel(int dataType, int w, int h, ! int bitMasks[]) { this(dataType, w, h, w, bitMasks); if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT && dataType != DataBuffer.TYPE_INT) { throw new IllegalArgumentException("Unsupported data type "+ --- 104,114 ---- * either {@code DataBuffer.TYPE_BYTE}, * {@code DataBuffer.TYPE_USHORT}, or * {@code DataBuffer.TYPE_INT} */ public SinglePixelPackedSampleModel(int dataType, int w, int h, ! int[] bitMasks) { this(dataType, w, h, w, bitMasks); if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT && dataType != DataBuffer.TYPE_INT) { throw new IllegalArgumentException("Unsupported data type "+
*** 138,148 **** * either {@code DataBuffer.TYPE_BYTE}, * {@code DataBuffer.TYPE_USHORT}, or * {@code DataBuffer.TYPE_INT} */ public SinglePixelPackedSampleModel(int dataType, int w, int h, ! int scanlineStride, int bitMasks[]) { super(dataType, w, h, bitMasks.length); if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT && dataType != DataBuffer.TYPE_INT) { throw new IllegalArgumentException("Unsupported data type "+ --- 138,148 ---- * either {@code DataBuffer.TYPE_BYTE}, * {@code DataBuffer.TYPE_USHORT}, or * {@code DataBuffer.TYPE_INT} */ public SinglePixelPackedSampleModel(int dataType, int w, int h, ! int scanlineStride, int[] bitMasks) { super(dataType, w, h, bitMasks.length); if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_USHORT && dataType != DataBuffer.TYPE_INT) { throw new IllegalArgumentException("Unsupported data type "+
*** 304,319 **** * SinglePixelPackedSampleModel/DataBuffer combination. * @exception RasterFormatException if the length of the bands argument is * greater than the number of bands in * the sample model. */ ! public SampleModel createSubsetSampleModel(int bands[]) { if (bands.length > numBands) throw new RasterFormatException("There are only " + numBands + " bands"); ! int newBitMasks[] = new int[bands.length]; for (int i=0; i<bands.length; i++) newBitMasks[i] = bitMasks[bands[i]]; return new SinglePixelPackedSampleModel(this.dataType, width, height, this.scanlineStride, newBitMasks); --- 304,319 ---- * SinglePixelPackedSampleModel/DataBuffer combination. * @exception RasterFormatException if the length of the bands argument is * greater than the number of bands in * the sample model. */ ! public SampleModel createSubsetSampleModel(int[] bands) { if (bands.length > numBands) throw new RasterFormatException("There are only " + numBands + " bands"); ! int[] newBitMasks = new int[bands.length]; for (int i=0; i<bands.length; i++) newBitMasks[i] = bitMasks[bands[i]]; return new SinglePixelPackedSampleModel(this.dataType, width, height, this.scanlineStride, newBitMasks);
*** 424,439 **** * @param iArray If non-null, returns the samples in this array * @param data The DataBuffer containing the image data. * @return all samples for the specified pixel. * @see #setPixel(int, int, int[], DataBuffer) */ ! public int [] getPixel(int x, int y, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } ! int pixels[]; if (iArray == null) { pixels = new int [numBands]; } else { pixels = iArray; } --- 424,439 ---- * @param iArray If non-null, returns the samples in this array * @param data The DataBuffer containing the image data. * @return all samples for the specified pixel. * @see #setPixel(int, int, int[], DataBuffer) */ ! public int [] getPixel(int x, int y, int[] iArray, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } ! int[] pixels; if (iArray == null) { pixels = new int [numBands]; } else { pixels = iArray; }
*** 458,478 **** * @param data The DataBuffer containing the image data. * @return all samples for the specified region of pixels. * @see #setPixels(int, int, int, int, int[], DataBuffer) */ public int[] getPixels(int x, int y, int w, int h, ! int iArray[], DataBuffer data) { int x1 = x + w; int y1 = y + h; if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width || y < 0 || y >= height || h > height || y1 < 0 || y1 > height) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } ! int pixels[]; if (iArray != null) { pixels = iArray; } else { pixels = new int [w*h*numBands]; } --- 458,478 ---- * @param data The DataBuffer containing the image data. * @return all samples for the specified region of pixels. * @see #setPixels(int, int, int, int, int[], DataBuffer) */ public int[] getPixels(int x, int y, int w, int h, ! int[] iArray, DataBuffer data) { int x1 = x + w; int y1 = y + h; if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width || y < 0 || y >= height || h > height || y1 < 0 || y1 > height) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } ! int[] pixels; if (iArray != null) { pixels = iArray; } else { pixels = new int [w*h*numBands]; }
*** 530,546 **** * @return the samples for the specified band for the specified * region of pixels. * @see #setSamples(int, int, int, int, int, int[], DataBuffer) */ public int[] getSamples(int x, int y, int w, int h, int b, ! int iArray[], DataBuffer data) { // Bounds check for 'b' will be performed automatically if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } ! int samples[]; if (iArray != null) { samples = iArray; } else { samples = new int [w*h]; } --- 530,546 ---- * @return the samples for the specified band for the specified * region of pixels. * @see #setSamples(int, int, int, int, int, int[], DataBuffer) */ public int[] getSamples(int x, int y, int w, int h, int b, ! int[] iArray, DataBuffer data) { // Bounds check for 'b' will be performed automatically if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } ! int[] samples; if (iArray != null) { samples = iArray; } else { samples = new int [w*h]; }
*** 632,642 **** * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getPixel(int, int, int[], DataBuffer) */ public void setPixel(int x, int y, ! int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } --- 632,642 ---- * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getPixel(int, int, int[], DataBuffer) */ public void setPixel(int x, int y, ! int[] iArray, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); }
*** 661,671 **** * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getPixels(int, int, int, int, int[], DataBuffer) */ public void setPixels(int x, int y, int w, int h, ! int iArray[], DataBuffer data) { int x1 = x + w; int y1 = y + h; if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width || y < 0 || y >= height || h > height || y1 < 0 || y1 > height) --- 661,671 ---- * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getPixels(int, int, int, int, int[], DataBuffer) */ public void setPixels(int x, int y, int w, int h, ! int[] iArray, DataBuffer data) { int x1 = x + w; int y1 = y + h; if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width || y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
*** 730,740 **** * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getSamples(int, int, int, int, int, int[], DataBuffer) */ public void setSamples(int x, int y, int w, int h, int b, ! int iArray[], DataBuffer data) { // Bounds check for 'b' will be performed automatically if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } --- 730,740 ---- * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getSamples(int, int, int, int, int, int[], DataBuffer) */ public void setSamples(int x, int y, int w, int h, int b, ! int[] iArray, DataBuffer data) { // Bounds check for 'b' will be performed automatically if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); }
< prev index next >