/// <summary> /// Add this metadata to an image. /// </summary> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <returns>True on success, false on failure.</returns> public bool AddToImage(FIBITMAP dib) { CheckDisposed(); if (dib.IsNull) { throw new ArgumentNullException("dib"); } if (Key == null) { throw new ArgumentNullException("Key"); } if (!selfCreated) { tag = FreeImage.CloneTag(tag); if (tag.IsNull) { throw new Exception("FreeImage.CloneTag() failed."); } selfCreated = true; } if (!FreeImage.SetMetadata(Model, dib, Key, tag)) { return(false); } FREE_IMAGE_MDMODEL _model = Model; string _key = Key; selfCreated = false; FreeImage.DeleteTag(tag); return(FreeImage.GetMetadata(_model, dib, _key, out tag)); }
/// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="model">The new model the tag should be of.</param> public MetadataTag(FREE_IMAGE_MDMODEL model) { this.model = model; tag = FreeImage.CreateTag(); selfCreated = true; if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) { Key = "XMLPacket"; } }
/// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="tag">The <see cref="FITAG"/> to represent.</param> /// <param name="model">The model of <paramref name="tag"/>.</param> public MetadataTag(FITAG tag, FREE_IMAGE_MDMODEL model) { if (tag.IsNull) { throw new ArgumentNullException("tag"); } this.tag = tag; this.model = model; selfCreated = false; if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) { Key = "XMLPacket"; } }
/// <summary> /// Gets or sets the <see cref="MetadataModel"/> of the specified type. /// <para>In case the getter returns <c>null</c> the model is not contained /// by the list.</para> /// <para><c>null</c> can be used calling the setter to destroy the model.</para> /// </summary> /// <param name="model">Type of the model.</param> /// <returns>The <see cref="FreeImageAPI.Metadata.MetadataModel"/> object of the specified type.</returns> public MetadataModel this[FREE_IMAGE_MDMODEL model] { get { for (int i = 0; i < data.Count; i++) { if (data[i].Model == model) { if (!data[i].Exists && hideEmptyModels) { return(null); } return(data[i]); } } return(null); } }
/// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="tag">The <see cref="FITAG"/> to represent.</param> /// <param name="dib">The bitmap <paramref name="tag"/> was extracted from.</param> public MetadataTag(FITAG tag, FIBITMAP dib) { if (tag.IsNull) { throw new ArgumentNullException("tag"); } if (dib.IsNull) { throw new ArgumentNullException("dib"); } this.tag = tag; model = GetModel(dib, tag); selfCreated = false; if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) { Key = "XMLPacket"; } }
public static extern FIMETADATA FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP dib, out FITAG tag);
private static unsafe extern byte* TagToString_(FREE_IMAGE_MDMODEL model, FITAG tag, uint Make);
/// <summary> /// Converts a FreeImage tag structure to a string that represents the interpreted tag value. /// The function is not thread safe. /// </summary> /// <param name="model">The metadata model.</param> /// <param name="tag">The interpreted tag value.</param> /// <param name="Make">Reserved.</param> /// <returns>The representing string.</returns> public static unsafe string TagToString(FREE_IMAGE_MDMODEL model, FITAG tag, uint Make) { return PtrToStr(TagToString_(model, tag, Make)); }
public static extern bool SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, FITAG tag);
/// <summary> /// Attach a new metadata tag to a FreeImage bitmap. /// </summary> /// <param name="model">The metadata model used to store the tag.</param> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <param name="key">The tag field name.</param> /// <param name="tag">The <see cref="MetadataTag"/> to be attached.</param> /// <returns>Returns true on success, false on failure.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dib"/> is null.</exception> public static bool SetMetadata( FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, MetadataTag tag) { if (dib.IsNull) { throw new ArgumentNullException("dib"); } return SetMetadata(model, dib, key, tag.tag); }
private static extern uint GetMetadataCountWindows(FREE_IMAGE_MDMODEL model, FIBITMAP dib);
private static extern bool SetMetadataWindows(FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, FITAG tag);
private static extern FIMETADATA FindFirstMetadataWindows(FREE_IMAGE_MDMODEL model, FIBITMAP dib, out FITAG tag);
private static extern bool GetMetadataLinux(FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, out FITAG tag);
/// <summary> /// Provides information about the first instance of a tag that matches the metadata model. /// </summary> /// <param name="model">The model to match.</param> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <param name="tag">Tag that matches the metadata model.</param> /// <returns>Unique search handle that can be used to call FindNextMetadata or FindCloseMetadata. /// Null if the metadata model does not exist.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dib"/> is null.</exception> public static FIMETADATA FindFirstMetadata( FREE_IMAGE_MDMODEL model, FIBITMAP dib, out MetadataTag tag) { if (dib.IsNull) { throw new ArgumentNullException("dib"); } FITAG _tag; FIMETADATA result = FindFirstMetadata(model, dib, out _tag); if (result.IsNull) { tag = null; return result; } tag = new MetadataTag(_tag, model); if (metaDataSearchHandler.ContainsKey(result)) { metaDataSearchHandler[result] = model; } else { metaDataSearchHandler.Add(result, model); } return result; }
public static extern uint GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP dib);
/// <summary> /// Retrieve a metadata attached to a FreeImage bitmap. /// </summary> /// <param name="model">The metadata model to look for.</param> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <param name="key">The metadata field name.</param> /// <param name="tag">A <see cref="MetadataTag"/> structure returned by the function.</param> /// <returns>Returns true on success, false on failure.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dib"/> is null.</exception> public static bool GetMetadata( FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, out MetadataTag tag) { if (dib.IsNull) { throw new ArgumentNullException("dib"); } FITAG _tag; bool result; if (GetMetadata(model, dib, key, out _tag)) { tag = new MetadataTag(_tag, model); result = true; } else { tag = null; result = false; } return result; }