本文整理汇总了C#中Tile.SetPixel方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.SetPixel方法的具体用法?C# Tile.SetPixel怎么用?C# Tile.SetPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile.SetPixel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadTile
public Tile ReadTile(int bitDepth)
{
Tile tile = new Tile(8, 8);
switch (bitDepth)
{
case 4:
{
for (int y = 0; y < 8; y++)
{
for (int x = 0; x < 8; x += 2)
{
byte temp = reader.ReadByte();
tile.SetPixel(x, y, (byte)(temp & 0xF));
tile.SetPixel(x + 1, y, (byte)((temp >> 4) & 0xF));
}
}
break;
}
case 8:
{
for (int y = 0; y < 8; y++)
for (int x = 0; x < 8; x++)
tile.SetPixel(x, y, reader.ReadByte());
break;
}
default:
throw new InvalidOperationException("Bit depth not supported");
}
return tile;
}
示例2: get5bpptile
//Input data loction and returns a Tile object from said data
private Tile get5bpptile(int initial_offset)
{
byte[,] tile = new byte[8, 8];
byte[] layer = new byte[5];
byte[] pixelbuilder = new byte[5];
Tile the_tile = new Tile(8, 8);
int secondary_offset = initial_offset + 32;
for (int i = 0; i < 8; i++)
{
layer[0] = raw_data_bytes[initial_offset];
layer[0] = (byte)(ReverseByteBits(layer[0]));
layer[1] = raw_data_bytes[initial_offset + 1];
layer[1] = (byte)(ReverseByteBits(layer[1]));
layer[2] = raw_data_bytes[initial_offset + 16];
layer[2] = (byte)(ReverseByteBits(layer[2]));
layer[3] = raw_data_bytes[initial_offset + 17];
layer[3] = (byte)(ReverseByteBits(layer[3]));
layer[4] = raw_data_bytes[secondary_offset];
layer[4] = (byte)(ReverseByteBits(layer[4]));
for (int a = 0; a < 8; a++)
{
//these shifts allow us to just get the bit we are interested in
pixelbuilder[0] = (byte)((layer[0] >> a) & 1);
pixelbuilder[1] = (byte)((layer[1] >> a) & 1);
pixelbuilder[2] = (byte)((layer[2] >> a) & 1);
pixelbuilder[3] = (byte)((layer[3] >> a) & 1);
pixelbuilder[4] = (byte)((layer[4] >> a) & 1);
//this OR operation 'sandwiches' the layers into one color palette value
the_tile.SetPixel(a, i, (byte)((pixelbuilder[0]) | (pixelbuilder[1] << 1 | (pixelbuilder[2] << 2) | (pixelbuilder[3] << 3) | (pixelbuilder[4] << 4))));
// tile[a,i] = (byte)((pixelbuilder[0]) | (pixelbuilder[1] << 1 | (pixelbuilder[2] << 2) | (pixelbuilder[3] << 3) | (pixelbuilder[4] << 4)));
}
initial_offset = initial_offset + 2;
secondary_offset++; //only increment this by 1
}
//need to start right after last secondary_offset value
//and its already incremented for us, so just set
//the next starting position to the value of secondary_offset
initial_offset = secondary_offset;
return the_tile;
}