stream.writeShorts(shorts, 0, shorts.length); break;
rowRaster.setDataElements(0, 0, raster.createChild(0, y, raster.getWidth(), 1, 0, 0, null)); short[] shorts = ((DataBufferUShort) buffer).getData(); imageOutput.writeShorts(shorts, 0, shorts.length); break; default:
private void writeImageData(final IIOImage image) throws IOException { // - dump data as is (or convert, if TYPE_INT_xxx) // Enforce RGB/CMYK order for such data! // TODO: Loop over x/y tiles, using 0,0 is only valid for BufferedImage // TODO: PNM/PAM does not support tiling, we must iterate all tiles along the x-axis for each row we write Raster tile = image.hasRaster() ? image.getRaster() : image.getRenderedImage().getTile(0, 0); SampleModel sampleModel = tile.getSampleModel(); DataBuffer dataBuffer = tile.getDataBuffer(); int tileWidth = tile.getWidth(); int tileHeight = tile.getHeight(); final int transferType = sampleModel.getTransferType(); Object data = null; for (int y = 0; y < tileHeight; y++) { data = sampleModel.getDataElements(0, y, tileWidth, 1, data, dataBuffer); // TODO: Support other (short, float) data types if (transferType == DataBuffer.TYPE_BYTE) { imageOutput.write((byte[]) data); } else if (transferType == DataBuffer.TYPE_USHORT) { short[] shortData = (short[]) data; imageOutput.writeShorts(shortData, 0, shortData.length); } processImageProgress(y * 100f / tileHeight); // TODO: Take tile y into account if (abortRequested()) { processWriteAborted(); break; } } }
/** * Please refer to {@link ProductData#writeTo(int, int, ImageOutputStream)}. */ @Override public void writeTo(int sourceStartPos, int numSourceElems, ImageOutputStream destination) throws IOException { destination.writeShorts(_array, sourceStartPos, numSourceElems); }
public void writeShorts(short[] s, int off, int len) throws IOException { ios.writeShorts(s, off, len); }
public void writeShorts(short[] s, int off, int len) throws IOException { ios.writeShorts(s, off, len); }
for (int i = 0; i < numBanks; i++) { bankData = ((DataBufferShort) dataBuf).getData(i); strm.writeShorts(bankData, 0, dataLen); for (int i = 0; i < numBanks; i++) { bankData = ((DataBufferUShort) dataBuf).getData(i); strm.writeShorts(bankData, 0, dataLen);
} else if (dataObject instanceof short[]) { short[] data = (short[]) dataObject; stream.writeShorts(data, 0, data.length); } else if (dataObject instanceof int[]) { int[] data = (int[]) dataObject;
stream.writeShorts(shorts, 0, shorts.length); break;
stream.writeShorts(shorts, 0, shorts.length); break;
for (int i = 0; i < numBanks; i++) { bankData = ((DataBufferShort) dataBuf).getData(i); strm.writeShorts(bankData, 0, dataLen); for (int i = 0; i < numBanks; i++) { bankData = ((DataBufferUShort) dataBuf).getData(i); strm.writeShorts(bankData, 0, dataLen);
if (literalCount == 127) { out.writeShorts(data, xy - literalCount + 1, literalCount); literalCount = 0; if (literalCount > 0) { out.writeShorts(data, xy - literalCount, literalCount); literalCount = 0; out.writeShorts(data, xy - literalCount, literalCount); literalCount = 0;
if (literalCount == 127) { out.writeShorts(data, xy - literalCount + 1, literalCount); literalCount = 0; if (literalCount > 0) { out.writeShorts(data, xy - literalCount, literalCount); literalCount = 0; out.writeShorts(data, xy - literalCount, literalCount); literalCount = 0;
static void writeTile(ImageOutputStream stream, Raster tile) throws IOException { if (tile.getSampleModel().getNumDataElements() != tile.getDataBuffer().getSize()) { // todo - log error throw new IllegalStateException(); } DataBuffer dataBuffer = tile.getDataBuffer(); if (dataBuffer instanceof DataBufferByte) { byte[] data = ((DataBufferByte) dataBuffer).getData(); stream.write(data, dataBuffer.getOffset(), dataBuffer.getSize()); } else if (dataBuffer instanceof DataBufferShort) { short[] data = ((DataBufferShort) dataBuffer).getData(); stream.writeShorts(data, dataBuffer.getOffset(), dataBuffer.getSize()); } else if (dataBuffer instanceof DataBufferInt) { int[] data = ((DataBufferInt) dataBuffer).getData(); stream.writeInts(data, dataBuffer.getOffset(), dataBuffer.getSize()); } else if (dataBuffer instanceof DataBufferFloat) { float[] data = ((DataBufferFloat) dataBuffer).getData(); stream.writeFloats(data, dataBuffer.getOffset(), dataBuffer.getSize()); } else if (dataBuffer instanceof DataBufferDouble) { double[] data = ((DataBufferDouble) dataBuffer).getData(); stream.writeDoubles(data, dataBuffer.getOffset(), dataBuffer.getSize()); } else { throw new IllegalStateException(); } }
break; case TIFFTag.TIFF_SSHORT: stream.writeShorts((short[])data, 0, ((short[])data).length); break; case TIFFTag.TIFF_SLONG:
break; case TIFFTag.TIFF_SSHORT: stream.writeShorts((short[])data, 0, ((short[])data).length); break; case TIFFTag.TIFF_SLONG:
break; case TIFFTag.TIFF_SSHORT: stream.writeShorts((short[])data, 0, ((short[])data).length); break; case TIFFTag.TIFF_SLONG:
break; case TIFFTag.TIFF_SSHORT: stream.writeShorts((short[])data, 0, ((short[])data).length); break; case TIFFTag.TIFF_SLONG:
data[x] = (short) regionData.getElemUIntAt(stride + x); ios.writeShorts(data, 0, regionWidth); } else if (bandDataType == ProductData.TYPE_INT16) { final short[] data = new short[regionWidth]; data[x] = (short) regionData.getElemIntAt(stride + x); ios.writeShorts(data, 0, regionWidth); } else if (bandDataType == ProductData.TYPE_UINT32) { final int[] data = new int[regionWidth];
outputStream.writeShorts(destBuffer, 0, destBuffer.length);