Java Code Examples for javax.imageio.metadata.IIOMetadataFormatImpl#standardMetadataFormatName()
The following examples show how to use
javax.imageio.metadata.IIOMetadataFormatImpl#standardMetadataFormatName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TIFFImageWriter.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Converts a standard {@code javax_imageio_1.0} tree to a * {@code TIFFImageMetadata} object. * * @param inData The metadata object. * @return a {@code TIFFImageMetadata} or {@code null} if * the standard tree derived from the input object is {@code null}. * @throws IllegalArgumentException if {@code inData} is * {@code null}. * @throws IllegalArgumentException if {@code inData} does not support * the standard metadata format. * @throws IIOInvalidTreeException if {@code inData} generates an * invalid standard metadata tree. */ private TIFFImageMetadata convertStandardImageMetadata(IIOMetadata inData) throws IIOInvalidTreeException { if(inData == null) { throw new NullPointerException("inData == null!"); } else if(!inData.isStandardMetadataFormatSupported()) { throw new IllegalArgumentException ("inData does not support standard metadata format!"); } TIFFImageMetadata outData = null; String formatName = IIOMetadataFormatImpl.standardMetadataFormatName; Node tree = inData.getAsTree(formatName); if (tree != null) { List<TIFFTagSet> tagSets = new ArrayList<TIFFTagSet>(1); tagSets.add(BaselineTIFFTagSet.getInstance()); outData = new TIFFImageMetadata(tagSets); outData.setFromTree(formatName, tree); } return outData; }
Example 2
Source File: TIFFImageWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Converts a standard {@code javax_imageio_1.0} tree to a * {@code TIFFImageMetadata} object. * * @param inData The metadata object. * @return a {@code TIFFImageMetadata} or {@code null} if * the standard tree derived from the input object is {@code null}. * @throws IllegalArgumentException if {@code inData} is * {@code null}. * @throws IllegalArgumentException if {@code inData} does not support * the standard metadata format. * @throws IIOInvalidTreeException if {@code inData} generates an * invalid standard metadata tree. */ private TIFFImageMetadata convertStandardImageMetadata(IIOMetadata inData) throws IIOInvalidTreeException { if(inData == null) { throw new NullPointerException("inData == null!"); } else if(!inData.isStandardMetadataFormatSupported()) { throw new IllegalArgumentException ("inData does not support standard metadata format!"); } TIFFImageMetadata outData = null; String formatName = IIOMetadataFormatImpl.standardMetadataFormatName; Node tree = inData.getAsTree(formatName); if (tree != null) { List<TIFFTagSet> tagSets = new ArrayList<TIFFTagSet>(1); tagSets.add(BaselineTIFFTagSet.getInstance()); outData = new TIFFImageMetadata(tagSets); outData.setFromTree(formatName, tree); } return outData; }
Example 3
Source File: J2KImageWriter.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
public IIOMetadata convertImageMetadata(IIOMetadata inData, ImageTypeSpecifier imageType, ImageWriteParam param) { // Check arguments. if(inData == null) { throw new IllegalArgumentException("inData == null!"); } if(imageType == null) { throw new IllegalArgumentException("imageType == null!"); } // If it's one of ours, return a clone. if (inData instanceof J2KMetadata) { return (IIOMetadata)((J2KMetadata)inData).clone(); } try { J2KMetadata outData = new J2KMetadata(); List formats = Arrays.asList(inData.getMetadataFormatNames()); String format = null; if(formats.contains(J2KMetadata.nativeMetadataFormatName)) { // Initialize from native image metadata format. format = J2KMetadata.nativeMetadataFormatName; } else if(inData.isStandardMetadataFormatSupported()) { // Initialize from standard metadata form of the input tree. format = IIOMetadataFormatImpl.standardMetadataFormatName; } if(format != null) { outData.setFromTree(format, inData.getAsTree(format)); return outData; } } catch(IIOInvalidTreeException e) { return null; } return null; }
Example 4
Source File: TIFFDirectory.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Creates a {@code TIFFDirectory} instance from the contents of * an image metadata object. The supplied object must support an image * metadata format supported by the TIFF {@link javax.imageio.ImageWriter} * plug-in. This will usually be either the TIFF native image metadata * format {@code javax_imageio_tiff_image_1.0} or the Java * Image I/O standard metadata format {@code javax_imageio_1.0}. * * @param tiffImageMetadata A metadata object which supports a compatible * image metadata format. * * @return A {@code TIFFDirectory} populated from the contents of * the supplied metadata object. * * @throws NullPointerException if {@code tiffImageMetadata} * is {@code null}. * @throws IllegalArgumentException if {@code tiffImageMetadata} * does not support a compatible image metadata format. * @throws IIOInvalidTreeException if the supplied metadata object * cannot be parsed. */ public static TIFFDirectory createFromMetadata(IIOMetadata tiffImageMetadata) throws IIOInvalidTreeException { if(tiffImageMetadata == null) { throw new NullPointerException("tiffImageMetadata == null"); } TIFFImageMetadata tim; if(tiffImageMetadata instanceof TIFFImageMetadata) { tim = (TIFFImageMetadata)tiffImageMetadata; } else { // Create a native metadata object. ArrayList<TIFFTagSet> l = new ArrayList<TIFFTagSet>(1); l.add(BaselineTIFFTagSet.getInstance()); tim = new TIFFImageMetadata(l); // Determine the format name to use. String formatName = null; if(TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME.equals (tiffImageMetadata.getNativeMetadataFormatName())) { formatName = TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME; } else { String[] extraNames = tiffImageMetadata.getExtraMetadataFormatNames(); if(extraNames != null) { for(int i = 0; i < extraNames.length; i++) { if(TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME.equals (extraNames[i])) { formatName = extraNames[i]; break; } } } if(formatName == null) { if(tiffImageMetadata.isStandardMetadataFormatSupported()) { formatName = IIOMetadataFormatImpl.standardMetadataFormatName; } else { throw new IllegalArgumentException ("Parameter does not support required metadata format!"); } } } // Set the native metadata object from the tree. tim.setFromTree(formatName, tiffImageMetadata.getAsTree(formatName)); } return tim.getRootIFD(); }
Example 5
Source File: TIFFDirectory.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Creates a {@code TIFFDirectory} instance from the contents of * an image metadata object. The supplied object must support an image * metadata format supported by the TIFF {@link javax.imageio.ImageWriter} * plug-in. This will usually be either the TIFF native image metadata * format {@code javax_imageio_tiff_image_1.0} or the Java * Image I/O standard metadata format {@code javax_imageio_1.0}. * * @param tiffImageMetadata A metadata object which supports a compatible * image metadata format. * * @return A {@code TIFFDirectory} populated from the contents of * the supplied metadata object. * * @throws NullPointerException if {@code tiffImageMetadata} * is {@code null}. * @throws IllegalArgumentException if {@code tiffImageMetadata} * does not support a compatible image metadata format. * @throws IIOInvalidTreeException if the supplied metadata object * cannot be parsed. */ public static TIFFDirectory createFromMetadata(IIOMetadata tiffImageMetadata) throws IIOInvalidTreeException { if(tiffImageMetadata == null) { throw new NullPointerException("tiffImageMetadata == null"); } TIFFImageMetadata tim; if(tiffImageMetadata instanceof TIFFImageMetadata) { tim = (TIFFImageMetadata)tiffImageMetadata; } else { // Create a native metadata object. ArrayList<TIFFTagSet> l = new ArrayList<TIFFTagSet>(1); l.add(BaselineTIFFTagSet.getInstance()); tim = new TIFFImageMetadata(l); // Determine the format name to use. String formatName = null; if(TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME.equals (tiffImageMetadata.getNativeMetadataFormatName())) { formatName = TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME; } else { String[] extraNames = tiffImageMetadata.getExtraMetadataFormatNames(); if(extraNames != null) { for(int i = 0; i < extraNames.length; i++) { if(TIFFImageMetadata.NATIVE_METADATA_FORMAT_NAME.equals (extraNames[i])) { formatName = extraNames[i]; break; } } } if(formatName == null) { if(tiffImageMetadata.isStandardMetadataFormatSupported()) { formatName = IIOMetadataFormatImpl.standardMetadataFormatName; } else { throw new IllegalArgumentException ("Parameter does not support required metadata format!"); } } } // Set the native metadata object from the tree. tim.setFromTree(formatName, tiffImageMetadata.getAsTree(formatName)); } return tim.getRootIFD(); }