本文整理汇总了C#中ColorModel类的典型用法代码示例。如果您正苦于以下问题:C# ColorModel类的具体用法?C# ColorModel怎么用?C# ColorModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColorModel类属于命名空间,在下文中一共展示了ColorModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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;
}
示例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;
}
示例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();
}
示例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));
}
}
示例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);
}
示例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));
}
}
示例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;
}
示例9: ChangeColorModel
/// <summary>
/// Changes the color model.
/// </summary>
/// <param name="colorModel">The color model.</param>
public void ChangeColorModel(ColorModel colorModel)
{
ColorModel = colorModel;
}
示例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]);
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例14: ChangeColorModel
private void ChangeColorModel()
{
activeColorModel = colorModelList[listColorModel.SelectedIndex];
// applies current UI selection
if (activeColorCache is BaseColorCache)
{
BaseColorCache colorCache = (BaseColorCache) activeColorCache;
colorCache.ChangeColorModel(activeColorModel);
}
}
示例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