/** * Gets the defined type for a tag. * * @param tagId a defined tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @return the type. * @see ExifTag#getDataType() */ @SuppressWarnings( "unused" ) public short getDefinedTagType( int tagId ) { int info = getTagInfo().get( tagId ); if( info == 0 ) { return - 1; } return getTypeFromInfo( info ); }
/** * Gets the defined type for a tag. * * @param tagId a defined tag constant, e.g. {@link #TAG_IMAGE_WIDTH}. * @return the type. * @see ExifTag#getDataType() */ @SuppressWarnings( "unused" ) public short getDefinedTagType( int tagId ) { int info = getTagInfo().get( tagId ); if( info == 0 ) { return - 1; } return getTypeFromInfo( 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; }