Beispiel #1
0
        private static Dictionary <MagickFormat, MagickFormatInfo> LoadFormats()
        {
            var result = new Dictionary <MagickFormat, MagickFormatInfo>();

            var list     = IntPtr.Zero;
            var length   = (UIntPtr)0;
            var instance = new NativeMagickFormatInfo();

            try
            {
                list = instance.CreateList(out length);

                var ptr = list;
                MagickFormatInfo formatInfo;
                for (int i = 0; i < (int)length; i++)
                {
                    instance.GetInfo(list, i);

                    formatInfo = Create(instance);
                    if (formatInfo != null)
                    {
                        result[formatInfo.Format] = formatInfo;
                    }

                    ptr = new IntPtr(ptr.ToInt64() + i);
                }

                /* stealth coders */

                formatInfo = Create(instance, "DIB");
                if (formatInfo != null)
                {
                    result[formatInfo.Format] = formatInfo;
                }

                formatInfo = Create(instance, "TIF");
                if (formatInfo != null)
                {
                    result[formatInfo.Format] = formatInfo;
                }
            }
            finally
            {
                if (list != IntPtr.Zero)
                {
                    NativeMagickFormatInfo.DisposeList(list, (int)length);
                }
            }

            return(result);
        }
        private static Dictionary <MagickFormat, MagickFormatInfo> LoadFormats()
        {
            var formats = new Dictionary <MagickFormat, MagickFormatInfo>();

            var list     = IntPtr.Zero;
            var length   = (UIntPtr)0;
            var instance = new NativeMagickFormatInfo();

            try
            {
                list = instance.CreateList(out length);

                var ptr = list;
                for (int i = 0; i < (int)length; i++)
                {
                    instance.GetInfo(list, i);

                    var formatInfo = Create(instance);
                    if (formatInfo != null)
                    {
                        formats[formatInfo.Format] = formatInfo;
                    }

                    ptr = new IntPtr(ptr.ToInt64() + i);
                }

                AddStealthCoders(instance, formats);
            }
            finally
            {
                if (list != IntPtr.Zero)
                {
                    NativeMagickFormatInfo.DisposeList(list, (int)length);
                }
            }

            return(formats);
        }