本文整理汇总了C#中System.Byte.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Byte.Contains方法的具体用法?C# Byte.Contains怎么用?C# Byte.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Byte
的用法示例。
在下文中一共展示了Byte.Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button2_Click
private void button2_Click(object sender, EventArgs e)
{
int colour;
int i;
output = new Byte[bmp.Height, bmp.Width];
for (int row = 0; row < bmp.Height; row++)
{
Color[] rowColors = new Color[MaxColoursPerRow];
int colorCount = 0;
for (int stitch = 0; stitch < bmp.Width; stitch++)
{
thisStitch = bmp.GetPixel(stitch, row);
if (!rowColors.Contains(thisStitch))
{
rowColors[colorCount++] = thisStitch;
}
}
for (int stitch = 0; stitch < bmp.Width; stitch++)
{
thisStitch = bmp.GetPixel(stitch, row);
for (i = 0; i < colors.Length; i++)
{
if (thisStitch == colors[i])
{
colour = Convert.ToInt32(colorNumber[i].Text);
output[row, stitch] = (Byte)colour;
break;
}
}
}
}
// Array 'output' now contains one byte per pixel (stitch), with number representing colour of yarn to use. Let's dump it to a file for reference.
System.IO.StreamWriter stream = new System.IO.StreamWriter("C:\\Knitulator\\Frontproof.txt");
for (int row = 0; row < bmp.Height; row++)
{
for (int stitch = 0; stitch < bmp.Width; stitch++)
{
stream.Write(output[row, stitch].ToString());
}
stream.WriteLine();
}
stream.Close();
// Now lets create a Multicolour pattern, where each row contains a boolean indicating do or don't use the colour.
// A separate array is required, for each row to indicate which colour to use.
//TOD: Make sure patternRowColour is multiple of 2 as colours are stored as nibbles
Byte[] patternRowColour = new Byte[bmp.Height * MaxColoursPerRow]; // Array to hold colour of yarn to use on each Multicolour row
int widthInBits = (int)(8 * Math.Round(bmp.Width / (double)8, MidpointRounding.AwayFromZero)); // must be multiple of 8 bits
Byte[,] pattern = new Byte[bmp.Height * MaxColoursPerRow, widthInBits]; // Array to hold pattern data = 1 byte represents 8 stitches
System.IO.StreamWriter stream2 = new System.IO.StreamWriter("C:\\Knitulator\\Frontmc.txt");
int n = bmp.Height * MaxColoursPerRow;
stream2.WriteLine("Row : Disp : Col : Row Pattern");
for (int row = 0; row < bmp.Height; row++)
{
// Work out which colours to knit:
Byte[] rowColours = new Byte[MaxColoursPerRow];
int colourCount = 0;
for (int stitch = 0; stitch < bmp.Width; stitch++)
{
if (!rowColours.Contains(output[row, stitch]))
{
rowColours[colourCount++] = output[row, stitch];
}
}
if (rowColours[1] == 0)
{
rowColours[1] = 8;
rowColours[2] = 9;
}
if (rowColours[2] == 0)
{
rowColours[2] = 9;
}
for (i = 0; i < MaxColoursPerRow; i++)
{
stream2.Write((bmp.Height - row).ToString("D3") + " : ");
stream2.Write(n.ToString("D3") + " : ");
n--;
//.........这里部分代码省略.........