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


C# System.Pixel类代码示例

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


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

示例1: Load

        /// <summary>
        /// Loads a texture from a file
        /// </summary>
        /// <param name="filename">The file from which to get the texture</param>
        /// <returns>If it loaded the texture correctly</returns>
        public bool Load(string filename)
        {
            FileStream fs = new FileStream(filename, FileMode.Open);
            BinaryReader br = new BinaryReader(fs);

            //Read the size
            int sizex = br.ReadInt32();
            int sizey = br.ReadInt32();

            this.Scale(sizex, sizey); //Scale to new size
            ComponentEditor.ModifyAll(this,null); //And clear

            //Read textures
            int totalPixels = br.ReadInt32();

            for (int i = 0; i < totalPixels; i++ )
            {
                int x = br.ReadInt32();
                int y = br.ReadInt32();
                char c = (char)br.ReadInt32();
                ConsoleColor f = (ConsoleColor)br.ReadInt32();
                ConsoleColor b = (ConsoleColor)br.ReadInt32();
                Contents[x, y] = new Pixel(c, f, b);

            }
            return true;
        }
开发者ID:MadcowD,项目名称:ConsoleLib,代码行数:32,代码来源:TextureComponent.cs

示例2: AreNotEqual

		//===========================================================================================
		public static void AreNotEqual(Pixel expected, Pixel actual)
		{
			Assert.IsNotNull(expected);
			Assert.IsNotNull(actual);

			AreNotEqual(expected.ToColor(), actual.ToColor());
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:8,代码来源:ColorAssert.cs

示例3: FrameSet

        public override void FrameSet(Pixel pixel, int position) {
            if (position < 0) { return; }

            int currentRow = position / (int)(NumberOfPanels * ColumnsPerPanel);
            int currentColumn = position % (int)(NumberOfPanels * ColumnsPerPanel);
            Frame[PointPostion(currentRow, currentColumn)] = pixel;
        }
开发者ID:MaitreDede,项目名称:Windows-IoT-Core-Graphics-Library,代码行数:7,代码来源:GridBase.cs

示例4: MergeRgb

        private static Pixel MergeRgb(Pixel p0, Pixel p1, Pixel p2)
        {
            var from = (p0 + p1 + p2) / 3;
            var to = new Pixel(p0.C0, p1.C1, p2.C2, from.C3);
            var p = 1.0;

            return from + (to - from) * p;
        }
开发者ID:EFanZh,项目名称:EFanZh,代码行数:8,代码来源:Program.cs

示例5: ColorHash

 private static int ColorHash(Pixel colour)
 {
     int num = 0;
     if (colour.A > 0)
     {
         num = (((((0xff - colour.R) * 0x100) * 0x100) + ((0xff - colour.G) * 0x100)) + (0xff - colour.B)) + 1;
     }
     return num;
 }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:9,代码来源:XpmSupport.cs

示例6: SetPixel

        public void SetPixel( int x, int y, Pixel colour )
        {
            if ( Image.TiledView )
            {
                x = Wrap( x, Image.Width );
                y = Wrap( y, Image.Height );
            }

            Pixels[ x, y ] = colour;
            DrawPixel( x, y );
        }
开发者ID:Metapyziks,项目名称:SprytEditor,代码行数:11,代码来源:Layer.cs

示例7: GetLowerUpper

        Tuple<int, int> GetLowerUpper(Pixel trimColor, IEnumerable<Pixel[]> array,
				  string lower, string upper)
        {
            Predicate<bool> notTrue = (b) => {return !b;};

              var rows = array.Select(x => AllEqual(x, trimColor)).ToList();

              return Tuple.Create((GetValue<bool>(lower)) ? rows.FindIndex(notTrue) : 0,
              (GetValue<bool>(upper)) ? rows.FindLastIndex(notTrue) + 1
              : rows.Count());
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:11,代码来源:Renderer.cs

示例8: LinearInterpolate

        //эта штука нужна, если мы попали на границу нашей картинки. Мы не можем взять 4 точки для интерполяции, поэтому берём только две
        private double LinearInterpolate(Pixel first, Pixel second, double x, double y)
        {
            if (first == null || second == null)//если вдруг мы попали в угол картинки. У нас не будет даже двух точек - будет всего одна
                return (first ?? second).Intensity;

            if (first.Y == second.Y)
                return Math.Abs((second.X - x) * first.Intensity + (x - first.X) * second.Intensity);
            if (first.X == second.X)
                return Math.Abs((second.Y - y) * first.Intensity + (y - first.Y) * second.Intensity);

            throw new Exception("Somthing wrong :)");
        }
开发者ID:sr480,项目名称:ImageToGCode,代码行数:13,代码来源:BilinearInterpolator.cs

示例9: Normalize

 double[,] Normalize(ref Pixel x)
 {
     //Gaussian distribution
     double[,] Px_i = new double[NumofClasses, NumofFeatures];
     for (int i = 0; i < NumofClasses; ++i)
     {
         Px_i[i, 0] = ((double)1 / Math.Sqrt(2 * Math.PI) * Sigma[i,0]) * Math.Exp(-Math.Pow((x.R - Mu[i,0]), 2) / (2 * Math.Pow(Sigma[i,0], 2)));
         Px_i[i, 1] = ((double)1 / Math.Sqrt(2 * Math.PI) * Sigma[i,1]) * Math.Exp(-Math.Pow((x.G - Mu[i,1]), 2) / (2 * Math.Pow(Sigma[i,1], 2)));
         Px_i[i, 2] = ((double)1 / Math.Sqrt(2 * Math.PI) * Sigma[i,2]) * Math.Exp(-Math.Pow((x.B - Mu[i,2]), 2) / (2 * Math.Pow(Sigma[i,2], 2)));
     }
     return Px_i;
 }
开发者ID:keroishak,项目名称:Pattern-Recognition,代码行数:12,代码来源:MultiFeatureBayesianClassifier.cs

示例10: ContainsCornerPixelsTest

 public void ContainsCornerPixelsTest()
 {
     var _Rectangle = new Rectangle<Double>(10, 20, 30, 40);
     var _Pixel1    = new Pixel<Double>(10, 20);
     var _Pixel2    = new Pixel<Double>(30, 20);
     var _Pixel3    = new Pixel<Double>(10, 40);
     var _Pixel4    = new Pixel<Double>(30, 40);
     Assert.IsTrue(_Rectangle.Contains(_Pixel1));
     Assert.IsTrue(_Rectangle.Contains(_Pixel2));
     Assert.IsTrue(_Rectangle.Contains(_Pixel3));
     Assert.IsTrue(_Rectangle.Contains(_Pixel4));
 }
开发者ID:Vanaheimr,项目名称:Illias,代码行数:12,代码来源:RectangleTests.cs

示例11: Filter

        public void Filter(IImage image, double[,] filter)
        {
            if (filter.GetLength(0) != filter.GetLength(1))
            {
                throw new ArgumentException("invalid filter", nameof(filter));
            }

            var result = new Pixel[image.Width, image.Height];

            double blue = 0.0;
            double green = 0.0;
            double red = 0.0;

            int filterOffset = (filter.GetLength(0) - 1) / 2;
            for (int offsetY = filterOffset; offsetY < image.Height - filterOffset; offsetY++)
            {
                for (int offsetX = filterOffset; offsetX < image.Width - filterOffset; offsetX++)
                {
                    blue = 0;
                    green = 0;
                    red = 0;

                    for (int filterY = -filterOffset; filterY <= filterOffset; filterY++)
                    {
                        for (int filterX = -filterOffset; filterX <= filterOffset; filterX++)
                        {
                            var imagePixel = image.GetPixel(offsetX + filterX, offsetY + filterY);

                            blue += (double)(imagePixel.B) * filter[filterY + filterOffset, filterX + filterOffset];
                            green += (double)(imagePixel.G) * filter[filterY + filterOffset, filterX + filterOffset];
                            red += (double)(imagePixel.R) * filter[filterY + filterOffset, filterX + filterOffset];
                        }
                    }

                    blue = Factor * blue + Bias;
                    green = Factor * green + Bias;
                    red = Factor * red + Bias;

                    result[offsetX, offsetY] = new Pixel { R = this.ToByte(red), G = this.ToByte(green), B = this.ToByte(blue) };
                }
            }

            for (int x = 0; x < result.GetLength(0); x++)
            {
                for (int y = 0; y < result.GetLength(1); y++)
                {
                    image.SetPixel(x, y, result[x, y]);
                }
            }
        }
开发者ID:VysotskiVadim,项目名称:bsuir-misoi-car-number,代码行数:50,代码来源:ConvolutionFilter.cs

示例12: ProcessImage

        public void ProcessImage(IImage inputImage)
        {
            var segments = _segmentationAlgoritm.ProcessImage(inputImage);

            var image = segments.SegmentationMatrix;
            for (int j = 0; j < inputImage.Height; j++)
            {
                for (int i = 0; i < inputImage.Width; i++)
                {
                    var random = new Random(image[i, j]);
                    var pixel = new Pixel { R = (byte)random.Next(255), G = (byte)random.Next(255), B = (byte)random.Next(255) };
                    inputImage.SetPixel(i, j, pixel);
                }
            }
        }
开发者ID:DashaVeresova,项目名称:RecognitionOfDrivingLicenses,代码行数:15,代码来源:SegmentationFilter.cs

示例13: GetForColorizer

 private byte GetForColorizer(Pixel p)
 {
     byte b = unchecked((byte)(Math.Floor((double)(getForPallet(p.R) / (byte)42)) * Math.Floor((double)(getForPallet(p.G) / (byte)42)) * Math.Floor((double)(getForPallet(p.B) / (byte)42))));
     if (b == 0)
     {
         return 1;
     }
     else if (b == 1)
     {
         return 0;
     }
     else
     {
         return unchecked((byte)(b + (byte)2));
     }
 }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:16,代码来源:VGADriver.cs

示例14: ReadCurrentRow__moves_through_complete_row

        public void ReadCurrentRow__moves_through_complete_row()
        {
            var p = new Pixel(50, 25);
            var called = 0;
            var reader = new Mock<IImageReader>();
            reader.Setup(i => i.CurrentPixelType()).Returns(PixelType.Water);
            reader.Setup(i => i.NextRow()).Returns(() => { called++; return called < 50; });
            reader.Setup(i => i.CurrentPixel).Returns(p);
            reader.Setup(i => i.FrameHeight).Returns(50);

            var imageParser = new ImageParser(reader.Object);

            var res = imageParser.ReadCurrentRow();

            res.Should().Be(p);
            called.Should().BeGreaterOrEqualTo(49);
        }
开发者ID:Krizzzn,项目名称:DLImageParsr,代码行数:17,代码来源:ImageParserTest.cs

示例15: Renderer

        public Renderer(VariableSet variables, Drawable drawable)
            : base(variables)
        {
            _drawable = drawable;
              int bpp = drawable.Bpp;
              _pixel = drawable.CreatePixel();
              _color = GetValue<bool>("color");

              if (drawable.HasAlpha)
            {
              bpp--;
              _pixel.Alpha = 255;
            }

              _calculator = new Calculator(GetValue<int>("points"),
                   GetValue<int>("closest"),
                   bpp, drawable.MaskBounds,
                   (int) GetValue<UInt32>("seed"));
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:19,代码来源:Renderer.cs


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