Package com.lightcrafts.utils.file

Examples of com.lightcrafts.utils.file.OrderableRandomAccessFile


        //
        // This code is based on the code in TIFFMetadataReader but it's been
        // simplified and does much less error-checking because we just wrote
        // the TIFF file ourselves so we know it's valid.
        //
        final OrderableRandomAccessFile file =
            new OrderableRandomAccessFile( fileName, "rw" );
        try {
            if ( file.readShort() == TIFF_LITTLE_ENDIAN )
                file.order( ByteOrder.LITTLE_ENDIAN );
            file.seek( TIFF_HEADER_SIZE - TIFF_INT_SIZE );
            int ifdOffset = file.readInt();
            while ( ifdOffset > 0 ) {
                file.seek( ifdOffset );
                final int entryCount = file.readUnsignedShort();
                for ( int entry = 0; entry < entryCount; ++entry ) {
                    final int entryOffset =
                        TIFFMetadataReader.calcIFDEntryOffset( ifdOffset, entry );
                    file.seek( entryOffset );
                    final int tagID = file.readUnsignedShort();
                    if ( tagID == TIFF_PHOTOSHOP_IMAGE_RESOURCES ) {
                        file.seek( file.getFilePointer() - TIFF_SHORT_SIZE );
                        file.writeShort( TIFF_EXIF_IFD_POINTER );
                        file.writeShort( TIFF_FIELD_TYPE_ULONG );
                        file.writeInt( 1 );
                        final int subdirOffset = file.readInt();
                        fixEXIFDirectory( file, subdirOffset, 0 );
                        return;
                    }
                }
                ifdOffset = file.readInt();
            }
        }
        finally {
            file.close();
        }
    }
View Full Code Here

TOP

Related Classes of com.lightcrafts.utils.file.OrderableRandomAccessFile

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.