use of org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam in project dcm4che by dcm4che.
the class LdapImageReaderConfiguration method merge.
private void merge(ConfigurationChanges diffs, ImageReaderFactory prev, ImageReaderFactory factory, String imageReadersDN) throws NamingException {
for (Entry<String, ImageReaderParam> entry : prev.getEntries()) {
String tsuid = entry.getKey();
if (factory.get(tsuid) == null) {
String dn = dnOf(tsuid, imageReadersDN);
config.destroySubcontext(dn);
ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D);
}
}
for (Entry<String, ImageReaderParam> entry : factory.getEntries()) {
String tsuid = entry.getKey();
String dn = dnOf(tsuid, imageReadersDN);
ImageReaderParam prevParam = prev.get(tsuid);
if (prevParam == null) {
ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.C);
config.createSubcontext(dn, storeTo(ConfigurationChanges.nullifyIfNotVerbose(diffs, ldapObj), tsuid, entry.getValue(), new BasicAttributes(true)));
} else {
ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.U);
config.modifyAttributes(dn, storeDiffs(ldapObj, prevParam, entry.getValue(), new ArrayList<ModificationItem>()));
ConfigurationChanges.removeLastIfEmpty(diffs, ldapObj);
}
}
}
use of org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam in project dcm4che by dcm4che.
the class LdapImageReaderConfiguration method loadChilds.
@Override
protected void loadChilds(Device device, String deviceDN) throws NamingException, ConfigurationException {
String imageReadersDN = CN_IMAGE_READER_FACTORY + deviceDN;
try {
config.getAttributes(imageReadersDN);
} catch (NameNotFoundException e) {
return;
}
ImageReaderFactory factory = new ImageReaderFactory();
NamingEnumeration<SearchResult> ne = config.search(imageReadersDN, "(objectclass=dcmImageReader)");
try {
while (ne.hasMore()) {
SearchResult sr = ne.next();
Attributes attrs = sr.getAttributes();
factory.put(LdapUtils.stringValue(attrs.get("dicomTransferSyntax"), null), new ImageReaderParam(LdapUtils.stringValue(attrs.get("dcmIIOFormatName"), null), LdapUtils.stringValue(attrs.get("dcmJavaClassName"), null), LdapUtils.stringValue(attrs.get("dcmPatchJPEGLS"), null), LdapUtils.stringArray(attrs.get("dcmImageReadParam"))));
}
} finally {
LdapUtils.safeClose(ne);
}
device.addDeviceExtension(new ImageReaderExtension(factory));
}
use of org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam in project dcm4che by dcm4che.
the class DicomImageReader method setMetadata.
private void setMetadata(DicomMetaData metadata) {
this.metadata = metadata;
Attributes ds = metadata.getAttributes();
if (pixelDataLength != 0) {
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 (pixelDataLength != -1) {
pmiAfterDecompression = pmi;
this.frameLength = pmi.frameLength(width, height, samples, bitsAllocated);
} else {
Attributes fmi = metadata.getFileMetaInformation();
if (fmi == null)
throw new IllegalArgumentException("Missing File Meta Information for Data Set with compressed Pixel Data");
String tsuid = fmi.getString(Tag.TransferSyntaxUID);
ImageReaderParam param = ImageReaderFactory.getImageReaderParam(tsuid);
if (param == null)
throw new UnsupportedOperationException("Unsupported Transfer Syntax: " + tsuid);
TransferSyntaxType tsType = TransferSyntaxType.forUID(tsuid);
if (tsType.adjustBitsStoredTo12(ds)) {
LOG.info("Adjust invalid Bits Stored: {} of {} to 12", bitsStored, tsType);
bitsStored = 12;
}
pmiAfterDecompression = pmi.isYBR() && TransferSyntaxType.isYBRCompression(tsuid) ? PhotometricInterpretation.RGB : pmi;
this.rle = tsuid.equals(UID.RLELossless);
this.decompressor = ImageReaderFactory.getImageReader(param);
LOG.debug("Decompressor: {}", decompressor.getClass().getName());
this.patchJpegLS = param.patchJPEGLS;
}
}
}
Aggregations