using System; using System.Diagnostics; namespace FreeImageAPI.Plugins { /// /// Class representing a FreeImage format. /// public sealed class FreeImagePlugin { [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly FREE_IMAGE_FORMAT fif; /// /// Initializes a new instance of this class. /// /// The FreeImage format to wrap. internal FreeImagePlugin(FREE_IMAGE_FORMAT fif) { this.fif = fif; } /// /// Gets the format of this instance. /// public FREE_IMAGE_FORMAT FIFormat { get { return fif; } } /// /// Gets or sets whether this plugin is enabled. /// public bool Enabled { get { return (FreeImage.IsPluginEnabled(fif) == 1); } set { FreeImage.SetPluginEnabled(fif, value); } } /// /// Gets a string describing the format. /// public string Format { get { return FreeImage.GetFormatFromFIF(fif); } } /// /// Gets a comma-delimited file extension list describing the bitmap formats /// this plugin can read and/or write. /// public string ExtentsionList { get { return FreeImage.GetFIFExtensionList(fif); } } /// /// Gets a descriptive string that describes the bitmap formats /// this plugin can read and/or write. /// public string Description { get { return FreeImage.GetFIFDescription(fif); } } /// /// Returns a regular expression string that can be used by /// a regular expression engine to identify the bitmap. /// FreeImageQt makes use of this function. /// public string RegExpr { get { return FreeImage.GetFIFRegExpr(fif); } } /// /// Gets whether this plugin can load bitmaps. /// public bool SupportsReading { get { return FreeImage.FIFSupportsReading(fif); } } /// /// Gets whether this plugin can save bitmaps. /// public bool SupportsWriting { get { return FreeImage.FIFSupportsWriting(fif); } } /// /// Checks whether this plugin can save a bitmap in the desired data type. /// /// The desired image type. /// True if this plugin can save bitmaps as the desired type, else false. public bool SupportsExportType(FREE_IMAGE_TYPE type) { return FreeImage.FIFSupportsExportType(fif, type); } /// /// Checks whether this plugin can save bitmaps in the desired bit depth. /// /// The desired bit depth. /// True if this plugin can save bitmaps in the desired bit depth, else false. public bool SupportsExportBPP(int bpp) { return FreeImage.FIFSupportsExportBPP(fif, bpp); } /// /// Gets whether this plugin can load or save an ICC profile. /// public bool SupportsICCProfiles { get { return FreeImage.FIFSupportsICCProfiles(fif); } } /// /// Checks whether an extension is valid for this format. /// /// The desired extension. /// True if the extension is valid for this format, false otherwise. public bool ValidExtension(string extension) { return FreeImage.IsExtensionValidForFIF(fif, extension); } /// /// Checks whether an extension is valid for this format. /// /// The desired extension. /// The string comparison type. /// True if the extension is valid for this format, false otherwise. public bool ValidExtension(string extension, StringComparison comparisonType) { return FreeImage.IsExtensionValidForFIF(fif, extension, comparisonType); } /// /// Checks whether a filename is valid for this format. /// /// The desired filename. /// True if the filename is valid for this format, false otherwise. public bool ValidFilename(string filename) { return FreeImage.IsFilenameValidForFIF(fif, filename); } /// /// Checks whether a filename is valid for this format. /// /// The desired filename. /// The string comparison type. /// True if the filename is valid for this format, false otherwise. public bool ValidFilename(string filename, StringComparison comparisonType) { return FreeImage.IsFilenameValidForFIF(fif, filename, comparisonType); } /// /// Gets a descriptive string that describes the bitmap formats /// this plugin can read and/or write. /// /// A descriptive string that describes the bitmap formats. public override string ToString() { return Description; } } }