本文整理汇总了C#中ImageView.DrawColorPixel方法的典型用法代码示例。如果您正苦于以下问题:C# ImageView.DrawColorPixel方法的具体用法?C# ImageView.DrawColorPixel怎么用?C# ImageView.DrawColorPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView.DrawColorPixel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderCounterBlocksOnBitmap
public void RenderCounterBlocksOnBitmap(ImageView imageView, NationColorOffset nationColorOffset, List<AbsoluteBlock> piactureElements, Collection<RawColorBlock> secondPartBlocks, ImageLayoutInfo layout, Color[] imagePaletteArray, Color[] generalPaletteColors)
{
var blocksDistributor = new BlocksDistributor();
var blockContainerCollection = Helper.WithMeasurement(() =>
blocksDistributor.GetDistributedCounterPartBlocks(piactureElements, secondPartBlocks), "GetDistributedCounterPartBlocks");
foreach (var blockContainer in blockContainerCollection)
{
foreach (var counterBlockContainer in blockContainer.CounterBlockContainers)
{
var sourceOffset = counterBlockContainer.RawColorBlock.Offset +
counterBlockContainer.StripePadding;
if (counterBlockContainer.RawColorBlock.type == RawColorBlockType.MultiPixel)
{
var offsetX = layout.offsetX + blockContainer.Block.OffsetX + counterBlockContainer.Offset;
var offsetY = layout.offsetY + blockContainer.Block.OffsetY;
var destinationOffset = offsetY * imageView.Width + offsetX;
Array.Copy(
sourceArray: imagePaletteArray,
sourceIndex: sourceOffset,
destinationArray: imageView.Pixels,
destinationIndex: destinationOffset,
length: counterBlockContainer.Width);
}
else if (counterBlockContainer.RawColorBlock.type == RawColorBlockType.FourPixel)
{
var offsetX = layout.offsetX + blockContainer.Block.OffsetX + counterBlockContainer.Offset;
var offsetY = layout.offsetY + blockContainer.Block.OffsetY;
var destinationOffset = offsetY * imageView.Width + offsetX;
var colorByte = counterBlockContainer.RawColorBlock.One; // Codes 4 pixels: 2 bits for pixel
var _1 = colorByte & 0x03;
var _2 = (colorByte >> 2) & 0x03;
var _3 = (colorByte >> 4) & 0x03;
var _4 = (colorByte >> 6) & 0x03;
var slice = new[]
{
generalPaletteColors[nationColorOffset.Offset + _1],
generalPaletteColors[nationColorOffset.Offset + _2],
generalPaletteColors[nationColorOffset.Offset + _3],
generalPaletteColors[nationColorOffset.Offset + _4]
};
Array.Copy(
sourceArray: slice,
sourceIndex: sourceOffset,
destinationArray: imageView.Pixels,
destinationIndex: destinationOffset,
length: counterBlockContainer.Width);
}
else
{
var colorIndex = counterBlockContainer.RawColorBlock.One;
var color = generalPaletteColors[colorIndex];
imageView.DrawColorPixel(color,
layout.offsetX + blockContainer.Block.OffsetX + counterBlockContainer.Offset,
layout.offsetY + blockContainer.Block.OffsetY);
}
}
}
}