當前位置: 首頁>>代碼示例>>C#>>正文


C# ColorBgra類代碼示例

本文整理匯總了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);
		}
開發者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


注:本文中的ColorBgra類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。