void Check(MainForm form, IWICBitmapEncoderInfo info, Tag tag)
        {
            ComponentInfoHelper.CheckNotReserverdGuid(form, info.GetContainerFormat, this);

            tag.PixelFormats = PixelFormatInfoRule.CheckPixelFormats(form, this, info.GetPixelFormats);

            ComponentInfoHelper.CheckVersion(form, info.GetColorManagementVersion, this);
            ComponentInfoHelper.CheckCommaSeparatedString(form, info.GetMimeTypes, ComponentInfoHelper.MimeMask, this);

            tag.Extensions = ComponentInfoHelper.CheckCommaSeparatedString(form, info.GetFileExtensions, ComponentInfoHelper.ExtensionMask, this);

            if (!info.DoesSupportMultiframe() && info.DoesSupportAnimation())
            {
                form.Add(this, Resources.DecoderAnimationIfMultiframe);
            }
            tag.SupportsMultiframe = info.DoesSupportMultiframe();
        }
示例#2
0
        protected override void RunOverride(MainForm form, object tag)
        {
            TempFileCollection    files   = null;
            IWICImagingFactory    factory = (IWICImagingFactory) new WICImagingFactory();
            IWICBitmapEncoderInfo info    = null;
            IWICBitmapEncoder     encoder = null;
            IWICStream            stream  = null;
            int i = 0;

            try
            {
                files = new TempFileCollection();
                info  = (IWICBitmapEncoderInfo)factory.CreateComponentInfo(Parent.Clsid);

                do
                {
                    stream.ReleaseComObject();
                    encoder.ReleaseComObject();
                    stream = factory.CreateStream();
                    stream.InitializeFromFilename(files.AddExtension(i.ToString(CultureInfo.InvariantCulture)), NativeMethods.GenericAccessRights.GENERIC_WRITE);
                    i++;
                    try
                    {
                        encoder = info.CreateInstance();
                        encoder.Initialize(stream, WICBitmapEncoderCacheOption.WICBitmapEncoderNoCache);
                    }
                    catch (Exception e)
                    {
                        form.Add(this, e.TargetSite.ToString(Resources._0_Failed), new DataEntry(e));
                        break;
                    }
                }while(ProcessEncoder(form, encoder, tag));
            }
            finally
            {
                factory.ReleaseComObject();
                info.ReleaseComObject();
                encoder.ReleaseComObject();
                stream.ReleaseComObject();
                if (files != null)
                {
                    files.Delete();
                }
            }
        }