Package com.sun.media.imageio.plugins.tiff

Examples of com.sun.media.imageio.plugins.tiff.TIFFField


            TIFFDirectory tifd;
            try {
                tifd = metadata == null ? new TIFFDirectory(new TIFFTagSet[]{BaselineTIFFTagSet.getInstance()}, null) : TIFFDirectory.createFromMetadata(metadata);
                if (!_useTIFF_UnforcedRGB) {
                    tifd.removeTIFFField(ttagPhoto.getNumber());
                    tifd.addTIFFField(new TIFFField(ttagPhoto, BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_RGB));
                }
                if (tifd.containsTIFFField(ttagPhoto.getNumber())) {
                    int photometric = tifd.getTIFFField(ttagPhoto.getNumber()).getAsInt(0);
                    float[] referenceBlackWhite;
                    float[] ycbcrCoefficients = null;
                    switch (photometric) {
                        case BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_RGB:
                            referenceBlackWhite = _useTIFF_NOHead_NOFoot ? referenceBlackWhiteRGB_NOHead_NOFoot : referenceBlackWhiteRGB_601_1;
                            break;
                        case BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_Y_CB_CR:
                            referenceBlackWhite = _useTIFF_NOHead_NOFoot ? referenceBlackWhiteYCbCr_NOHead_NOFoot : referenceBlackWhiteYCbCr_601_1;
                            ycbcrCoefficients = _useTIFF_NOHead_NOFoot ? ycbcrCoefficients_709 : ycbcrCoefficients_601_1;
                            break;
                        default:
                            referenceBlackWhite = null;
                            break;
                    }
                    if (referenceBlackWhite != null) {
                        tifd.removeTIFFField(ttagRefBW.getNumber());
                        tifd.addTIFFField(new TIFFField(ttagRefBW, TIFFTag.TIFF_FLOAT, 6, referenceBlackWhite));
                        if (ycbcrCoefficients != null) {
                            tifd.removeTIFFField(ttagCoeff.getNumber());
                            tifd.addTIFFField(new TIFFField(ttagCoeff, TIFFTag.TIFF_FLOAT, 3, ycbcrCoefficients));
                        }
                        if (DebugMap._getInstance().isDebuggerEnabled(Sprite.class) && DebugMap._getInstance().isDebugLevelEnabled(DebugMap._getInstance()._VOID)) {
                            System.out.print("TIFFField ReferenceBlackWhite ");
                            for (float f : referenceBlackWhite) {
                                System.out.print(" " + f);
                            }
                            System.out.println();
                        }
                    }
                }
                if (_useTIFF_EXIF) {
                    TIFFTagSet exif = EXIFTIFFTagSet.getInstance();
                    tifd.addTagSet(exif);
                    tifd.addTIFFField(new TIFFField(exif.getTag(EXIFTIFFTagSet.TAG_EXIF_VERSION), TIFFTag.TIFF_UNDEFINED, 4, EXIFTIFFTagSet.EXIF_VERSION_2_2));
                }
                metadata = tifd.getAsMetadata();
            } catch (IIOInvalidTreeException ex) {
                if (DebugMap._getInstance().isDebuggerEnabled(Sprite.class)) {
                    ex.printStackTrace();
View Full Code Here


    private TIFFField getMetadataField( int tag ) {
        if ( metadata == null ) {
            load( false, true, Integer.MAX_VALUE, Integer.MAX_VALUE, false );
        }
       
        TIFFField ret =  null;
        if ( exifData != null ) {
            ret = exifData.getTIFFField( tag );
        }
        if ( ret == null && metadata != null ) {
            ret = metadata.getTIFFField( tag );
View Full Code Here

     * @param tag ID of the tag.
     * @return The tag value as String or <CODE>null</CODE> if the tag does not exist in the image
     */
    public String getEXIFTagAsString( int tag ) {
        String ret = null;
        TIFFField fld = getMetadataField( tag );
        if ( fld != null ) {
            ret = fld.getAsString( 0 );
        }
        return ret;
    }
View Full Code Here

        return ret;
    }
   
    public double getEXIFTagAsDouble( int tag ) {
        double ret = 0.0;
        TIFFField fld = getMetadataField( tag );
        if ( fld != null ) {
            ret = fld.getAsDouble( 0 );
        }
        return ret;
    }
View Full Code Here

        return ret;
    }

    public int getEXIFTagAsInt( int tag ) {
        int ret = 0;
        TIFFField fld = getMetadataField( tag );
        if ( fld != null ) {
            ret = fld.getAsInt( 0 );
        }
        return ret;
    }
View Full Code Here

                            if ( readers.hasNext() ) {
                                ImageReader reader = (ImageReader) readers.next();
                                reader.setInput( metadataStream );
                                IIOMetadata metadata = reader.getImageMetadata( 0 );
                                this.metadata = TIFFDirectory.createFromMetadata( metadata );
                                TIFFField exifField = this.metadata.getTIFFField( EXIFParentTIFFTagSet.TAG_EXIF_IFD_POINTER );
                                if ( exifField != null ) {
                                    exifData = (TIFFDirectory) exifField.getData();
                                }
                            }
                        } catch (IOException ex) {
                            ex.printStackTrace();
                        }
View Full Code Here

        throws IOException {
        rootIFD.initialize(stream, ignoreUnknownFields);
    }

    public void addShortOrLongField(int tagNumber, int value) {
        TIFFField field = new TIFFField(rootIFD.getTag(tagNumber), value);
        rootIFD.addTIFFField(field);
    }
View Full Code Here

            IFDRoot.setAttribute("tagSets", tagSetNames);
        }

        Iterator iter = ifd.iterator();
        while (iter.hasNext()) {
            TIFFField f = (TIFFField)iter.next();
            int tagNumber = f.getTagNumber();
            TIFFTag tag = TIFFIFD.getTag(tagNumber, tagSets);

            Node node = null;
            if (tag == null) {
                node = f.getAsNativeNode();
            } else if (tag.isIFDPointer()) {
                TIFFIFD subIFD = (TIFFIFD)f.getData();

                // Recurse
                node = getIFDAsTree(subIFD, tag.getName(), tag.getNumber());
            } else {
                node = f.getAsNativeNode();
            }

            if (node != null) {
                IFDRoot.appendChild(node);
            }
View Full Code Here

    public IIOMetadataNode getStandardChromaNode() {
        IIOMetadataNode chroma_node = new IIOMetadataNode("Chroma");
        IIOMetadataNode node = null; // scratch node

        TIFFField f;

        // Set the PhotometricInterpretation and the palette color flag.
        int photometricInterpretation = -1;
        boolean isPaletteColor = false;
        f = getTIFFField(BaselineTIFFTagSet.TAG_PHOTOMETRIC_INTERPRETATION);
        if (f != null) {
            photometricInterpretation = f.getAsInt(0);

            isPaletteColor =
                photometricInterpretation ==
                BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_PALETTE_COLOR;
        }

        // Determine the number of channels.
        int numChannels = -1;
        if(isPaletteColor) {
            numChannels = 3;
        } else {
            f = getTIFFField(BaselineTIFFTagSet.TAG_SAMPLES_PER_PIXEL);
            if (f != null) {
                numChannels = f.getAsInt(0);
            } else { // f == null
                f = getTIFFField(BaselineTIFFTagSet.TAG_BITS_PER_SAMPLE);
                if(f != null) {
                    numChannels = f.getCount();
                }
            }
        }

        if(photometricInterpretation != -1) {
            if (photometricInterpretation >= 0 &&
                photometricInterpretation < colorSpaceNames.length) {
                node = new IIOMetadataNode("ColorSpaceType");
                String csName;
                if(photometricInterpretation ==
                   BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_CMYK &&
                   numChannels == 3) {
                    csName = "CMY";
                } else {
                    csName = colorSpaceNames[photometricInterpretation];
                }
                node.setAttribute("name", csName);
                chroma_node.appendChild(node);
            }
           
            node = new IIOMetadataNode("BlackIsZero");
            node.setAttribute("value",
                              (photometricInterpretation ==
                   BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_WHITE_IS_ZERO)
                              ? "FALSE" : "TRUE");
            chroma_node.appendChild(node);
        }

        if(numChannels != -1) {
            node = new IIOMetadataNode("NumChannels");
            node.setAttribute("value", Integer.toString(numChannels));
            chroma_node.appendChild(node);
        }

        f = getTIFFField(BaselineTIFFTagSet.TAG_COLOR_MAP);
        if (f != null) {
            // NOTE: The presence of hasAlpha is vestigial: there is
            // no way in TIFF to represent an alpha component in a palette
            // color image. See bug 5086341.
            boolean hasAlpha = false;

            node = new IIOMetadataNode("Palette");
            int len = f.getCount()/(hasAlpha ? 4 : 3);
            for (int i = 0; i < len; i++) {
                IIOMetadataNode entry =
                    new IIOMetadataNode("PaletteEntry");
                entry.setAttribute("index", Integer.toString(i));

                int r = (f.getAsInt(i)*255)/65535;
                int g = (f.getAsInt(len + i)*255)/65535;
                int b = (f.getAsInt(2*len + i)*255)/65535;

                entry.setAttribute("red", Integer.toString(r));
                entry.setAttribute("green", Integer.toString(g));
                entry.setAttribute("blue", Integer.toString(b));
                if (hasAlpha) {
View Full Code Here

    public IIOMetadataNode getStandardCompressionNode() {
        IIOMetadataNode compression_node = new IIOMetadataNode("Compression");
        IIOMetadataNode node = null; // scratch node

        TIFFField f;

        f = getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
        if (f != null) {
            String compressionTypeName = null;
            int compression = f.getAsInt(0);
            boolean isLossless = true; // obligate initialization.
            if(compression == BaselineTIFFTagSet.COMPRESSION_NONE) {
                compressionTypeName = "None";
                isLossless = true;
            } else {
View Full Code Here

TOP

Related Classes of com.sun.media.imageio.plugins.tiff.TIFFField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.