當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。