/** * Creates a tag for a defined tag constant in the tag's default IFD. * * @param tagId a tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @param val the tag's value. * @return an ExifTag object. */ public ExifTag buildTag( int tagId, Object val ) { int ifdId = getTrueIfd( tagId ); return buildTag( tagId, ifdId, val ); }
/** * Creates a tag for a defined tag constant in the tag's default IFD. * * @param tagId a tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @param val the tag's value. * @return an ExifTag object. */ public ExifTag buildTag( int tagId, Object val ) { int ifdId = getTrueIfd( tagId ); return buildTag( tagId, ifdId, val ); }
/** * Creates, formats, and sets the DateTimeStamp tag for one of: * {@link #TAG_DATE_TIME}, {@link #TAG_DATE_TIME_DIGITIZED}, * {@link #TAG_DATE_TIME_ORIGINAL}. * * @param tagId one of the DateTimeStamp tags. * @param timestamp a timestamp to format. * @param timezone a TimeZone object. * @return true if success, false if the tag could not be set. */ public boolean addDateTimeStampTag( int tagId, long timestamp, TimeZone timezone ) { if( tagId == TAG_DATE_TIME || tagId == TAG_DATE_TIME_DIGITIZED || tagId == TAG_DATE_TIME_ORIGINAL ) { mDateTimeStampFormat.setTimeZone( timezone ); ExifTag t = buildTag( tagId, mDateTimeStampFormat.format( timestamp ) ); if( t == null ) { return false; } setTag( t ); } else { return false; } return true; }
/** * Creates, formats, and sets the DateTimeStamp tag for one of: * {@link #TAG_DATE_TIME}, {@link #TAG_DATE_TIME_DIGITIZED}, * {@link #TAG_DATE_TIME_ORIGINAL}. * * @param tagId one of the DateTimeStamp tags. * @param timestamp a timestamp to format. * @param timezone a TimeZone object. * @return true if success, false if the tag could not be set. */ public boolean addDateTimeStampTag( int tagId, long timestamp, TimeZone timezone ) { if( tagId == TAG_DATE_TIME || tagId == TAG_DATE_TIME_DIGITIZED || tagId == TAG_DATE_TIME_ORIGINAL ) { mDateTimeStampFormat.setTimeZone( timezone ); ExifTag t = buildTag( tagId, mDateTimeStampFormat.format( timestamp ) ); if( t == null ) { return false; } setTag( t ); } else { return false; } return true; }
/** * Creates and sets all to the GPS tags for a give latitude and longitude. * * @param latitude a GPS latitude coordinate. * @param longitude a GPS longitude coordinate. * @return true if success, false if they could not be created or set. */ @SuppressWarnings( "unused" ) public boolean addGpsTags( double latitude, double longitude ) { ExifTag latTag = buildTag( TAG_GPS_LATITUDE, toExifLatLong( latitude ) ); ExifTag longTag = buildTag( TAG_GPS_LONGITUDE, toExifLatLong( longitude ) ); ExifTag latRefTag = buildTag( TAG_GPS_LATITUDE_REF, latitude >= 0 ? GpsLatitudeRef.NORTH : GpsLatitudeRef.SOUTH ); ExifTag longRefTag = buildTag( TAG_GPS_LONGITUDE_REF, longitude >= 0 ? GpsLongitudeRef.EAST : GpsLongitudeRef.WEST ); if( latTag == null || longTag == null || latRefTag == null || longRefTag == null ) { return false; } setTag( latTag ); setTag( longTag ); setTag( latRefTag ); setTag( longRefTag ); return true; }
/** * Creates and sets all to the GPS tags for a give latitude and longitude. * * @param latitude a GPS latitude coordinate. * @param longitude a GPS longitude coordinate. * @return true if success, false if they could not be created or set. */ @SuppressWarnings( "unused" ) public boolean addGpsTags( double latitude, double longitude ) { ExifTag latTag = buildTag( TAG_GPS_LATITUDE, toExifLatLong( latitude ) ); ExifTag longTag = buildTag( TAG_GPS_LONGITUDE, toExifLatLong( longitude ) ); ExifTag latRefTag = buildTag( TAG_GPS_LATITUDE_REF, latitude >= 0 ? GpsLatitudeRef.NORTH : GpsLatitudeRef.SOUTH ); ExifTag longRefTag = buildTag( TAG_GPS_LONGITUDE_REF, longitude >= 0 ? GpsLongitudeRef.EAST : GpsLongitudeRef.WEST ); if( latTag == null || longTag == null || latRefTag == null || longRefTag == null ) { return false; } setTag( latTag ); setTag( longTag ); setTag( latRefTag ); setTag( longRefTag ); return true; }
/** * Creates and sets the GPS timestamp tag. * * @param timestamp a GPS timestamp. * @return true if success, false if could not be created or set. */ @SuppressWarnings( "unused" ) public boolean addGpsDateTimeStampTag( long timestamp ) { ExifTag t = buildTag( TAG_GPS_DATE_STAMP, mGPSDateStampFormat.format( timestamp ) ); if( t == null ) { return false; } setTag( t ); mGPSTimeStampCalendar.setTimeInMillis( timestamp ); t = buildTag( TAG_GPS_TIME_STAMP, new Rational[]{ new Rational( mGPSTimeStampCalendar.get( Calendar.HOUR_OF_DAY ), 1 ), new Rational( mGPSTimeStampCalendar.get( Calendar.MINUTE ), 1 ), new Rational( mGPSTimeStampCalendar.get( Calendar.SECOND ), 1 ) } ); if( t == null ) { return false; } setTag( t ); return true; }
/** * Creates and sets the GPS timestamp tag. * * @param timestamp a GPS timestamp. * @return true if success, false if could not be created or set. */ @SuppressWarnings( "unused" ) public boolean addGpsDateTimeStampTag( long timestamp ) { ExifTag t = buildTag( TAG_GPS_DATE_STAMP, mGPSDateStampFormat.format( timestamp ) ); if( t == null ) { return false; } setTag( t ); mGPSTimeStampCalendar.setTimeInMillis( timestamp ); t = buildTag( TAG_GPS_TIME_STAMP, new Rational[]{ new Rational( mGPSTimeStampCalendar.get( Calendar.HOUR_OF_DAY ), 1 ), new Rational( mGPSTimeStampCalendar.get( Calendar.MINUTE ), 1 ), new Rational( mGPSTimeStampCalendar.get( Calendar.SECOND ), 1 ) } ); if( t == null ) { return false; } setTag( t ); return true; }