Beispiel #1
0
        private void init(IWICBitmapDecoder dec, WicProcessingContext ctx)
        {
            Decoder = AddRef(dec);

            ctx.ContainerFormat     = dec.GetContainerFormat();
            ctx.ContainerFrameCount = dec.GetFrameCount();
        }
Beispiel #2
0
        private WicImageContainer(IWICBitmapDecoder dec, WicPipelineContext ctx)
        {
            wicContext = ctx;
            WicDecoder = ctx.AddRef(dec);

            WicContainerFormat = dec.GetContainerFormat();
            ContainerFormat    = formatMap.GetValueOrDefault(WicContainerFormat, FileFormat.Unknown);
            FrameCount         = (int)dec.GetFrameCount();
        }
Beispiel #3
0
        public static WicImageContainer Create(IWICBitmapDecoder dec, PipelineContext ctx)
        {
            var fmt = WicImageDecoder.FormatMap.GetValueOrDefault(dec.GetContainerFormat(), FileFormat.Unknown);

            if (fmt == FileFormat.Gif)
            {
                return(ctx.AddDispose(new WicGifContainer(dec, ctx.WicContext)));
            }

            return(new WicImageContainer(dec, ctx.WicContext, fmt));
        }
Beispiel #4
0
        private void init(IWICBitmapDecoder dec, WicProcessingContext ctx)
        {
            ctx.Decoder = this;

            if (dec is null)
            {
                return;
            }

            Decoder = ctx.AddRef(dec);

            WicContainerFormat = dec.GetContainerFormat();
            ContainerFormat    = formatMap.GetValueOrDefault(WicContainerFormat, () => FileFormat.Unknown);
            FrameCount         = dec.GetFrameCount();
        }
Beispiel #5
0
    private static WicBitmapSource LoadBitmapSource(Stream stream, int frameIndex, WICDecodeOptions metadataOptions)
    {
        var wfac = (IWICImagingFactory) new WICImagingFactory();
        IWICBitmapDecoder decoder = null;

        try
        {
            decoder = wfac.CreateDecoderFromStream(new ManagedIStream(stream), null, metadataOptions);
            return(new WicBitmapSource(decoder.GetFrame(frameIndex), decoder.GetContainerFormat()));
        }
        finally
        {
            Release(decoder);
            Release(wfac);
        }
    }
Beispiel #6
0
    private static WicBitmapSource LoadBitmapSource(string filePath, int frameIndex, WICDecodeOptions metadataOptions)
    {
        var wfac = (IWICImagingFactory) new WICImagingFactory();
        IWICBitmapDecoder decoder = null;

        try
        {
            decoder = wfac.CreateDecoderFromFilename(filePath, null, GenericAccessRights.GENERIC_READ, metadataOptions);
            return(new WicBitmapSource(decoder.GetFrame(frameIndex), decoder.GetContainerFormat()));
        }
        finally
        {
            Release(decoder);
            Release(wfac);
        }
    }
        protected override void RunOverride(MainForm form, object tag)
        {
            IWICImagingFactory    factory = (IWICImagingFactory) new WICImagingFactory();
            IWICBitmapDecoderInfo info    = (IWICBitmapDecoderInfo)factory.CreateComponentInfo(Parent.Clsid);
            Guid cf;

            info.GetContainerFormat(out cf);
            IWICBitmapDecoder decoder = null;

            try
            {
                decoder = info.CreateInstance();
                Guid containerFormat;
                try
                {
                    decoder.GetContainerFormat(out containerFormat);
                    if (containerFormat != cf)
                    {
                        form.Add(this, Resources.ContainerFormatsDoNotMatch, new DataEntry(Resources.Actual, cf), new DataEntry(Resources.Expected, containerFormat));
                    }
                }
                catch (Exception e)
                {
                    form.Add(this, e.TargetSite.ToString(Resources._0_Failed), new DataEntry(e));
                }

                ComponentInfoHelper.CheckEquals <IWICBitmapDecoderInfo>(form, decoder.GetDecoderInfo, this, Extensions.CompareInfos);
            }
            finally
            {
                factory.ReleaseComObject();
                info.ReleaseComObject();
                decoder.ReleaseComObject();
            }

            base.RunOverride(form, tag);
        }