Class that can be used to initialize Magick.NET.
Ejemplo n.º 1
0
        public static IMagickFormatInfo GetFormatInformation(Stream stream)
        {
            var startPosition = stream.Position;

            try
            {
                var info = new MagickImageInfo(stream);
                return(MagickNET.GetFormatInformation(info.Format));
            }
            catch
            {
                stream.Position = startPosition;

                return(GetFormatInformationFromHeader(stream));
            }
            finally
            {
                stream.Position = startPosition;
            }
        }
Ejemplo n.º 2
0
        private static void ExtractLibrary()
        {
#if Q8
            string name = "Magick.NET-Q8-" + (NativeLibrary.Is64Bit ? "x64" : "x86");
#elif Q16
            string name = "Magick.NET-Q16-" + (NativeLibrary.Is64Bit ? "x64" : "x86");
#elif Q16HDRI
            string name = "Magick.NET-Q16-HDRI-" + (NativeLibrary.Is64Bit ? "x64" : "x86");
#else
#error Not implemented!
#endif
            string cacheDirectory = CreateCacheDirectory();
            string tempFile       = Path.Combine(cacheDirectory, name + ".Native.dll");

            WriteAssembly(tempFile);
            WriteXmlResources(cacheDirectory);

            NativeMethods.SetDllDirectory(cacheDirectory);

            MagickNET.Initialize(cacheDirectory);
        }
Ejemplo n.º 3
0
        private IImageOptimizer GetOptimizer(Stream stream)
        {
            long            position  = stream.Position;
            MagickImageInfo imageInfo = new MagickImageInfo(stream);

            stream.Position = position;

            MagickFormatInfo info = MagickNET.GetFormatInformation(imageInfo.Format);

            foreach (IImageOptimizer optimizer in _optimizers)
            {
                if (optimizer.Format.Module == info.Module)
                {
                    return(optimizer);
                }
            }

            if (IgnoreUnsupportedFormats)
            {
                return(null);
            }

            throw new MagickCorruptImageErrorException("Invalid format, supported formats are: " + SupportedFormats);
        }
Ejemplo n.º 4
0
        private static MagickFormat GetModule(MagickFormat format)
        {
            MagickFormatInfo formatInfo = MagickNET.GetFormatInformation(format);

            return(formatInfo.Module);
        }
Ejemplo n.º 5
0
 ///<summary>
 /// Returns the format information. The extension of the supplied file is used to determine
 /// the format.
 ///</summary>
 /// <param name="file">The file to check.</param>
 public static MagickFormatInfo Create(FileInfo file)
 {
     return(MagickNET.GetFormatInformation(file));
 }
Ejemplo n.º 6
0
 ///<summary>
 /// Returns the format information of the specified format.
 ///</summary>
 ///<param name="format">The image format.</param>
 public static MagickFormatInfo Create(MagickFormat format)
 {
     return(MagickNET.GetFormatInformation(format));
 }