Package com.lightcrafts.image.metadata

Examples of com.lightcrafts.image.metadata.ImageMetadataDirectory


                                          int maxHeight )
        throws BadImageFileException, IOException, UnknownImageTypeException
    {
        RenderedImage image = null;

        final ImageMetadataDirectory dir =
            imageInfo.getMetadata().getDirectoryFor( OlympusDirectory.class );

        if ( dir != null ) {
            //
            // This should never be null, but just in case ...
            //
            image = JPEGImageType.getImageFromBuffer(
                imageInfo.getByteBuffer(),
                dir.getValue( OLYMPUS_PREVIEW_IMAGE_START ), 0,
                dir.getValue( OLYMPUS_PREVIEW_IMAGE_LENGTH ),
                maxWidth, maxHeight
            );
            if ( image == null )
                image = JPEGImageType.getImageFromBuffer(
                    imageInfo.getByteBuffer(),
                    dir.getValue( OLYMPUS_PREVIEW_IMAGE_START_2 ), 0,
                    dir.getValue( OLYMPUS_PREVIEW_IMAGE_LENGTH_2 ),
                    maxWidth, maxHeight
                );
            if ( image == null )
                image = JPEGImageType.getImageFromBuffer(
                    imageInfo.getByteBuffer(),
                    dir.getValue( OLYMPUS_CS_PREVIEW_IMAGE_START ), 0,
                    dir.getValue( OLYMPUS_CS_PREVIEW_IMAGE_LENGTH ),
                    maxWidth, maxHeight
                );
        }
        return  image != null ?
                image : super.getPreviewImage( imageInfo, maxWidth, maxHeight );
View Full Code Here


    public RenderedImage getPreviewImage( ImageInfo imageInfo, int maxWidth,
                                          int maxHeight )
        throws BadImageFileException, IOException, UnknownImageTypeException
    {
        final ImageMetadata metadata = imageInfo.getMetadata();
        final ImageMetadataDirectory dir =
            metadata.getDirectoryFor( CIFFDirectory.class );
        if ( dir != null ) {
            final ImageMetaValue colorSpace = dir.getValue( CIFF_COLOR_SPACE );
            ColorSpace cs = JAIContext.sRGBColorSpace;
            if ( colorSpace != null )
                switch ( colorSpace.getIntValue() ) {
                    case CIFF_COLOR_SPACE_ADOBE_RGB:
                        cs = JAIContext.adobeRGBColorSpace;
                        break;
                }
            final RenderedImage image = JPEGImageType.getImageFromBuffer(
                imageInfo.getByteBuffer(),
                dir.getValue( CIFF_PREVIEW_IMAGE_OFFSET ), 0,
                dir.getValue( CIFF_PREVIEW_IMAGE_LENGTH ),
                cs, maxWidth, maxHeight
            );
            if ( image != null )
                return image;
        }
View Full Code Here

        throws BadImageFileException, IOException, UnknownImageTypeException
    {
        if (!USE_EMBEDDED_PREVIEW)
            return super.getPreviewImage(imageInfo, maxWidth, maxHeight);

        final ImageMetadataDirectory dir =
            imageInfo.getMetadata().getDirectoryFor( MinoltaDirectory.class );
        if ( dir == null ) {
            //
            // This should never be null, but just in case ...
            //
            return null;
        }
        //
        // We can't just call createWritableRasterFrom() directly using the
        // ImageInfo.getByteBuffer() because Minolta is being annoying by
        // deliberately obfuscating the preview image: they change the first
        // byte of the JPEG from FF to some other value (I've seen 02).
        //
        // We have to redo a lot of what createWritableRasterFrom() does here
        // so we can get a hold of the buffer and change the fist byte back to
        // FF.  Because we have to modify it, it can't be a FileByteBuffer, so
        // we have to copy it into an ArrayByteBuffer.
        //
        final ImageMetaValue offsetValue =
            dir.getValue( MINOLTA_PREVIEW_IMAGE_START );
        final ImageMetaValue lengthValue =
            dir.getValue( MINOLTA_PREVIEW_IMAGE_LENGTH );
        if ( offsetValue == null || lengthValue == null )
            return null;
        final int offset = offsetValue.getIntValue();
        final int length = lengthValue.getIntValue();
        if ( offset <= 0 || length <= 0 )
View Full Code Here

     * @return Returns said tag name or <code>null</code> if it either has
     * no owning {@link ImageMetadataDirectory} or said directory has no such
     * tag.
     */
    public final String getTagName() {
        final ImageMetadataDirectory dir = getOwningDirectory();
        return  dir != null ?
                dir.getTagNameFor( getOwningTagID(), false ) : null;
    }
View Full Code Here

     * @return Returns said string.
     */
    protected String toStringImpl() {
        if ( m_value == null )
            return null;
        final ImageMetadataDirectory owningDir = getOwningDirectory();
        final int tagID = getOwningTagID();
        final StringBuilder sb = new StringBuilder();
        boolean comma = false;
        for ( String value : m_value ) {
            if ( !comma )
                comma = true;
            else
                sb.append( ',' );
            if ( owningDir != null )
                value = owningDir.getTagValueLabelFor( tagID, value );
            sb.append( value );
        }
        return sb.toString();
    }
View Full Code Here

     *
     * @return Returns said {@link String}.
     */
    public final synchronized String toString() {
        if ( m_toStringCache == null ) {
            final ImageMetadataDirectory dir = getOwningDirectory();
            if ( dir != null ) {
                //
                // First, consult the the owning directory to see if this
                // metadata value needs special-handling.
                //
                m_toStringCache = dir.valueToString( this );
                if ( m_toStringCache == null ) {
                    //
                    // The owning directory didn't create a string for it
                    // because it didn't need special-handling, so revert to
                    // the ordinary way to create its string.
View Full Code Here

     * @return Returns said string.
     */
    protected final String toStringImpl() {
        if ( m_value == null )
            return null;
        final ImageMetadataDirectory owningDir = getOwningDirectory();
        final int tagID = getOwningTagID();
        final StringBuilder sb = new StringBuilder();
        boolean comma = false;
        for ( long value : m_value ) {
            if ( !comma )
                comma = true;
            else
                sb.append( ',' );
            final String valueAsString = owningDir != null ?
                owningDir.getTagValueLabelFor( tagID, value ) :
                Long.toString( value );
            sb.append( valueAsString );
        }
        return sb.toString();
    }
View Full Code Here

    RelatedDocsMenu(ComboFrame frame, ImageMetadata meta) {
        this.frame = frame;

        setIcon(Icon);

        ImageMetadataDirectory coreDir =
            meta.getDirectoryFor(CoreDirectory.class);

        ImageMetaValue fileValue =
            coreDir.getValue(CORE_FILE_NAME);
        ImageMetaValue dirValue =
            coreDir.getValue(CORE_DIR_NAME);

        imageFile = new File(dirValue.toString(), fileValue.toString());

        updateFromDatabase();
View Full Code Here

    RatingMetadataEntry() {
        super(CoreDirectory.class, CoreTags.CORE_RATING);
    }

    public RatingObject getValue(ImageMetadata meta) {
        ImageMetadataDirectory dir = meta.getDirectoryFor(clazz);
        if (dir != null) {
            ImageMetaValue value = dir.getValue(tagID);
            return new RatingObject(value);
        }
        return new RatingObject(null);
    }
View Full Code Here

    int getTagID() {
        return tagID;
    }

    public String getLabel(ImageMetadata meta) {
        ImageMetadataDirectory dir = meta.getDirectoryFor(clazz);
        if (dir != null) {
            String label = dir.getTagLabelFor(tagID);
            return label;
        }
        try {
            return clazz.newInstance().getTagLabelFor(tagID);
        }
View Full Code Here

TOP

Related Classes of com.lightcrafts.image.metadata.ImageMetadataDirectory

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.