public WicConvertFromCustomPixelFormat(WicTransform prev) : base(prev)
        {
            var ifmt = Source.GetPixelFormat();
            var ofmt = ifmt;

            if (ifmt == Consts.GUID_WICPixelFormat32bppGrayFloat || ifmt == PixelFormat.Grey32BppLinearFloat.FormatGuid || ifmt == PixelFormat.Grey16BppLinearUQ15.FormatGuid)
            {
                ofmt = Consts.GUID_WICPixelFormat8bppGray;
            }
            else if (ifmt == PixelFormat.Y32BppFloat.FormatGuid || ifmt == PixelFormat.Y32BppLinearFloat.FormatGuid || ifmt == PixelFormat.Y16BppLinearUQ15.FormatGuid)
            {
                ofmt = Consts.GUID_WICPixelFormat8bppY;
            }
            else if (ifmt == PixelFormat.Bgr96BppFloat.FormatGuid || ifmt == PixelFormat.Bgr96BppLinearFloat.FormatGuid || ifmt == PixelFormat.Bgr48BppLinearUQ15.FormatGuid)
            {
                ofmt = Consts.GUID_WICPixelFormat24bppBGR;
            }
            else if (ifmt == PixelFormat.Pbgra128BppFloat.FormatGuid || ifmt == PixelFormat.Pbgra128BppLinearFloat.FormatGuid || ifmt == PixelFormat.Bgra64BppLinearUQ15.FormatGuid || ifmt == PixelFormat.Pbgra64BppLinearUQ15.FormatGuid)
            {
                ofmt = Consts.GUID_WICPixelFormat32bppBGRA;
            }
            else if (ifmt == PixelFormat.CbCr64BppFloat.FormatGuid)
            {
                ofmt = Consts.GUID_WICPixelFormat16bppCbCr;
            }

            if (ofmt == ifmt)
            {
                return;
            }

            Source = conv = new WicCustomPixelFormatConverter(Source, ofmt);
            Context.PixelFormat = PixelFormat.Cache[Source.GetPixelFormat()];
        }
        public WicMatteTransform(WicTransform prev) : base(prev)
        {
            if (Context.PixelFormat == PixelFormat.Pbgra128BppFloat)
            {
                Source = conv = new WicCustomPixelFormatConverter(Source, Consts.GUID_WICPixelFormat32bppBGRA);
                Context.PixelFormat = PixelFormat.Cache[Source.GetPixelFormat()];
            }

            if (Context.Settings.MatteColor.IsEmpty || Context.PixelFormat.ColorRepresentation != PixelColorRepresentation.Bgr || Context.PixelFormat.AlphaRepresentation == PixelAlphaRepresentation.None)
            {
                return;
            }

            Source = new WicMatte(Source, Context.Settings.MatteColor);
        }
        public WicConvertToCustomPixelFormat(WicTransform prev) : base(prev)
        {
            var  ifmt   = Source.GetPixelFormat();
            var  ofmt   = ifmt;
            bool linear = Context.Settings.BlendingMode == GammaMode.Linear;

            if (MagicImageProcessor.EnableSimd)
            {
                if (ifmt == Consts.GUID_WICPixelFormat8bppGray)
                {
                    ofmt = linear ? PixelFormat.Grey32BppLinearFloat.FormatGuid : Consts.GUID_WICPixelFormat32bppGrayFloat;
                }
                else if (ifmt == Consts.GUID_WICPixelFormat8bppY)
                {
                    ofmt = linear ? PixelFormat.Y32BppLinearFloat.FormatGuid : PixelFormat.Y32BppFloat.FormatGuid;
                }
                else if (ifmt == Consts.GUID_WICPixelFormat24bppBGR)
                {
                    ofmt = linear ? PixelFormat.Bgr96BppLinearFloat.FormatGuid : PixelFormat.Bgr96BppFloat.FormatGuid;
                }
                else if (ifmt == Consts.GUID_WICPixelFormat32bppBGRA || ifmt == Consts.GUID_WICPixelFormat32bppPBGRA)
                {
                    ofmt = linear ? PixelFormat.Pbgra128BppLinearFloat.FormatGuid : PixelFormat.Pbgra128BppFloat.FormatGuid;
                }
                else if (ifmt == Consts.GUID_WICPixelFormat16bppCbCr)
                {
                    ofmt = PixelFormat.CbCr64BppFloat.FormatGuid;
                }
            }
            else if (linear)
            {
                if (ifmt == Consts.GUID_WICPixelFormat8bppGray)
                {
                    ofmt = PixelFormat.Grey16BppLinearUQ15.FormatGuid;
                }
                else if (ifmt == Consts.GUID_WICPixelFormat8bppY)
                {
                    ofmt = PixelFormat.Y16BppLinearUQ15.FormatGuid;
                }
                else if (ifmt == Consts.GUID_WICPixelFormat24bppBGR)
                {
                    ofmt = PixelFormat.Bgr48BppLinearUQ15.FormatGuid;
                }
                else if (ifmt == Consts.GUID_WICPixelFormat32bppBGRA)
                {
                    ofmt = PixelFormat.Bgra64BppLinearUQ15.FormatGuid;
                }
                else if (ifmt == Consts.GUID_WICPixelFormat32bppPBGRA)
                {
                    ofmt = PixelFormat.Pbgra64BppLinearUQ15.FormatGuid;
                }
            }

            if (ofmt == ifmt)
            {
                return;
            }

            Source = conv = new WicCustomPixelFormatConverter(Source, ofmt);
            Context.PixelFormat = PixelFormat.Cache[Source.GetPixelFormat()];
        }