本文整理汇总了C#中ColorBgra类的典型用法代码示例。如果您正苦于以下问题:C# ColorBgra类的具体用法?C# ColorBgra怎么用?C# ColorBgra使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColorBgra类属于命名空间,在下文中一共展示了ColorBgra类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
}
}
示例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();
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例9: Apply
public override unsafe void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
(*ptr)[channel] = set_value;
++ptr;
--length;
}
}
示例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;
}
示例11: Apply
public override unsafe void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
ptr->Bgra |= 0xff000000;
++ptr;
--length;
}
}
示例12: Apply
public unsafe override void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
*ptr = set_color;
++ptr;
--length;
}
}
示例13: Apply
public unsafe override void Apply (ColorBgra* src, ColorBgra* dst, int length)
{
for (int i = 0; i < length; i++) {
*dst = *src;
dst++;
src++;
}
}
示例14: Apply
public override unsafe void Apply (ColorBgra* ptr, int length)
{
while (length > 0) {
ptr->Bgra = (ptr->Bgra & 0x00ffffff) + add_value;
++ptr;
--length;
}
}
示例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;
}
}