Example #1
0
        private static ProcessImageResult processImage(WicDecoder dec, WicProcessingContext ctx, Stream ostm)
        {
            var frm = new WicFrameReader(ctx);

            WicTransforms.AddMetadataReader(ctx);

            ctx.FinalizeSettings();

            WicTransforms.AddNativeScaler(ctx);
            WicTransforms.AddExifRotator(ctx);
            WicTransforms.AddConditionalCache(ctx);
            WicTransforms.AddCropper(ctx);
            WicTransforms.AddPixelFormatConverter(ctx);
            WicTransforms.AddScaler(ctx);
            WicTransforms.AddColorspaceConverter(ctx);
            MagicTransforms.AddMatte(ctx);
            MagicTransforms.AddPad(ctx);
            WicTransforms.AddIndexedColorConverter(ctx);

            var enc = new WicEncoder(ctx, ostm.AsIStream());

            enc.WriteSource(ctx);

            return(new ProcessImageResult {
                Settings = ctx.UsedSettings, Stats = ctx.Stats
            });
        }
        private static ProcessImageResult processImage(PipelineContext ctx, Stream ostm)
        {
            var frame = (WicImageFrame)ctx.ImageContainer.GetFrame(ctx.Settings.FrameIndex);

            ctx.AddFrameDisposer();
            ctx.ImageFrame = frame;
            ctx.Source     = frame.Source;

            MagicTransforms.AddGifFrameBuffer(ctx);

            ctx.FinalizeSettings();

            WicTransforms.AddColorProfileReader(ctx);
            WicTransforms.AddNativeScaler(ctx);
            WicTransforms.AddExifFlipRotator(ctx);
            WicTransforms.AddCropper(ctx);
            WicTransforms.AddPixelFormatConverter(ctx);
            WicTransforms.AddHybridScaler(ctx);
            WicTransforms.AddScaler(ctx);
            WicTransforms.AddColorspaceConverter(ctx);
            MagicTransforms.AddMatte(ctx);
            MagicTransforms.AddPad(ctx);
            WicTransforms.AddIndexedColorConverter(ctx);

            using var enc = new WicImageEncoder(ctx.Settings.SaveFormat, ostm);
            using var frm = new WicImageEncoderFrame(ctx, enc);
            frm.WriteSource(ctx);
            enc.Commit();

            return(new ProcessImageResult(ctx.UsedSettings, ctx.Stats));
        }
#pragma warning restore 1573

        internal static ProcessImageResult WriteOutput(PipelineContext ctx, Stream ostm)
        {
            MagicTransforms.AddExternalFormatConverter(ctx);
            WicTransforms.AddIndexedColorConverter(ctx);

            var enc = new WicEncoder(ctx, ostm.AsIStream());

            enc.WriteSource(ctx);

            return(new ProcessImageResult(ctx.UsedSettings, ctx.Stats));
        }
        private static ProcessImageResult executePipeline(WicProcessingContext ctx, Stream ostm)
        {
            WicTransforms.AddIndexedColorConverter(ctx);

            var enc = new WicEncoder(ctx, ostm.AsIStream());

            enc.WriteSource(ctx);

            return(new ProcessImageResult {
                Settings = ctx.UsedSettings, Stats = ctx.Stats
            });
        }