本文整理汇总了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;
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}