public long getSizeInBytes() { long size = 0L; java.awt.image.Raster raster = this.bufferedImage.getRaster(); if (raster != null) { java.awt.image.DataBuffer db = raster.getDataBuffer(); if (db != null) { size = sizeOfDataBuffer(db); } } return(size); }
/// <summary> /// Constructs a Raster with the given SampleModel, DataBuffer, and /// parent. /// </summary> public Raster(SampleModel @sampleModel, DataBuffer @dataBuffer, Rectangle @aRegion, Point @sampleModelTranslate, Raster @parent) { }
/// <summary> /// Creates a Raster based on a MultiPixelPackedSampleModel with the /// specified DataBuffer, width, height, and bits per pixel. /// </summary> public WritableRaster createPackedRaster(DataBuffer @dataBuffer, int @w, int @h, int @bitsPerPixel, Point @location) { return default(WritableRaster); }
/// <summary> /// Creates a Raster based on a SinglePixelPackedSampleModel with /// the specified DataBuffer, width, height, scanline stride, and /// band masks. /// </summary> public WritableRaster createPackedRaster(DataBuffer @dataBuffer, int @w, int @h, int @scanlineStride, int[] @bandMasks, Point @location) { return default(WritableRaster); }
/// <summary> /// Sets the samples in the specified band for the specified rectangle /// of pixels from an int array containing one sample per array element. /// ArrayIndexOutOfBoundsException may be thrown if the coordinates are /// not in bounds. </summary> /// <param name="x"> The X coordinate of the upper left pixel location. </param> /// <param name="y"> The Y coordinate of the upper left pixel location. </param> /// <param name="w"> The width of the pixel rectangle. </param> /// <param name="h"> The height of the pixel rectangle. </param> /// <param name="b"> The band to set. </param> /// <param name="iArray"> The input samples in an int array. </param> /// <param name="data"> The DataBuffer containing the image data. </param> /// <seealso cref= #getSamples(int, int, int, int, int, int[], DataBuffer) </seealso> public override 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_Renamed) || (y + h > Height_Renamed)) { throw new ArrayIndexOutOfBoundsException("Coordinate out of bounds!"); } int lineOffset = y * ScanlineStride_Renamed + x; int srcOffset = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int value = data.GetElem(lineOffset + j); value &= ~BitMasks_Renamed[b]; int sample = iArray[srcOffset++]; value |= ((int)sample << BitOffsets_Renamed[b]) & BitMasks_Renamed[b]; data.SetElem(lineOffset + j, value); } lineOffset += ScanlineStride_Renamed; } }
/// <summary> /// Returns data for a single pixel in a primitive array of type /// TransferType. For a SinglePixelPackedSampleModel, the array will /// have one element, and the type will be the same as the storage /// data type. Generally, obj /// should be passed in as null, so that the Object will be created /// automatically and will be of the right primitive data type. /// <para> /// The following code illustrates transferring data for one pixel from /// DataBuffer <code>db1</code>, whose storage layout is described by /// SinglePixelPackedSampleModel <code>sppsm1</code>, to /// DataBuffer <code>db2</code>, whose storage layout is described by /// SinglePixelPackedSampleModel <code>sppsm2</code>. /// The transfer will generally be more efficient than using /// getPixel/setPixel. /// <pre> /// SinglePixelPackedSampleModel sppsm1, sppsm2; /// DataBufferInt db1, db2; /// sppsm2.setDataElements(x, y, sppsm1.getDataElements(x, y, null, /// db1), db2); /// </pre> /// Using getDataElements/setDataElements to transfer between two /// DataBuffer/SampleModel pairs is legitimate if the SampleModels have /// the same number of bands, corresponding bands have the same number of /// bits per sample, and the TransferTypes are the same. /// </para> /// <para> /// If obj is non-null, it should be a primitive array of type TransferType. /// Otherwise, a ClassCastException is thrown. An /// ArrayIndexOutOfBoundsException may be thrown if the coordinates are /// not in bounds, or if obj is non-null and is not large enough to hold /// the pixel data. /// </para> /// </summary> /// <param name="x"> The X coordinate of the pixel location. </param> /// <param name="y"> The Y coordinate of the pixel location. </param> /// <param name="obj"> If non-null, a primitive array in which to return /// the pixel data. </param> /// <param name="data"> The DataBuffer containing the image data. </param> /// <returns> the data for the specified pixel. </returns> /// <seealso cref= #setDataElements(int, int, Object, DataBuffer) </seealso> public override Object GetDataElements(int x, int y, Object obj, DataBuffer data) { // Bounds check for 'b' will be performed automatically if ((x < 0) || (y < 0) || (x >= Width_Renamed) || (y >= Height_Renamed)) { throw new ArrayIndexOutOfBoundsException("Coordinate out of bounds!"); } int type = TransferType; switch (type) { case DataBuffer.TYPE_BYTE: sbyte[] bdata; if (obj == null) { bdata = new sbyte[1]; } else { bdata = (sbyte[])obj; } bdata[0] = (sbyte)data.GetElem(y * ScanlineStride_Renamed + x); obj = (Object)bdata; break; case DataBuffer.TYPE_USHORT: short[] sdata; if (obj == null) { sdata = new short[1]; } else { sdata = (short[])obj; } sdata[0] = (short)data.GetElem(y * ScanlineStride_Renamed + x); obj = (Object)sdata; break; case DataBuffer.TYPE_INT: int[] idata; if (obj == null) { idata = new int[1]; } else { idata = (int[])obj; } idata[0] = data.GetElem(y * ScanlineStride_Renamed + x); obj = (Object)idata; break; } return(obj); }
/// <summary> /// Returns data for a single pixel in a primitive array of type /// TransferType. /// </summary> public object getDataElements(int @x, int @y, object @obj, DataBuffer @data) { return default(object); }
/// <summary> /// Sets the samples in the specified band for the specified rectangle /// of pixels from a double array containing one sample per array element. /// </summary> public void setSamples(int @x, int @y, int @w, int @h, int @b, double[] @dArray, DataBuffer @data) { }
/// <summary> /// Returns the samples for a specified band for the specified rectangle /// of pixels in a float array, one sample per array element. /// </summary> public float[] getSamples(int @x, int @y, int @w, int @h, int @b, float[] @fArray, DataBuffer @data) { return default(float[]); }
/// <summary> /// Returns the samples for a specified band for a specified rectangle /// of pixels in a double array, one sample per array element. /// </summary> public double[] getSamples(int @x, int @y, int @w, int @h, int @b, double[] @dArray, DataBuffer @data) { return default(double[]); }
/// <summary> /// Returns the sample in a specified band /// for the pixel located at (x,y) as a float. /// </summary> public float getSampleFloat(int @x, int @y, int @b, DataBuffer @data) { return default(float); }
/// <summary> /// Returns the sample in a specified band /// for a pixel located at (x,y) as a double. /// </summary> public double getSampleDouble(int @x, int @y, int @b, DataBuffer @data) { return default(double); }
/// <summary> /// Returns the sample in a specified band for the pixel located /// at (x,y) as an int. /// </summary> abstract public int getSample(int @x, int @y, int @b, DataBuffer @data);
/// <summary> /// Returns all samples for a rectangle of pixels in an /// int array, one sample per array element. /// </summary> public int[] getPixels(int @x, int @y, int @w, int @h, int[] @iArray, DataBuffer @data) { return default(int[]); }
/// <summary> /// Returns all samples for a rectangle of pixels in a float /// array, one sample per array element. /// </summary> public float[] getPixels(int @x, int @y, int @w, int @h, float[] @fArray, DataBuffer @data) { return default(float[]); }
/// <summary> /// Constructs a WritableRaster with the given SampleModel and DataBuffer. /// </summary> public WritableRaster(SampleModel @sampleModel, DataBuffer @dataBuffer, Point @origin) : base(sampleModel, origin) { }
private static long sizeOfDataBuffer(java.awt.image.DataBuffer dataBuffer) { return(sizeOfElement(dataBuffer.getDataType()) * dataBuffer.getSize()); }
/// <summary> /// Returns the samples for a specified band for the specified rectangle /// of pixels in an int array, one sample per array element. /// </summary> public int[] getSamples(int @x, int @y, int @w, int @h, int @b, int[] @iArray, DataBuffer @data) { return default(int[]); }
/// <summary> /// Sets the samples in the specified band for the specified rectangle /// of pixels from an int array containing one sample per array element. /// </summary> public void setSamples(int @x, int @y, int @w, int @h, int @b, int[] @iArray, DataBuffer @data) { }
/// <summary> /// Sets the data for a rectangle of pixels in the specified DataBuffer /// from a primitive array of type TransferType. /// </summary> public void setDataElements(int @x, int @y, int @w, int @h, object @obj, DataBuffer @data) { }
/// <summary> /// Returns the samples for the specified pixel in an array of double. /// </summary> public double[] getPixel(int @x, int @y, double[] @dArray, DataBuffer @data) { return default(double[]); }
/// <summary> /// Sets the data for a single pixel in the specified DataBuffer from a /// primitive array of type TransferType. /// </summary> abstract public void setDataElements(int @x, int @y, object @obj, DataBuffer @data);
/// <summary> /// Returns the samples for a specified band for the specified rectangle /// of pixels in an int array, one sample per array element. /// ArrayIndexOutOfBoundsException may be thrown if the coordinates are /// not in bounds. </summary> /// <param name="x"> The X coordinate of the upper left pixel location. </param> /// <param name="y"> The Y coordinate of the upper left pixel location. </param> /// <param name="w"> The width of the pixel rectangle. </param> /// <param name="h"> The height of the pixel rectangle. </param> /// <param name="b"> The band to return. </param> /// <param name="iArray"> If non-null, returns the samples in this array. </param> /// <param name="data"> The DataBuffer containing the image data. </param> /// <returns> the samples for the specified band for the specified /// region of pixels. </returns> /// <seealso cref= #setSamples(int, int, int, int, int, int[], DataBuffer) </seealso> public override 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_Renamed) || (y + h > Height_Renamed)) { throw new ArrayIndexOutOfBoundsException("Coordinate out of bounds!"); } int[] samples; if (iArray != null) { samples = iArray; } else { samples = new int [w * h]; } int lineOffset = y * ScanlineStride_Renamed + x; int dstOffset = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int value = data.GetElem(lineOffset + j); samples[dstOffset++] = ((int)((uint)(value & BitMasks_Renamed[b]) >> BitOffsets_Renamed[b])); } lineOffset += ScanlineStride_Renamed; } return(samples); }
/// <summary> /// Sets a pixel in the DataBuffer using a float array of samples for input. /// </summary> public void setPixel(int @x, int @y, float[] @fArray, DataBuffer @data) { }
/// <summary> /// Creates a Raster based on a PixelInterleavedSampleModel with the /// specified DataBuffer, width, height, scanline stride, pixel /// stride, and band offsets. /// </summary> public WritableRaster createInterleavedRaster(DataBuffer @dataBuffer, int @w, int @h, int @scanlineStride, int @pixelStride, int[] @bandOffsets, Point @location) { return default(WritableRaster); }
/// <summary> /// Sets all samples for a rectangle of pixels from a double array /// containing one sample per array element. /// </summary> public void setPixels(int @x, int @y, int @w, int @h, double[] @dArray, DataBuffer @data) { }
/// <summary> /// Constructs a Raster with the given SampleModel and DataBuffer. /// </summary> public Raster(SampleModel @sampleModel, DataBuffer @dataBuffer, Point @origin) { }
/// <summary> /// Sets all samples for a rectangle of pixels from an int array containing /// one sample per array element. /// </summary> public void setPixels(int @x, int @y, int @w, int @h, int[] @iArray, DataBuffer @data) { }
/// <summary> /// Creates a WritableRaster with the specified SampleModel and DataBuffer. /// </summary> public WritableRaster createWritableRaster(SampleModel @sm, DataBuffer @db, Point @location) { return default(WritableRaster); }
/// <summary> /// Sets a sample in the specified band for the pixel located at (x,y) /// in the DataBuffer using a double for input. /// </summary> public void setSample(int @x, int @y, int @b, double @s, DataBuffer @data) { }
/// <summary> /// Creates a Raster based on a BandedSampleModel with the /// specified DataBuffer, width, height, scanline stride, bank /// indices, and band offsets. /// </summary> public WritableRaster createBandedRaster(DataBuffer @dataBuffer, int @w, int @h, int @scanlineStride, int[] @bankIndices, int[] @bandOffsets, Point @location) { return default(WritableRaster); }
/// <summary> /// Sets a sample in the specified band for the pixel located at (x,y) /// in the DataBuffer using a float for input. /// </summary> public void setSample(int @x, int @y, int @b, float @s, DataBuffer @data) { }
/// <summary> /// Constructs a WritableRaster with the given SampleModel, DataBuffer, /// and parent. /// </summary> public WritableRaster(SampleModel @sampleModel, DataBuffer @dataBuffer, Rectangle @aRegion, Point @sampleModelTranslate, WritableRaster @parent) : base(sampleModel, null) { }
/// <summary> /// Sets a sample in the specified band for the pixel located at (x,y) /// in the DataBuffer using an int for input. /// </summary> abstract public void setSample(int @x, int @y, int @b, int @s, DataBuffer @data);