public override bool Equals(Object o) { if ((o == null) || !(o is ComponentSampleModel)) { return(false); } ComponentSampleModel model = (ComponentSampleModel)o; return(this.width == model.width && this.height == model.height && this.numBands == model.numBands && this.dataType == model.dataType && java.util.Arrays <Object> .equals(this.bandOffsets, model.bandOffsets) && java.util.Arrays <Object> .equals(this.bankIndices, model.bankIndices) && this.numBands == model.numBands && this.numBanks == model.numBanks && this.scanlineStride == model.scanlineStride && this.pixelStride == model.pixelStride); }
private static void validateDataBuffer(DataBuffer dataBuffer, int w, int h, SampleModel sampleModel) { int size = 0; if (sampleModel is ComponentSampleModel) { ComponentSampleModel csm = (ComponentSampleModel)sampleModel; int [] offsets = csm.getBandOffsets(); int maxOffset = offsets[0]; for (int i = 1; i < offsets.Length; i++) { if (offsets[i] > maxOffset) { maxOffset = offsets[i]; } } int scanlineStride = csm.getScanlineStride(); int pixelStride = csm.getPixelStride(); size = (h - 1) * scanlineStride + (w - 1) * pixelStride + maxOffset + 1; } else if (sampleModel is MultiPixelPackedSampleModel) { MultiPixelPackedSampleModel mppsm = (MultiPixelPackedSampleModel)sampleModel; int scanlineStride = mppsm.getScanlineStride(); int dataBitOffset = mppsm.getDataBitOffset(); int dataType = dataBuffer.getDataType(); size = scanlineStride * h; switch (dataType) { case DataBuffer.TYPE_BYTE: size += (dataBitOffset + 7) / 8; break; case DataBuffer.TYPE_USHORT: size += (dataBitOffset + 15) / 16; break; case DataBuffer.TYPE_INT: size += (dataBitOffset + 31) / 32; break; } } else if (sampleModel is SinglePixelPackedSampleModel) { SinglePixelPackedSampleModel sppsm = (SinglePixelPackedSampleModel)sampleModel; int scanlineStride = sppsm.getScanlineStride(); size = (h - 1) * scanlineStride + w; } if (dataBuffer.getSize() < size) { // awt.298=dataBuffer is too small throw new RasterFormatException("dataBuffer is too small"); //$NON-NLS-1$ } }