dis = new DicomInputStream(new ImageInputStreamAdapter(iis));
dis.setIncludeBulkData(IncludeBulkData.URI);
dis.setBulkDataDescriptor(BulkDataDescriptor.PIXELDATA);
dis.setURI("java:iis"); // avoid copy of pixeldata to temporary file
Attributes fmi = dis.readFileMetaInformation();
Attributes ds = dis.readDataset(-1, -1);
metadata = new DicomMetaData(fmi, ds);
Object pixeldata = ds.getValue(Tag.PixelData, pixeldataVR );
if (pixeldata != null) {
frames = ds.getInt(Tag.NumberOfFrames, 1);
width = ds.getInt(Tag.Columns, 0);
height = ds.getInt(Tag.Rows, 0);
samples = ds.getInt(Tag.SamplesPerPixel, 1);
banded = samples > 1 && ds.getInt(Tag.PlanarConfiguration, 0) != 0;
bitsAllocated = ds.getInt(Tag.BitsAllocated, 8);
bitsStored = ds.getInt(Tag.BitsStored, bitsAllocated);
dataType = bitsAllocated <= 8 ? DataBuffer.TYPE_BYTE
: DataBuffer.TYPE_USHORT;
pmi = PhotometricInterpretation.fromString(
ds.getString(Tag.PhotometricInterpretation, "MONOCHROME2"));
if (pixeldata instanceof BulkData) {
iis.setByteOrder(ds.bigEndian()
? ByteOrder.BIG_ENDIAN
: ByteOrder.LITTLE_ENDIAN);
this.frameLength = pmi.frameLength(width, height, samples, bitsAllocated);
this.pixeldata = (BulkData) pixeldata;
} else {