c# XNA 将表示 2 色图像的 2D bool 数组的给定部分渲染到窗口
首先,我关于这个数组将占用多少空间的逻辑是否正确?
bool[,] b = new bool[8192 /* 8 * 1024 = 1KB */, 20]; // 20KB
我希望将二维数组的给定部分渲染到窗口。该数组由布尔值组成,表示 2 色图像。图像应该占据整个窗口,并且每个像素应该是锐利\像素化的,而不是像素中心之间存在插值\梯度。
例如(ofc 将会有比这更多的封装):
draw(bool[,] b,
float top_left_x, float top_left_y, float width, float height,
float false_red, float false_green, float false_blue,
float true_red, float true_green, float true_blue)
{
// what goes here?
}
c#\XNA 中是否有内置的东西可以有效地做到这一点?
Firstly, is my logic about how much space this array will take up correct?
bool[,] b = new bool[8192 /* 8 * 1024 = 1KB */, 20]; // 20KB
I wish to render a given section of a 2D array to the window. The array is of bools and represents a 2 color image. The image should take up the whole window and each pixel should be sharp\pixelated as opposed to there being interpolation\gradients between the pixels centers.
For example (there will ofc be more encapsulation than this):
draw(bool[,] b,
float top_left_x, float top_left_y, float width, float height,
float false_red, float false_green, float false_blue,
float true_red, float true_green, float true_blue)
{
// what goes here?
}
Is there anything build into c#\XNA to do this efficiently?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在这里做同样的事情:如何绘制 2D XNA 中逐像素?
您唯一要做的就是检查哪种颜色将进入您的纹理,如果它是 true 或 false。
You could do the same thing as opposed here: How to draw 2D pixel-by-pixel in XNA?
The only thing you have to do is check which color will get into your texture for if it is true or false.
您可以创建一个新的Texture2D,然后将SetData 函数与颜色数组一起使用。我还没有测试过,但它应该可以工作。
You can create a new Texture2D, and then use the SetData function with a array of colors. I haven't tested it, but it should work.