/** * Sets long values into this tag. This method should be used for tags of * type {@link #TYPE_UNSIGNED_LONG}. This method will fail if: * <ul> * <li>The component type of this tag is not {@link #TYPE_UNSIGNED_LONG}.</li> * <li>The value overflows.</li> * <li>The component count in the definition for this tag is not 1.</li> * </ul> */ public boolean setValue( long value ) { return setValue( new long[]{ value } ); }
/** * Sets byte value into this tag. This method should be used for tags of * type {@link #TYPE_UNSIGNED_BYTE} or {@link #TYPE_UNDEFINED}. This method * will fail if: * <ul> * <li>The component type of this tag is not {@link #TYPE_UNSIGNED_BYTE} or * {@link #TYPE_UNDEFINED} .</li> * <li>The component count in the definition for this tag is not 1.</li> * </ul> */ public boolean setValue( byte value ) { return setValue( new byte[]{ value } ); }
/** * Sets long values into this tag. This method should be used for tags of * type {@link #TYPE_UNSIGNED_LONG}. This method will fail if: * <ul> * <li>The component type of this tag is not {@link #TYPE_UNSIGNED_LONG}.</li> * <li>The value overflows.</li> * <li>The component count in the definition for this tag is not 1.</li> * </ul> */ public boolean setValue( long value ) { return setValue( new long[]{ value } ); }
/** * Equivalent to setValue(value, 0, value.length). */ public boolean setValue( byte[] value ) { return setValue( value, 0, value.length ); }
/** * Equivalent to setValue(value, 0, value.length). */ public boolean setValue( byte[] value ) { return setValue( value, 0, value.length ); }
/** * Sets integer value into this tag. This method should be used for tags of * type {@link #TYPE_UNSIGNED_SHORT}, or {@link #TYPE_LONG}. This method * will fail if: * <ul> * <li>The component type of this tag is not {@link #TYPE_UNSIGNED_SHORT}, * {@link #TYPE_UNSIGNED_LONG}, or {@link #TYPE_LONG}.</li> * <li>The value overflows.</li> * <li>The component count in the definition of this tag is not 1.</li> * </ul> */ public boolean setValue( int value ) { return setValue( new int[]{ value } ); }
/** * Sets byte value into this tag. This method should be used for tags of * type {@link #TYPE_UNSIGNED_BYTE} or {@link #TYPE_UNDEFINED}. This method * will fail if: * <ul> * <li>The component type of this tag is not {@link #TYPE_UNSIGNED_BYTE} or * {@link #TYPE_UNDEFINED} .</li> * <li>The component count in the definition for this tag is not 1.</li> * </ul> */ public boolean setValue( byte value ) { return setValue( new byte[]{ value } ); }
/** * Sets integer value into this tag. This method should be used for tags of * type {@link #TYPE_UNSIGNED_SHORT}, or {@link #TYPE_LONG}. This method * will fail if: * <ul> * <li>The component type of this tag is not {@link #TYPE_UNSIGNED_SHORT}, * {@link #TYPE_UNSIGNED_LONG}, or {@link #TYPE_LONG}.</li> * <li>The value overflows.</li> * <li>The component count in the definition of this tag is not 1.</li> * </ul> */ public boolean setValue( int value ) { return setValue( new int[]{ value } ); }
/** * Sets a Rational value into this tag. This method should be used for tags * of type {@link #TYPE_UNSIGNED_RATIONAL}, or {@link #TYPE_RATIONAL}. This * method will fail if: * <ul> * <li>The component type of this tag is not {@link #TYPE_UNSIGNED_RATIONAL} * or {@link #TYPE_RATIONAL}.</li> * <li>The value overflows.</li> * <li>The component count in the definition for this tag is not 1.</li> * </ul> * * @see Rational */ public boolean setValue( Rational value ) { return setValue( new Rational[]{ value } ); }
/** * Sets a Rational value into this tag. This method should be used for tags * of type {@link #TYPE_UNSIGNED_RATIONAL}, or {@link #TYPE_RATIONAL}. This * method will fail if: * <ul> * <li>The component type of this tag is not {@link #TYPE_UNSIGNED_RATIONAL} * or {@link #TYPE_RATIONAL}.</li> * <li>The value overflows.</li> * <li>The component count in the definition for this tag is not 1.</li> * </ul> * * @see Rational */ public boolean setValue( Rational value ) { return setValue( new Rational[]{ value } ); }
/** * Sets a timestamp to this tag. The method converts the timestamp with the * format of "yyyy:MM:dd kk:mm:ss" and calls {@link #setValue(String)}. This * method will fail if the data type is not {@link #TYPE_ASCII} or the * component count of this tag is not 20 or undefined. * * @param time the number of milliseconds since Jan. 1, 1970 GMT * @return true on success */ public boolean setTimeValue( long time ) { // synchronized on TIME_FORMAT as SimpleDateFormat is not thread safe synchronized( TIME_FORMAT ) { return setValue( TIME_FORMAT.format( new Date( time ) ) ); } }
/** * Sets a timestamp to this tag. The method converts the timestamp with the * format of "yyyy:MM:dd kk:mm:ss" and calls {@link #setValue(String)}. This * method will fail if the data type is not {@link #TYPE_ASCII} or the * component count of this tag is not 20 or undefined. * * @param time the number of milliseconds since Jan. 1, 1970 GMT * @return true on success */ public boolean setTimeValue( long time ) { // synchronized on TIME_FORMAT as SimpleDateFormat is not thread safe synchronized( TIME_FORMAT ) { return setValue( TIME_FORMAT.format( new Date( time ) ) ); } }
/** * Sets the value of an ExifTag if it exists in the given IFD. The value * must be the correct type and length for that ExifTag. * * @param tagId a tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @param ifdId the IFD that the ExifTag is in. * @param val the value to set. * @return true if success, false if the ExifTag doesn't exist or the value * is the wrong type/length. * @see #setTagValue */ public boolean setTagValue( int tagId, int ifdId, Object val ) { ExifTag t = getTag( tagId, ifdId ); return t != null && t.setValue( val ); }
/** * Sets the value of an ExifTag if it exists in the given IFD. The value * must be the correct type and length for that ExifTag. * * @param tagId a tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @param ifdId the IFD that the ExifTag is in. * @param val the value to set. * @return true if success, false if the ExifTag doesn't exist or the value * is the wrong type/length. * @see #setTagValue */ public boolean setTagValue( int tagId, int ifdId, Object val ) { ExifTag t = getTag( tagId, ifdId ); return t != null && t.setValue( val ); }
IfdData ifd0 = mExifData.getIfdData( IfdId.TYPE_IFD_0 ); offset = calculateOffsetOfIfd( ifd0, offset ); ifd0.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_EXIF_IFD ) ).setValue( offset ); exifIfd.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_INTEROPERABILITY_IFD ) ).setValue( offset ); offset = calculateOffsetOfIfd( interIfd, offset ); ifd0.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_GPS_IFD ) ).setValue( offset ); offset = calculateOffsetOfIfd( gpsIfd, offset ); ifd1.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT ) ).setValue( offset ); offset += mExifData.getCompressedThumbnail().length; offset += mExifData.getStrip( i ).length; ifd1.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_STRIP_OFFSETS ) ).setValue( offsets );
IfdData ifd0 = mExifData.getIfdData( IfdId.TYPE_IFD_0 ); offset = calculateOffsetOfIfd( ifd0, offset ); ifd0.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_EXIF_IFD ) ).setValue( offset ); exifIfd.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_INTEROPERABILITY_IFD ) ).setValue( offset ); offset = calculateOffsetOfIfd( interIfd, offset ); ifd0.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_GPS_IFD ) ).setValue( offset ); offset = calculateOffsetOfIfd( gpsIfd, offset ); ifd1.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT ) ).setValue( offset ); offset += mExifData.getCompressedThumbnail().length; offset += mExifData.getStrip( i ).length; ifd1.getTag( ExifInterface.getTrueTagKey( ExifInterface.TAG_STRIP_OFFSETS ) ).setValue( offsets );
/** * Creates a tag for a defined tag constant in a given IFD if that IFD is * allowed for the tag. This method will fail anytime the appropriate * {@link ExifTag#setValue} for this tag's datatype would fail. * * @param tagId a tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @param ifdId the IFD that the tag should be in. * @param val the value of the tag to set. * @return an ExifTag object or null if one could not be constructed. * @see #buildTag */ public ExifTag buildTag( int tagId, int ifdId, Object val ) { int info = getTagInfo().get( tagId ); if( info == 0 || val == null ) { return null; } short type = getTypeFromInfo( info ); int definedCount = getComponentCountFromInfo( info ); boolean hasDefinedCount = ( definedCount != ExifTag.SIZE_UNDEFINED ); if( ! ExifInterface.isIfdAllowed( info, ifdId ) ) { return null; } ExifTag t = new ExifTag( getTrueTagKey( tagId ), type, definedCount, ifdId, hasDefinedCount ); if( ! t.setValue( val ) ) { return null; } return t; }
/** * Creates a tag for a defined tag constant in a given IFD if that IFD is * allowed for the tag. This method will fail anytime the appropriate * {@link ExifTag#setValue} for this tag's datatype would fail. * * @param tagId a tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @param ifdId the IFD that the tag should be in. * @param val the value of the tag to set. * @return an ExifTag object or null if one could not be constructed. * @see #buildTag */ public ExifTag buildTag( int tagId, int ifdId, Object val ) { int info = getTagInfo().get( tagId ); if( info == 0 || val == null ) { return null; } short type = getTypeFromInfo( info ); int definedCount = getComponentCountFromInfo( info ); boolean hasDefinedCount = ( definedCount != ExifTag.SIZE_UNDEFINED ); if( ! ExifInterface.isIfdAllowed( info, ifdId ) ) { return null; } ExifTag t = new ExifTag( getTrueTagKey( tagId ), type, definedCount, ifdId, hasDefinedCount ); if( ! t.setValue( val ) ) { return null; } return t; }
byte[] buf = new byte[Math.min(mDataAboveIfd0.length, (int) numOfComp)]; System.arraycopy( mDataAboveIfd0, (int) offset - DEFAULT_IFD0_OFFSET, buf, 0, buf.length ); tag.setValue( buf );
byte[] buf = new byte[(int) numOfComp]; System.arraycopy( mDataAboveIfd0, (int) offset - DEFAULT_IFD0_OFFSET, buf, 0, (int) numOfComp ); tag.setValue( buf );