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


C# Color.GetHashCode方法代码示例

本文整理汇总了C#中Color.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Color.GetHashCode方法的具体用法?C# Color.GetHashCode怎么用?C# Color.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Color的用法示例。


在下文中一共展示了Color.GetHashCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetHashCode

        public List<string> GetHashCode(BitmapImage bitmap)
        {//takes a bitmap and translates it into the hashcode list
            List<string> hashCode= new List<string>();

            int stride = bitmap.PixelWidth * (bitmap.Format.BitsPerPixel / 8);
            for (int i = 0; i < bitmap.PixelHeight; i++)//divides an image into rows 
            {
                string row="";
                for (int x = 0; x < bitmap.PixelWidth; x++)//iterates through each pixel in the row
                {
                    byte[] pixel = new byte[bitmap.PixelHeight];//holds color values of a single pixel
                    bitmap.CopyPixels(new Int32Rect(x, i, 1, 1), pixel, stride, 0);//assigns color values of a single pixel to the pixel array
                    Color singlePixel = new Color();//creates new color objects and assigns the color values found in pixel array to it
                    singlePixel.B = pixel[0];
                    singlePixel.G = pixel[1];
                    singlePixel.R = pixel[2];
                    singlePixel.A = pixel[3];
                    row += singlePixel.GetHashCode().ToString();//converst the color value into the hashcode and converts it to the string
                }
                hashCode.Add(row);
                if (i % 20 == 0)//Updates programm only after each tenth iteration, this makes program run a bit faster
                UpdatePRogress();
            }
            return hashCode;
        }
开发者ID:iskenxan,项目名称:ImageComparer,代码行数:25,代码来源:GetPixelStrings.cs

示例2: TextEntity

 /// <summary>
 /// Initializes a new TextEntity class.
 /// </summary>
 /// <param name="text">The Text.</param>
 /// <param name="font">The Font.</param>
 /// <param name="color">The Color.</param>
 /// <param name="wrapWidth">The Wordwrap Width.</param>
 public TextEntity(string text, OpenGLFont font, Color color, int wrapWidth = 0)
 {
     if (wrapWidth > 0) text = text.WordWrap(wrapWidth);
     var gdiFont = OpenGLHelper.ConvertFont(font);
     Id = text.GetHashCode() + gdiFont.GetHashCode() + color.GetHashCode();
     _text = text;
     _font = gdiFont;
     _color = color;
 }
开发者ID:ThuCommix,项目名称:Sharpex2D,代码行数:16,代码来源:TextEntity.cs

示例3: Equals

        public void Equals()
        {
            var color1 = new Color(10, 20, 30, 40);
            var color2 = new Color(20, 30, 40, 50);

            Assert.AreNotEqual(color1, color2);
            Assert.AreEqual(color1, new Color(10, 20, 30, 40));

            Assert.IsTrue(color1 == new Color(10, 20, 30, 40));
            Assert.IsTrue(color1 != color2);
            Assert.IsTrue(color1.Equals((object)new Color(10, 20, 30, 40)));
            Assert.AreEqual(color1.PackedArgb, color1.GetHashCode());
        }
开发者ID:lilinghui,项目名称:DeltaEngine,代码行数:13,代码来源:ColorTests.cs

示例4: Ensure_that_hash_code_can_be_generated

 public void Ensure_that_hash_code_can_be_generated()
 {
     var color = new Color(0, 1, 0);
     Assert.AreEqual(1, color.GetHashCode());
 }
开发者ID:killthrush,项目名称:DomainLayerSample,代码行数:5,代码来源:ColorTests.cs

示例5: CreateTexture

        /*
         * CreateTexture
         * Returns the texture2D to use for each GoL cell
         * can be any size, but is pixelScale * pixelScale by default
         */
        private Texture2D CreateTexture(Color colour)
        {
            Texture2D newTexture = new Texture2D(GraphicsDevice, pixelScale, pixelScale);

            int[] pixelTexture = new int[pixelScale * pixelScale];

            int whiteColour = colour.GetHashCode();
            for (int i = 0; i < pixelScale * pixelScale; i++)
            {
                pixelTexture[i] = whiteColour;
            }

            newTexture.SetData<int>(pixelTexture);
            return newTexture;
        }
开发者ID:Catchouli-old,项目名称:GoL,代码行数:20,代码来源:Game1.cs


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