由0和1阵列绘制的隔离形状
我有文本文件包含0s和1s的数组。 它的宽度为64,我想将其转换为32像素,但可见形状。
我试图删除一个。 但这使得不可见。
我试图总结每两个像素,但是代码不起作用。 它给了我一个空数组。
这是我的功能:
string[] halfColumnsAndRawsArray = new string[halfRawsArray.Length];
for (int i = 0; i < halfRawsArray.Length; i ++)
{
char[] beforeEditingStr = halfRawsArray[i].ToCharArray();
char[] afterEditingStr = new char[beforeEditingStr.Length / 2];
int c = 0;
for (int j = 0; j < beforeEditingStr.Length; j += 2)
{
int jj = j + 1;
//if ((j % 2) == 0)
//{
int sum = (Convert.ToInt16(beforeEditingStr[j]) + Convert.ToInt16(beforeEditingStr[jj]));
if (sum == 2) sum = 1;
afterEditingStr[c] = Convert.ToChar(sum);
c++;
//}
}
for (int k = 0; k < afterEditingStr.Length; k++)
{
halfColumnsAndRawsArray[i] += afterEditingStr[k];
}
halfColumnsAndRawsArray[i] += ", ";
}
此功能的主要目标是将黑白位图转换为0s和1s字符串数组。 这使我能够在微控制器中使用它。
我的程序已经准备好,只是在等待此功能。
在此之前,我使用功能将位图转换为0s和1s数组 并将其保存到文本文件 然后,我应该从0s绘制这种形状,而较小的
阵列为16×64 我想将其转换为 16×32,但形状是由这个阵列涂抹的,仍然可以用眼睛理解
I have text file contain array of 0s and 1s.
Its width is 64 and I want to convert it to 32 pixel but keep shape painted by it is visible.
I tried to take one and delete one.
But that makes shape not visible.
I tried to sum every two pixels but code doesn´t work.
It gives me an empty array.
This is my function:
string[] halfColumnsAndRawsArray = new string[halfRawsArray.Length];
for (int i = 0; i < halfRawsArray.Length; i ++)
{
char[] beforeEditingStr = halfRawsArray[i].ToCharArray();
char[] afterEditingStr = new char[beforeEditingStr.Length / 2];
int c = 0;
for (int j = 0; j < beforeEditingStr.Length; j += 2)
{
int jj = j + 1;
//if ((j % 2) == 0)
//{
int sum = (Convert.ToInt16(beforeEditingStr[j]) + Convert.ToInt16(beforeEditingStr[jj]));
if (sum == 2) sum = 1;
afterEditingStr[c] = Convert.ToChar(sum);
c++;
//}
}
for (int k = 0; k < afterEditingStr.Length; k++)
{
halfColumnsAndRawsArray[i] += afterEditingStr[k];
}
halfColumnsAndRawsArray[i] += ", ";
}
The main goal of this function to convert black and white bitmap to 0s and 1s string array.
That makes me able to use it in microcontrollers.
My program is ready and just waiting for this function.
before this i used function to convert a bitmap to 0s and 1s array
and saved it to text file
then i should get this shap are painted from 0s and 1s smaller
array is 16×64
and i want to convert it to
16×32 but the shape are painted by this array shuold still understandable by eyes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论