本文整理汇总了C#中ColorBgra类的典型用法代码示例。如果您正苦于以下问题:C# ColorBgra类的具体用法?C# ColorBgra怎么用?C# ColorBgra使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColorBgra类属于命名空间,在下文中一共展示了ColorBgra类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetSaturation
//Saturation formula from RgbColor.cs, public HsvColor ToHsv()
private int GetSaturation (ColorBgra color)
{
double min;
double max;
double delta;
var r = (double)color.R / 255;
var g = (double)color.G / 255;
var b = (double)color.B / 255;
double s;
min = Math.Min (Math.Min (r, g), b);
max = Math.Max (Math.Max (r, g), b);
delta = max - min;
if (max == 0 || delta == 0) {
// R, G, and B must be 0, or all the same.
// In this case, S is 0, and H is undefined.
// Using H = 0 is as good as any...
s = 0;
} else {
s = delta / max;
}
return (int)(s * 255);
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:28,代码来源:RedEyeRemoveOp.cs
示例2: Apply
public override ColorBgra Apply (ColorBgra color)
{
// Adjust saturation
var intensity = color.GetIntensityByte ();
color.R = Utility.ClampToByte ((intensity * 1024 + (color.R - intensity) * sat_factor) >> 10);
color.G = Utility.ClampToByte ((intensity * 1024 + (color.G - intensity) * sat_factor) >> 10);
color.B = Utility.ClampToByte ((intensity * 1024 + (color.B - intensity) * sat_factor) >> 10);
var hsvColor = (new RgbColor (color.R, color.G, color.B)).ToHsv ();
int hue = hsvColor.Hue;
hue += hue_delta;
while (hue < 0)
hue += 360;
while (hue > 360)
hue -= 360;
hsvColor.Hue = hue;
var rgbColor = hsvColor.ToRgb ();
var newColor = ColorBgra.FromBgr ((byte)rgbColor.Blue, (byte)rgbColor.Green, (byte)rgbColor.Red);
newColor = blend_op.Apply (newColor);
newColor.A = color.A;
return newColor;
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:29,代码来源:HueSaturationLightnessOp.cs
示例3: Render
protected override unsafe void Render (ColorBgra* src, ColorBgra* dst, int length)
{
var srcRowPtr = src;
var dstRowPtr = dst;
var dstRowEndPtr = dstRowPtr + length;
if (divide == 0) {
while (dstRowPtr < dstRowEndPtr) {
var col = *srcRowPtr;
var i = col.GetIntensityByte ();
uint c = rgbTable[i];
dstRowPtr->Bgra = (col.Bgra & 0xff000000) | c | (c << 8) | (c << 16);
++dstRowPtr;
++srcRowPtr;
}
} else {
while (dstRowPtr < dstRowEndPtr) {
var col = *srcRowPtr;
var i = col.GetIntensityByte ();
var shiftIndex = i * 256;
col.R = rgbTable[shiftIndex + col.R];
col.G = rgbTable[shiftIndex + col.G];
col.B = rgbTable[shiftIndex + col.B];
*dstRowPtr = col;
++dstRowPtr;
++srcRowPtr;
}
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:32,代码来源:BrightnessContrastEffect.cs
示例4: EffectEnvironmentParameters
public EffectEnvironmentParameters(ColorBgra primaryColor, ColorBgra secondaryColor, float brushWidth, PdnRegion selection)
{
this.primaryColor = primaryColor;
this.secondaryColor = secondaryColor;
this.brushWidth = brushWidth;
this.selection = (PdnRegion)selection.Clone();
}
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:7,代码来源:EffectEnvironmentParameters.cs
示例5: ResizeDocument
public static Document ResizeDocument(Document document, Size newSize, AnchorEdge edge, ColorBgra background)
{
Document newDoc = new Document(newSize.Width, newSize.Height);
newDoc.ReplaceMetaDataFrom(document);
for (int i = 0; i < document.Layers.Count; ++i)
{
Layer layer = (Layer)document.Layers[i];
if (layer is BitmapLayer)
{
Layer newLayer;
try
{
newLayer = ResizeLayer((BitmapLayer)layer, newSize, edge, background);
}
catch (OutOfMemoryException)
{
newDoc.Dispose();
throw;
}
newDoc.Layers.Add(newLayer);
}
else
{
throw new InvalidOperationException("Canvas Size does not support Layers that are not BitmapLayers");
}
}
return newDoc;
}
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:34,代码来源:CanvasSizeAction.cs
示例6: ApplyWithAlpha
public unsafe override ColorBgra ApplyWithAlpha (ColorBgra src, int area, int sum, int* hb, int* hg, int* hr)
{
//each slot of the histgram can contain up to area * 255. This will overflow an int when area > 32k
if (area < 32768) {
int b = 0;
int g = 0;
int r = 0;
for (int i = 1; i < 256; ++i) {
b += i * hb[i];
g += i * hg[i];
r += i * hr[i];
}
int alpha = sum / area;
int div = area * 255;
return ColorBgra.FromBgraClamped (b / div, g / div, r / div, alpha);
} else { //use a long if an int will overflow.
long b = 0;
long g = 0;
long r = 0;
for (long i = 1; i < 256; ++i) {
b += i * hb[i];
g += i * hg[i];
r += i * hr[i];
}
int alpha = sum / area;
int div = area * 255;
return ColorBgra.FromBgraClamped (b / div, g / div, r / div, alpha);
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:35,代码来源:UnfocusEffect.cs
示例7: Apply
public override unsafe ColorBgra Apply (ColorBgra color, int area, int* hb, int* hg, int* hr, int* ha)
{
var normalized = GetPercentileOfColor (color, area, hb, hg, hr, ha);
var lerp = strength * (1 - 0.75 * color.GetIntensity ());
return ColorBgra.Lerp (color, normalized, lerp);
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:7,代码来源:ReduceNoiseEffect.cs
示例8: Apply
public unsafe override void Apply (ColorBgra* src, ColorBgra* dst, int length)
{
while (length > 0) {
int lhsA; { lhsA = ((*dst).A); };
int rhsA; { rhsA = ((*src).A); };
int y; { y = ((lhsA) * (255 - rhsA) + 0x80); y = ((((y) >> 8) + (y)) >> 8); }; int totalA = y + rhsA; uint ret; if (totalA == 0) { ret = 0; } else { int fB; int fG; int fR; { fB = ((*src).B); }; { fG = ((*src).G); }; { fR = ((*src).R); }; int x; { x = ((lhsA) * (rhsA) + 0x80); x = ((((x) >> 8) + (x)) >> 8); }; int z = rhsA - x; int masIndex = totalA * 3; uint taM = masTable[masIndex]; uint taA = masTable[masIndex + 1]; uint taS = masTable[masIndex + 2]; uint b = (uint)(((((long)((((*dst).B * y) + ((*src).B * z) + (fB * x)))) * taM) + taA) >> (int)taS); uint g = (uint)(((((long)((((*dst).G * y) + ((*src).G * z) + (fG * x)))) * taM) + taA) >> (int)taS); uint r = (uint)(((((long)((((*dst).R * y) + ((*src).R * z) + (fR * x)))) * taM) + taA) >> (int)taS); int a; { { a = ((lhsA) * (255 - (rhsA)) + 0x80); a = ((((a) >> 8) + (a)) >> 8); }; a += (rhsA); }; ret = b + (g << 8) + (r << 16) + ((uint)a << 24); }; dst->Bgra = ret; ++dst; ++src; --length;
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:8,代码来源:NormalBlendOp.cs
示例9: Apply
public override unsafe void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
(*ptr)[channel] = set_value;
++ptr;
--length;
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:8,代码来源:SetChannelOp.cs
示例10: PolarInversionEffect
/// <summary>
/// Creates a new effect that will apply a polar inversion to an image.
/// </summary>
/// <param name="amount">Amount of inversion. Valid range is -4 - 4.</param>
/// <param name="quality">Quality of the inversion. Valid range is 1 - 5.</param>
/// <param name="centerOffset">Center of the inversion.</param>
/// <param name="edgeBehavior">Edge behavior of the inversion.</param>
/// <param name="primaryColor">Primary color of the inversion.</param>
/// <param name="secondaryColor">Secondary color of the inversion.</param>
public PolarInversionEffect (double amount = 0, int quality = 2, Point centerOffset = new Point (), WarpEdgeBehavior edgeBehavior = WarpEdgeBehavior.Reflect, ColorBgra primaryColor = new ColorBgra (), ColorBgra secondaryColor = new ColorBgra ())
: base (quality, centerOffset, edgeBehavior, primaryColor, secondaryColor)
{
if (amount < -4 || amount > 4)
throw new ArgumentOutOfRangeException ("amount");
this.amount = amount;
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:17,代码来源:PolarInversionEffect.cs
示例11: Apply
public override unsafe void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
ptr->Bgra |= 0xff000000;
++ptr;
--length;
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:8,代码来源:SetAlphaChannelTo255Op.cs
示例12: Apply
public unsafe override void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
*ptr = set_color;
++ptr;
--length;
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:8,代码来源:ConstantOp.cs
示例13: Apply
public unsafe override void Apply (ColorBgra* src, ColorBgra* dst, int length)
{
for (int i = 0; i < length; i++) {
*dst = *src;
dst++;
src++;
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:8,代码来源:IdentityOp.cs
示例14: Apply
public override unsafe void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
ptr->Bgra = (ptr->Bgra & 0x00ffffff) + add_value;
++ptr;
--length;
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:8,代码来源:SetAlphaChannelOp.cs
示例15: Apply
public override unsafe void Apply (ColorBgra* ptr, int length)
{
while (--length >= 0) {
ptr->B = CurveB[ptr->B];
ptr->G = CurveG[ptr->G];
ptr->R = CurveR[ptr->R];
++ptr;
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:10,代码来源:ChannelCurveOp.cs
示例16: WarpEffect
protected WarpEffect (int quality, Point centerOffset, WarpEdgeBehavior edgeBehavior, ColorBgra primaryColor, ColorBgra secondaryColor)
{
if (quality < 1 || quality > 5)
throw new ArgumentOutOfRangeException ("quality");
this.quality = quality;
this.center_offset = centerOffset;
this.edge_behavior = edgeBehavior;
this.primary_color = primaryColor;
this.secondary_color = secondaryColor;
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:11,代码来源:WarpEffect.cs
示例17: Apply
public unsafe override void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
ptr->B = blue_levels[ptr->B];
ptr->G = green_levels[ptr->G];
ptr->R = red_levels[ptr->R];
++ptr;
--length;
}
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:11,代码来源:PosterizePixelOp.cs
示例18: Apply
public override ColorBgra Apply (ColorBgra color)
{
byte lumi = color.GetIntensityByte ();
int diff = Curve[lumi] - lumi;
return ColorBgra.FromBgraClamped (
color.B + diff,
color.G + diff,
color.R + diff,
color.A);
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:11,代码来源:LuminosityCurveOp.cs
示例19: Apply
public override ColorBgra Apply (ColorBgra color)
{
int a = blend_color.A;
int invA = 255 - a;
int r = ((color.R * invA) + (blend_color.R * a)) / 256;
int g = ((color.G * invA) + (blend_color.G * a)) / 256;
int b = ((color.B * invA) + (blend_color.B * a)) / 256;
byte a2 = ComputeAlpha (color.A, blend_color.A);
return ColorBgra.FromBgra ((byte)b, (byte)g, (byte)r, a2);
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:12,代码来源:BlendConstantOp.cs
示例20: LevelOp
public LevelOp (ColorBgra in_lo, ColorBgra in_hi, float[] gamma, ColorBgra out_lo, ColorBgra out_hi)
{
colorInLow = in_lo;
colorInHigh = in_hi;
colorOutLow = out_lo;
colorOutHigh = out_hi;
if (gamma.Length != 3)
throw new ArgumentException ("gamma", "gamma must be a float[3]");
this.gamma = gamma;
UpdateLookupTable ();
}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:13,代码来源:LevelOp.cs
注:本文中的ColorBgra类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论