• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ColorModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ColorModel的典型用法代码示例。如果您正苦于以下问题:C# ColorModel类的具体用法?C# ColorModel怎么用?C# ColorModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ColorModel类属于命名空间,在下文中一共展示了ColorModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetColorComponents

        public static void GetColorComponents(ColorModel colorModel, Color color, out Single componentA, out Single componentB, out Single componentC)
        {
            componentA = 0.0f;
            componentB = 0.0f;
            componentC = 0.0f;

            switch (colorModel)
            {
                case ColorModel.RedGreenBlue:
                    componentA = color.R;
                    componentB = color.G;
                    componentC = color.B;
                    break;

                case ColorModel.HueSaturationBrightness:
                    componentA = color.GetHue();
                    componentB = color.GetSaturation();
                    componentC = color.GetBrightness();
                    break;

                case ColorModel.LabColorSpace:
                    RGBtoLab(color.R, color.G, color.B, out componentA, out componentB, out componentC);
                    break;

                case ColorModel.XYZ:
                    RGBtoXYZ(color.R, color.G, color.B, out componentA, out componentB, out componentC);
                    break;
            }
        }
开发者ID:RHY3756547,项目名称:FreeSO,代码行数:29,代码来源:ColorModelHelper.cs


示例2: PngHeader

        public PngHeader(int width, int height, byte bitdepth, ColorModel colorModel)
        {
            Width = width;
            Height = height;
            BitDepth = bitdepth;
            ColorModel = colorModel;

            bool alpha = (colorModel & ColorModel.Alpha) == ColorModel.Alpha;
            bool palette = (colorModel & ColorModel.Palette) == ColorModel.Palette;
            bool grayscale = (colorModel & ColorModel.Color) != ColorModel.Color;
            bool packed = bitdepth < 8;

            if (grayscale && palette)
                throw new ArgumentOutOfRangeException("palette and greyscale are exclusive");

            int channels = (grayscale || palette) ?
                    (alpha ? 2 : 1) :	// Grayscale or Palette
                    (alpha ? 4 : 3);	// RGB

            int bpp = channels * BitDepth;
            BytesPerPixel = (bpp + 7) / 8;
            Stride = (bpp * width + 7) / 8;
            int samplesPerRow = channels * width;
            int samplesPerRowPacked = (packed) ? Stride : samplesPerRow;
        }
开发者ID:stefc,项目名称:pngread,代码行数:25,代码来源:PngHeader.cs


示例3: Invert

        public static ColorModel Invert(this ColorModel color)
        {
            ColorModel model = new ColorModel()
            {
                Red = ~(byte)color.Red,
                Green = ~(byte)color.Green,
                Blue = ~(byte)color.Blue
            };

            return model;

        }
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:12,代码来源:ColorModelExtensions.cs


示例4: ColorConverterSmartTagAction

        public ColorConverterSmartTagAction(ITrackingSpan span, ParseItem item, ColorModel colorModel, ColorFormat format)
        {
            _span = span;
            _item = item;
            _format = format;
            _colorModel = colorModel;

            if (Icon == null)
            {
                Icon = BitmapFrame.Create(new Uri("pack://application:,,,/WebEssentials2013;component/Resources/palette.png", UriKind.RelativeOrAbsolute));
            }

            SetDisplayText();
        }
开发者ID:joeriks,项目名称:WebEssentials2013,代码行数:14,代码来源:ColorConverterSmartTagAction.cs


示例5: FormatHslColor

        private static string FormatHslColor(ColorModel colorModel)
        {
            if (colorModel.Alpha < 1)
            {
                // HSL can't specify alpha
                return FormatHslaColor(colorModel);
            }
            else
            {
                HslColor hsl = colorModel.HSL;

                return string.Format(CultureInfo.InvariantCulture, "hsl({0}, {1}%, {2}%)",
                    Math.Round(hsl.Hue * 360, 1),
                    Math.Round(hsl.Saturation * 100, 1),
                    Math.Round(hsl.Lightness * 100, 1));
            }
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:17,代码来源:ColorConverterSmartTagAction.cs


示例6: ColorConverterSmartTagAction

        public ColorConverterSmartTagAction(ITrackingSpan span, ColorModel colorModel, ColorFormat format)
        {
            _span = span;

            if (format == ColorFormat.RgbHex6)
                format = ColorFormat.RgbHex3;

            _format = format;
            _colorModel = colorModel.Clone();
            _colorModel.Format = format;

            if (Icon == null)
            {
                Icon = BitmapFrame.Create(new Uri("pack://application:,,,/WebEssentials2015;component/Resources/Images/palette.png", UriKind.RelativeOrAbsolute));
            }

            _displayText = "Convert to " + GetColorString(_format, _colorModel);
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:18,代码来源:ColorConverterSmartTagAction.cs


示例7: GetColorString

        private static string GetColorString(ColorFormat format, ColorModel model)
        {
            switch (format)
            {
                case ColorFormat.Name:
                    return GetNamedColor(model.Color);

                case ColorFormat.Hsl:
                    return FormatHslColor(model); //ColorFormatter.FormatColorAs(_colorModel, ColorFormat.Hsl);

                case ColorFormat.Rgb:
                case ColorFormat.RgbHex3:
                case ColorFormat.RgbHex6:
                    return ColorFormatter.FormatColor(model, format);

                default:
                    throw new InvalidEnumArgumentException("format", (int)format, typeof(ColorFormat));
            }
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:19,代码来源:ColorConverterSmartTagAction.cs


示例8: BuildColorAnimation

        /// <summary>
        /// 创建Color值之间的线性动画
        /// </summary>
        public static ColorAnimation BuildColorAnimation(ColorModel Model)
        {
            ColorAnimation _colorAnimation = new ColorAnimation();
            _colorAnimation.From = Model.From;
            _colorAnimation.To = Model.To;
            _colorAnimation.Duration = new Duration(TimeSpan.FromSeconds(Model.Duration));
            _colorAnimation.AutoReverse = Model.AutoReverse;
            _colorAnimation.BeginTime = TimeSpan.FromSeconds(Model.BeginTime);
            _colorAnimation.By = Model.By;
            _colorAnimation.FillBehavior = Model.FillBehavior;
            _colorAnimation.RepeatBehavior = Model.RepeatBehavior;
            _colorAnimation.SpeedRatio = Model.SpeedRatio;

            if (Model.EasingFunction != null)
                _colorAnimation.EasingFunction = Model.EasingFunction;


            Storyboard.SetTarget(_colorAnimation, Model.Target);
            Storyboard.SetTargetProperty(_colorAnimation, new PropertyPath(Model.PropertyPath));
            return _colorAnimation;
        }
开发者ID:JuRogn,项目名称:OA,代码行数:24,代码来源:ColorComponents.cs


示例9: ChangeColorModel

 /// <summary>
 /// Changes the color model.
 /// </summary>
 /// <param name="colorModel">The color model.</param>
 public void ChangeColorModel(ColorModel colorModel)
 {
     ColorModel = colorModel;
 }
开发者ID:KonstantinFinagin,项目名称:aforge,代码行数:8,代码来源:BaseColorCache.cs


示例10: ToLab

 /// <summary>
 /// Converts a color to a Lab color
 /// </summary>
 /// <param name="InColor">The color to convert</param>
 /// <param name="RefWhite">The reference white to be used for the converted color</param>
 /// <returns>The converted color</returns>
 public ColorLab ToLab(Color InColor, Whitepoint RefWhite)
 {
     OutputModel = ColorModel.CIELab;
     OutReferenceWhite = RefWhite;
     SetInputColor(InColor);
     varArr = Do();
     return new ColorLab(OutReferenceWhite, varArr[0], varArr[1], varArr[2]);
 }
开发者ID:RajibTheKing,项目名称:DesktopClient,代码行数:14,代码来源:Color_Conversion.cs


示例11: GetColor

        /// <summary>
        /// Creates a new instance of a specific color with the standard settings
        /// </summary>
        /// <param name="Model">The colormodel the new color will be in</param>
        /// <returns>A color in the given colormodel or null if not possible to create color</returns>
        public static Color GetColor(ColorModel Model)
        {
            switch (Model)
            {
                case ColorModel.CIELab: return new ColorLab();
                case ColorModel.CIELCHab: return new ColorLCHab();
                case ColorModel.CIELCHuv: return new ColorLCHuv();
                case ColorModel.CIELuv: return new ColorLuv();
                case ColorModel.CIEXYZ: return new ColorXYZ();
                case ColorModel.CIEYxy: return new ColorYxy();
                case ColorModel.Gray: return new ColorGray();
                case ColorModel.HSL: return new ColorHSL();
                case ColorModel.HSV: return new ColorHSV();
                case ColorModel.LCH99: return new ColorLCH99();
                case ColorModel.LCH99b: return new ColorLCH99b();
                case ColorModel.LCH99c: return new ColorLCH99c();
                case ColorModel.LCH99d: return new ColorLCH99d();
                case ColorModel.RGB: return new ColorRGB();
                case ColorModel.YCbCr: return new ColorYCbCr();

                default: return null;
            }
        }
开发者ID:RajibTheKing,项目名称:DesktopClient,代码行数:28,代码来源:BaseColor.cs


示例12: IsXColor

        private bool IsXColor(ColorModel model)
        {
            switch (model)
            {
                case ColorModel.Color2:
                case ColorModel.Color3:
                case ColorModel.Color4:
                case ColorModel.Color5:
                case ColorModel.Color6:
                case ColorModel.Color7:
                case ColorModel.Color8:
                case ColorModel.Color9:
                case ColorModel.Color10:
                case ColorModel.Color11:
                case ColorModel.Color12:
                case ColorModel.Color13:
                case ColorModel.Color14:
                case ColorModel.Color15:
                    return true;

                default: return false;
            }
        }
开发者ID:RajibTheKing,项目名称:DesktopClient,代码行数:23,代码来源:MainForm.cs


示例13: EuclideanDistanceColorCache

 /// <summary>
 /// Initializes a new instance of the <see cref="EuclideanDistanceColorCache"/> class.
 /// </summary>
 /// <param name="colorModel">The color model.</param>
 public EuclideanDistanceColorCache(ColorModel colorModel)
 {
     ColorModel = colorModel;
 }
开发者ID:RHY3756547,项目名称:FreeSO,代码行数:8,代码来源:EuclideanDistanceColorCache.cs


示例14: ChangeColorModel

        private void ChangeColorModel()
        {
            activeColorModel = colorModelList[listColorModel.SelectedIndex];

            // applies current UI selection
            if (activeColorCache is BaseColorCache)
            {
                BaseColorCache  colorCache = (BaseColorCache) activeColorCache;
                colorCache.ChangeColorModel(activeColorModel);
            }
        }
开发者ID:dext3r,项目名称:NBA-JAM-Player-Editor,代码行数:11,代码来源:MainForm.cs


示例15: Decode


//.........这里部分代码省略.........
                            byte[][,] raster = Image.CreateRaster(frame.Width, frame.Height, frame.ComponentCount);

                            IList<JpegComponent> components = frame.Scan.Components;

                            int totalSteps = components.Count * 3; // Three steps per loop
                            int stepsFinished = 0;

                            for(int i = 0; i < components.Count; i++)
                            {
                                JpegComponent comp = components[i];

                                comp.QuantizationTable = qTables[comp.quant_id].Table;

                                // 1. Quantize
                                comp.quantizeData();
                                UpdateProgress(++stepsFinished, totalSteps);

                                // 2. Run iDCT (expensive)
                                comp.idctData();
                                UpdateProgress(++stepsFinished, totalSteps);

                                // 3. Scale the image and write the data to the raster.
                                comp.writeDataScaled(raster, i, BlockUpsamplingMode);

                                UpdateProgress(++stepsFinished, totalSteps);

                                // Ensure garbage collection.
                                comp = null; GC.Collect();
                            }

                            // Grayscale Color Image (1 Component).
                            if (frame.ComponentCount == 1)
                            {
                                ColorModel cm = new ColorModel() { colorspace = ColorSpace.Gray, Opaque = true };
                                image = new Image(cm, raster);
                            }
                            // YCbCr Color Image (3 Components).
                            else if (frame.ComponentCount == 3)
                            {
                                ColorModel cm = new ColorModel() { colorspace = ColorSpace.YCbCr, Opaque = true };
                                image = new Image(cm, raster);
                            }
                            // Possibly CMYK or RGBA ?
                            else
                            {
                                throw new NotSupportedException("Unsupported Color Mode: 4 Component Color Mode found.");
                            }

                            // If needed, convert centimeters to inches.
                            Func<double, double> conv = x =>
                                Units == UnitType.Inches ? x : x / 2.54;

                            image.DensityX = conv(XDensity);
                            image.DensityY = conv(YDensity);

                            height = frame.Height;
                            width = frame.Width;
                        }
                        else
                        {
                            // JPEG Heirarchial Frame
                            throw new NotSupportedException("Unsupported Codec Type: Hierarchial JPEG");
                        }
                        break;

                    // Only SOF0 (baseline) and SOF2 (progressive) are supported by FJCore
开发者ID:akoch-ov,项目名称:dipstart-development,代码行数:67,代码来源:JpegDecoder.cs


示例16: ToLCH99c

 /// <summary>
 /// Converts a color to a LCH99c color
 /// </summary>
 /// <param name="InColor">The color to convert</param>
 /// <returns>The converted color</returns>
 public ColorLCH99c ToLCH99c(Color InColor)
 {
     OutReferenceWhite = WhitepointArr[(int)WhitepointName.D65];
     OutputModel = ColorModel.LCH99c;
     SetInputColor(InColor);
     varArr = Do();
     return new ColorLCH99c(varArr[0], varArr[1], varArr[2]);
 }
开发者ID:RajibTheKing,项目名称:DesktopClient,代码行数:13,代码来源:Color_Conversion.cs


示例17: IsSameSpace

 internal static bool IsSameSpace(ColorModel Model, ColorSpaceType Space)
 {
     if (Enum.GetName(typeof(ColorModel), Model).ToLower() == Enum.GetName(typeof(ColorSpaceType), Space).ToLower()) return true;
     else return false;
 }
开发者ID:RajibTheKing,项目名称:DesktopClient,代码行数:5,代码来源:ICC_Conversion.cs


示例18: GetComponentC

        public static Int32 GetComponentC(ColorModel colorModel, Color color)
        {
            Int32 result = 0;

            switch (colorModel)
            {
                case ColorModel.RedGreenBlue:
                    result = color.B;
                    break;

                case ColorModel.HueSaturationBrightness:
                    result = Convert.ToInt32(color.GetBrightness() * 255);
                    break;

                case ColorModel.LabColorSpace:
                    Single l, a, b;
                    RGBtoLab(color.R, color.G, color.B, out l, out a, out b);
                    result = Convert.ToInt32(b * 255.0f);
                    break;
            }

            return result;
        }
开发者ID:hungdluit,项目名称:aforge,代码行数:23,代码来源:ColorModelHelper.cs


示例19: PixelFormatInfo

 public PixelFormatInfo(int bitsPerPixel, ColorModel model, ColorChannels channels)
 {
     BitsPerPixel = bitsPerPixel;
     ColorModel = model;
     Channels = channels;
 }
开发者ID:carbon,项目名称:Media,代码行数:6,代码来源:PixelFormat.cs


示例20: GetColorEuclideanDistance

 public static Int64 GetColorEuclideanDistance(ColorModel colorModel, Color requestedColor, Color realColor)
 {
     Single componentA, componentB, componentC;
     GetColorComponents(colorModel, requestedColor, realColor, out componentA, out componentB, out componentC);
     return (Int64)(componentA * componentA + componentB * componentB + componentC * componentC);
 }
开发者ID:hungdluit,项目名称:aforge,代码行数:6,代码来源:ColorModelHelper.cs



注:本文中的ColorModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ColorPicker类代码示例发布时间:2022-05-24
下一篇:
C# ColorImagePoint类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap