/** * Checks whether a tag has a defined number of elements. * * @param tagId a defined tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @return true if the tag has a defined number of elements. */ @SuppressWarnings( "unused" ) public boolean isTagCountDefined( int tagId ) { int info = getTagInfo().get( tagId ); // No value in info can be zero, as all tags have a non-zero type return info != 0 && getComponentCountFromInfo( info ) != ExifTag.SIZE_UNDEFINED; }
/** * Checks whether a tag has a defined number of elements. * * @param tagId a defined tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @return true if the tag has a defined number of elements. */ @SuppressWarnings( "unused" ) public boolean isTagCountDefined( int tagId ) { int info = getTagInfo().get( tagId ); // No value in info can be zero, as all tags have a non-zero type return info != 0 && getComponentCountFromInfo( info ) != ExifTag.SIZE_UNDEFINED; }
/** * Gets the defined number of elements for a tag. * * @param tagId a defined tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @return the number of elements or {@link ExifTag#SIZE_UNDEFINED} if the * tag or the number of elements is not defined. */ @SuppressWarnings( "unused" ) public int getDefinedTagCount( int tagId ) { int info = getTagInfo().get( tagId ); if( info == 0 ) { return ExifTag.SIZE_UNDEFINED; } return getComponentCountFromInfo( info ); }
/** * Gets the defined number of elements for a tag. * * @param tagId a defined tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @return the number of elements or {@link ExifTag#SIZE_UNDEFINED} if the * tag or the number of elements is not defined. */ @SuppressWarnings( "unused" ) public int getDefinedTagCount( int tagId ) { int info = getTagInfo().get( tagId ); if( info == 0 ) { return ExifTag.SIZE_UNDEFINED; } return getComponentCountFromInfo( info ); }
protected ExifTag buildUninitializedTag( int tagId ) { int info = getTagInfo().get( tagId ); if( info == 0 ) { return null; } short type = getTypeFromInfo( info ); int definedCount = getComponentCountFromInfo( info ); boolean hasDefinedCount = ( definedCount != ExifTag.SIZE_UNDEFINED ); int ifdId = getTrueIfd( tagId ); return new ExifTag( getTrueTagKey( tagId ), type, definedCount, ifdId, hasDefinedCount ); }
protected ExifTag buildUninitializedTag( int tagId ) { int info = getTagInfo().get( tagId ); if( info == 0 ) { return null; } short type = getTypeFromInfo( info ); int definedCount = getComponentCountFromInfo( info ); boolean hasDefinedCount = ( definedCount != ExifTag.SIZE_UNDEFINED ); int ifdId = getTrueIfd( tagId ); return new ExifTag( getTrueTagKey( tagId ), type, definedCount, ifdId, hasDefinedCount ); }
protected int getTagDefinitionForTag( short tagId, short type, int count, int ifd ) { int[] defs = getTagDefinitionsForTagId( tagId ); if( defs == null ) { return TAG_NULL; } SparseIntArray infos = getTagInfo(); int ret = TAG_NULL; for( int i : defs ) { int info = infos.get( i ); short def_type = getTypeFromInfo( info ); int def_count = getComponentCountFromInfo( info ); int[] def_ifds = getAllowedIfdsFromInfo( info ); boolean valid_ifd = false; for( int j : def_ifds ) { if( j == ifd ) { valid_ifd = true; break; } } if( valid_ifd && type == def_type && ( count == def_count || def_count == ExifTag.SIZE_UNDEFINED ) ) { ret = i; break; } } return ret; }
protected int getTagDefinitionForTag( short tagId, short type, int count, int ifd ) { int[] defs = getTagDefinitionsForTagId( tagId ); if( defs == null ) { return TAG_NULL; } SparseIntArray infos = getTagInfo(); int ret = TAG_NULL; for( int i : defs ) { int info = infos.get( i ); short def_type = getTypeFromInfo( info ); int def_count = getComponentCountFromInfo( info ); int[] def_ifds = getAllowedIfdsFromInfo( info ); boolean valid_ifd = false; for( int j : def_ifds ) { if( j == ifd ) { valid_ifd = true; break; } } if( valid_ifd && type == def_type && ( count == def_count || def_count == ExifTag.SIZE_UNDEFINED ) ) { ret = i; break; } } return ret; }
/** * 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; }