示例#1
0
        public static void AddInternalFormatConverter(PipelineContext ctx, PixelValueEncoding enc = PixelValueEncoding.Unspecified, bool allow96bppFloat = false)
        {
            var  ifmt   = ctx.Source.Format;
            var  ofmt   = ifmt;
            bool linear = enc == PixelValueEncoding.Unspecified ? ctx.Settings.BlendingMode == GammaMode.Linear : enc == PixelValueEncoding.Linear;

            if (allow96bppFloat && MagicImageProcessor.EnableSimd && ifmt == PixelFormat.Bgr24Bpp)
            {
                ofmt = linear ? PixelFormat.Bgr96BppLinearFloat : PixelFormat.Bgr96BppFloat;
            }
            else if (linear && (MagicImageProcessor.EnableSimd ? internalFormatMapLinearSimd : internalFormatMapLinear).TryGetValue(ifmt, out var ofmtl))
            {
                ofmt = ofmtl;
            }
            else if (MagicImageProcessor.EnableSimd && internalFormatMapSimd.TryGetValue(ifmt, out var ofmts))
            {
                ofmt = ofmts;
            }

            bool videoLevels = ifmt == PixelFormat.Y8Bpp && ctx.ImageFrame is IYccImageFrame frame && !frame.IsFullRange;

            if (ofmt == ifmt && !videoLevels)
            {
                return;
            }

            bool forceSrgb = (ofmt == PixelFormat.Y32BppLinearFloat || ofmt == PixelFormat.Y16BppLinearUQ15) && ctx.SourceColorProfile != ColorProfile.sRGB;

            ctx.Source = ctx.AddDispose(new ConversionTransform(ctx.Source, forceSrgb ? ColorProfile.sRGB : ctx.SourceColorProfile, forceSrgb ? ColorProfile.sRGB : ctx.DestColorProfile, ofmt, videoLevels));
        }
示例#2
0
 private PixelFormat(Guid guid, string name, int bpp, int channels, PixelNumericRepresentation numericRepresentation,
                     PixelColorRepresentation colorRepresentation = PixelColorRepresentation.Unspecified, PixelAlphaRepresentation alphaRepresentation = PixelAlphaRepresentation.None,
                     PixelValueEncoding encoding = PixelValueEncoding.Unspecified, bool isWic = false
                     )
 {
     FormatGuid            = guid;
     Name                  = name;
     IsWicNative           = isWic;
     BitsPerPixel          = bpp;
     ChannelCount          = channels;
     NumericRepresentation = numericRepresentation;
     ColorRepresentation   = colorRepresentation;
     AlphaRepresentation   = alphaRepresentation;
     Encoding              = encoding;
 }