由0和1阵列绘制的隔离形状

发布于 2025-02-12 09:13:52 字数 1127 浏览 2 评论 0原文

我有文本文件包含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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文