private static void processImage(WicDecoder dec, WicProcessingContext ctx, Stream ostm)
        {
            using (var frm = new WicFrameReader(dec, ctx))
                using (var met = new WicMetadataReader(frm))
                {
                    if (!ctx.Settings.Normalized)
                    {
                        ctx.Settings.Fixup((int)ctx.Width, (int)ctx.Height, ctx.IsRotated90);
                    }

                    if (EnablePlanarPipeline && ctx.SupportsPlanar)
                    {
                        MagicPlanarImageProcessor.ProcessImage(met, ctx, ostm);
                        return;
                    }

                    using (var qsc = new WicNativeScaler(met))
                        using (var rot = new WicExifRotator(qsc))
                            using (var cac = new WicConditionalCache(rot))
                                using (var crp = new WicCropper(cac))
                                    using (var pix = new WicPixelFormatConverter(crp))
                                        using (var cmy = new WicCmykConverter(pix))
                                            using (var res = new WicScaler(cmy, true))
                                                using (var lll = new WicConvertToCustomPixelFormat(res))
                                                    using (var mmm = new WicHighQualityScaler(lll))
                                                        using (var mat = new WicMatteTransform(mmm))
                                                            using (var ggg = new WicConvertFromCustomPixelFormat(mat))
                                                                using (var csc = new WicColorspaceConverter(ggg))
                                                                    using (var sss = new WicUnsharpMask(csc))
                                                                        using (var dit = new WicPaletizer(sss))
                                                                            using (var enc = new WicEncoder(ostm.AsIStream(), ctx))
                                                                                enc.WriteSource(dit);
                }
        }
Exemple #2
0
        private static void processImage(WicDecoder dec, WicProcessingContext ctx, Stream ostm)
        {
            using (var frm = new WicFrameReader(dec, ctx))
                using (var met = new WicMetadataReader(frm))
                {
                    if (!ctx.Settings.Normalized)
                    {
                        ctx.Settings.Fixup((int)ctx.Width, (int)ctx.Height, ctx.IsRotated90);
                    }

                    ctx.Settings.HybridMode = HybridScaleMode.Turbo;
                    //ctx.NeedsCache = true;

                    using (var qsc = new WicNativeScaler(met))
                        using (var rot = new WicExifRotator(qsc))
                            using (var cac = new WicConditionalCache(rot))
                                using (var crp = new WicCropper(cac))
                                    using (var pix = new WicPixelFormatConverter(crp))
                                        using (var cmy = new WicCmykConverter(pix))
                                            using (var res = new WicScaler(cmy))
                                                using (var csc = new WicColorspaceConverter(res))
                                                    using (var mat = new WicMatteTransform(csc))
                                                        using (var pal = new WicPaletizer(mat, 256))
                                                            using (var enc = new WicEncoder(ostm.AsIStream(), ctx))
                                                                enc.WriteSource(pal);
                }
        }
        private static void processImage(WicDecoder dec, WicProcessingContext ctx, Stream ostm)
        {
            using (var frm = new WicFrameReader(dec, ctx))
                using (var met = new WicMetadataReader(frm))
                {
                    if (!ctx.Settings.Normalized)
                    {
                        ctx.Settings.Fixup((int)ctx.Width, (int)ctx.Height, ctx.IsRotated90);
                    }

                    bool mod1   = (!ctx.IsSubsampled || ctx.Settings.HybridScaleRatio > 1d || (ctx.Settings.Crop.Width % 2 == 0 && ctx.Settings.Crop.Height % 2 == 0) || (ctx.Settings.Crop.Width == ctx.Width && ctx.Settings.Crop.Height == ctx.Height));
                    bool planar = ctx.SupportsPlanar && mod1;
                    if (planar && ctx.Settings.HybridMode != HybridScaleMode.Off)
                    {
                        MagicPlanarImageProcessor.ProcessImage(met, ctx, ostm);
                        return;
                    }

                    using (var qsc = new WicNativeScaler(met))
                        using (var rot = new WicExifRotator(qsc))
                            using (var cac = new WicConditionalCache(rot))
                                using (var crp = new WicCropper(cac))
                                    using (var pix = new WicPixelFormatConverter(crp))
                                        using (var cmy = new WicCmykConverter(pix))
                                            using (var res = new WicScaler(cmy, true))
                                                using (var lll = new WicGammaExpand(res))
                                                    using (var mmm = new WicHighQualityScaler(lll))
                                                        using (var mat = new WicMatteTransform(mmm))
                                                            using (var ggg = new WicGammaCompress(mat))
                                                                using (var csc = new WicColorspaceConverter(ggg))
                                                                    using (var sss = new WicUnsharpMask(csc))
                                                                        using (var dit = new WicPaletizer(sss, 256))
                                                                            using (var enc = new WicEncoder(ostm.AsIStream(), ctx))
                                                                                enc.WriteSource(dit);
                }
        }