Пример #1
0
        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));
        }