当前位置: 首页>>代码示例>>C#>>正文


C# Core.ColorBgra类代码示例

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


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

示例1: 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:jobernolte,项目名称:Pinta,代码行数:35,代码来源:UnfocusEffect.cs

示例2: Apply

		public override unsafe ColorBgra Apply (ColorBgra color, int area, int* hb, int* hg, int* hr, int* ha)
		{
			ColorBgra normalized = GetPercentileOfColor (color, area, hb, hg, hr, ha);
			double lerp = strength * (1 - 0.75 * color.GetIntensity ());

			return ColorBgra.Lerp (color, normalized, lerp);
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:7,代码来源:ReduceNoiseEffect.cs

示例3: Apply

            public unsafe override void Apply(ColorBgra *dst, ColorBgra *src, int length)
            {
		    for (int i = 0; i < length; i++) {
			*dst = *src;
			dst++;
			src++;
		    }
            }
开发者ID:msiyer,项目名称:Pinta,代码行数:8,代码来源:UnaryPixelOps.cs

示例4: GetPointUnchecked

        // This isn't really an extension method, since it doesn't use
        // the passed in argument, but it's nice to have the same calling
        // convention as the uncached version.  If you can use this one
        // over the other, it is much faster in tight loops (like effects).
        public static unsafe ColorBgra GetPointUnchecked(this ImageSurface surf, ColorBgra* surfDataPtr, int surfWidth, int x, int y)
        {
            ColorBgra* dstPtr = surfDataPtr;

            dstPtr += (x) + (y * surfWidth);

            return *dstPtr;
        }
开发者ID:Yetangitu,项目名称:f-spot,代码行数:12,代码来源:CairoExtensions.cs

示例5: HistogramRgb

 public HistogramRgb()
     : base(3, 256)
 {
     visualColors = new ColorBgra[]{     
                                       ColorBgra.Blue,
                                       ColorBgra.Green,
                                       ColorBgra.Red
                                   };
 }
开发者ID:msiyer,项目名称:Pinta,代码行数:9,代码来源:HistogramRGB.cs

示例6: Render

        public unsafe void Render(Cairo.ImageSurface dst, Gdk.Point offset)
        {
            if (cr.ScaleFactor > new ScaleFactor (1, 2))
                return;

            int[] d2SLookupX = cr.Dst2SrcLookupX;
            int[] d2SLookupY = cr.Dst2SrcLookupY;
            int[] s2DLookupX = cr.Src2DstLookupX;
            int[] s2DLookupY = cr.Src2DstLookupY;

            ColorBgra[] blackAndWhite = new ColorBgra[2] { ColorBgra.White, ColorBgra.Black };

            // draw horizontal lines
            int dstHeight = dst.Height;
            int dstWidth = dst.Width;
            int dstStride = dst.Stride;
            int sTop = d2SLookupY[offset.Y];
            int sBottom = d2SLookupY[offset.Y + dstHeight];

            for (int srcY = sTop; srcY <= sBottom; ++srcY) {
                int dstY = s2DLookupY[srcY];
                int dstRow = dstY - offset.Y;

                if (dstRow >= 0 && dstRow < dstHeight) {
                    ColorBgra* dstRowPtr = dst.GetRowAddressUnchecked (dstRow);
                    ColorBgra* dstRowEndPtr = dstRowPtr + dstWidth;

                    dstRowPtr += offset.X & 1;

                    while (dstRowPtr < dstRowEndPtr) {
                        *dstRowPtr = ColorBgra.Black;
                        dstRowPtr += 2;
                    }
                }
            }

            // draw vertical lines
            int sLeft = d2SLookupX[offset.X];
            int sRight = d2SLookupX[offset.X + dstWidth];

            for (int srcX = sLeft; srcX <= sRight; ++srcX) {
                int dstX = s2DLookupX[srcX];
                int dstCol = dstX - offset.X;

                if (dstCol >= 0 && dstCol < dstWidth) {
                    byte* dstColPtr = (byte*)dst.GetPointAddress (dstCol, 0);
                    byte* dstColEndPtr = dstColPtr + dstStride * dstHeight;

                    dstColPtr += (offset.Y & 1) * dstStride;

                    while (dstColPtr < dstColEndPtr) {
                        *((ColorBgra*)dstColPtr) = ColorBgra.Black;
                        dstColPtr += 2 * dstStride;
                    }
                }
            }
        }
开发者ID:sandyarmstrong,项目名称:Pinta,代码行数:57,代码来源:GridRenderer.cs

示例7: Apply

 public unsafe virtual void Apply(ColorBgra* ptr, int length)
 {
     unsafe {
         while (length > 0) {
             *ptr = Apply (*ptr);
             ++ptr;
             --length;
         }
     }
 }
开发者ID:deckarep,项目名称:Pinta,代码行数:10,代码来源:UnaryPixelOp.cs

示例8: Apply

		public unsafe virtual void Apply (ColorBgra* dst, ColorBgra* lhs, ColorBgra* rhs, int length)
		{
			unsafe {
				while (length > 0) {
					*dst = Apply (*lhs, *rhs);
					++dst;
					++lhs;
					++rhs;
					--length;
				}
			}
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:12,代码来源:BinaryPixelOp.cs

示例9: Apply

            public override ColorBgra Apply(ColorBgra color)
            {
                int a = blendColor.A;
                int invA = 255 - a;

                int r = ((color.R * invA) + (blendColor.R * a)) / 256;
                int g = ((color.G * invA) + (blendColor.G * a)) / 256;
                int b = ((color.B * invA) + (blendColor.B * a)) / 256;
                byte a2 = ComputeAlpha(color.A, blendColor.A);

                return ColorBgra.FromBgra((byte)b, (byte)g, (byte)r, a2);
            }
开发者ID:asbjornu,项目名称:Pinta,代码行数:12,代码来源:UnaryPixelOps.cs

示例10: Apply

        public unsafe override ColorBgra Apply(ColorBgra src, int area, int* hb, int* hg, int* hr, int* ha)
        {
            int resultB = BlurChannel (src.B, hb);
            int resultG = BlurChannel (src.G, hg);
            int resultR = BlurChannel (src.R, hr);

            // there is no way we can deal with pre-multiplied alphas; the correlation
            // between channels no longer exists by this point in the algorithm...
            // so, just use the alpha from the source pixel.
            ColorBgra result = ColorBgra.FromBgra ((byte)resultB, (byte)resultG, (byte)resultR, src.A);

            return result;
        }
开发者ID:sandyarmstrong,项目名称:Pinta,代码行数:13,代码来源:SurfaceBlurEffect.cs

示例11: Apply

		public ColorBgra Apply (ColorBgra color, int checkerX, int checkerY)
		{
			int b = color.B;
			int g = color.G;
			int r = color.R;
			int a = ApplyOpacity (color.A);

			int v = ((checkerX ^ checkerY) & 8) * 8 + 191;
			a = a + (a >> 7);
			int vmia = v * (256 - a);

			r = ((r * a) + vmia) >> 8;
			g = ((g * a) + vmia) >> 8;
			b = ((b * a) + vmia) >> 8;

			return ColorBgra.FromUInt32 ((uint)b + ((uint)g << 8) + ((uint)r << 16) + 0xff000000);
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:17,代码来源:CheckerBoardOperation.cs

示例12: FillStencilByColor

        public static unsafe void FillStencilByColor(ImageSurface surface, IBitVector2D stencil, ColorBgra cmp, int tolerance, out Rectangle boundingBox)
        {
            int top = int.MaxValue;
            int bottom = int.MinValue;
            int left = int.MaxValue;
            int right = int.MinValue;

            stencil.Clear (false);

            for (int y = 0; y < surface.Height; ++y) {
                bool foundPixelInRow = false;
                ColorBgra* ptr = surface.GetRowAddressUnchecked (y);

                for (int x = 0; x < surface.Width; ++x) {
                    if (CheckColor (cmp, *ptr, tolerance)) {
                        stencil.SetUnchecked (x, y, true);

                        if (x < left) {
                            left = x;
                        }

                        if (x > right) {
                            right = x;
                        }

                        foundPixelInRow = true;
                    }

                    ++ptr;
                }

                if (foundPixelInRow) {
                    if (y < top) {
                        top = y;
                    }

                    if (y >= bottom) {
                        bottom = y;
                    }
                }
            }

            boundingBox = new Rectangle (left, top, right + 1, bottom + 1);
        }
开发者ID:deckarep,项目名称:Pinta,代码行数:44,代码来源:FloodTool.cs

示例13: GetPercentileOfColor

		private static unsafe ColorBgra GetPercentileOfColor (ColorBgra color, int area, int* hb, int* hg, int* hr, int* ha)
		{
			int rc = 0;
			int gc = 0;
			int bc = 0;

			for (int i = 0; i < color.R; ++i)
				rc += hr[i];

			for (int i = 0; i < color.G; ++i)
				gc += hg[i];

			for (int i = 0; i < color.B; ++i)
				bc += hb[i];

			rc = (rc * 255) / area;
			gc = (gc * 255) / area;
			bc = (bc * 255) / area;

			return ColorBgra.FromBgr ((byte)bc, (byte)gc, (byte)rc);
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:21,代码来源:ReduceNoiseEffect.cs

示例14: Blend

        /// <summary>
        /// Smoothly blends between two colors.
        /// </summary>
        public static ColorBgra Blend(ColorBgra ca, ColorBgra cb, byte cbAlpha)
        {
            uint caA = (uint)Utility.FastScaleByteByByte((byte)(255 - cbAlpha), ca.A);
            uint cbA = (uint)Utility.FastScaleByteByByte(cbAlpha, cb.A);
            uint cbAT = caA + cbA;

            uint r;
            uint g;
            uint b;

            if (cbAT == 0) {
                r = 0;
                g = 0;
                b = 0;
            } else {
                r = ((ca.R * caA) + (cb.R * cbA)) / cbAT;
                g = ((ca.G * caA) + (cb.G * cbA)) / cbAT;
                b = ((ca.B * caA) + (cb.B * cbA)) / cbAT;
            }

            return ColorBgra.FromBgra((byte)b, (byte)g, (byte)r, (byte)cbAT);
        }
开发者ID:xxgreg,项目名称:Pinta,代码行数:25,代码来源:Utility.cs

示例15: Apply

		public unsafe override ColorBgra Apply (ColorBgra src, int area, int* hb, int* hg, int* hr, int* ha)
		{
			ColorBgra c = GetPercentile (this.percentile, area, hb, hg, hr, ha);
			return c;
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:5,代码来源:MedianEffect.cs


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