在微控制器的屏幕上显示图片

时间:2014-05-16 23:07:56

标签: c image microcontroller

您好我想让我的照片(尺寸为:40 x 42)占用我的微控制器上可用的更多空间,因为您可以看到我的脸在屏幕上非常小:

enter image description here

我尝试过的第一件事就是使用尺寸为70 x 73的更大图片。然后它将图片放在同一个地方,没有任何空间可供选择:

enter image description here

问题还在于我需要创造更多空间/空间,因为我想在屏幕上展示自己的更大幅度。但是我不知道如何解决这个问题,有人可以帮助我吗?

这是我用来在微控制器上显示我的小图片(40 x 42)的代码:

showCredits() {

while (1) {
    // 38 width, 44 height
    //int asciiZaky [44] [38]
   // int asciiZaky [42] [20] = { //40 x 42 size
   // int asciiZaky [73] [35] = { //70 x 73 size
    int asciiZaky [44] [38] = { //40 x 42 size
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,0,0,1,1,1,1,0,1,0,0,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,},
{0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,},
{1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,},
{1,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,},
{1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,}
    };


    int i, j;
    for (i = 0; i <= 128; i++) {
        drawScreen(dogmScreen, 8, 128);
        for (j = 0; j <= 64; j++) {
            setPixel(i, j);
            if (45 <= i && i < 83 && //Aligning the image to the center
                    10 <= j && j < 54 && // Putting the image below
                    asciiZaky [j - 10] [i - 45] == 1// Giving good values to the array
                    ||
                    (i > 108 && j > 52) // Right under corner
                    ) {
                clearPixel(i, j);
            }
        }

    }   
  }
}

以下是其他一些尝试,但我还没有成功:

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

我简化了代码,不容易阅读。 在上面的某处定义这两个函数:

void clearScreen(int color) {
    int i,j;

    for(i=0;i<=128;i++) { //Did you really mean 129 wide? If not, remove the '='
        for(j=0;j<=64;j++) {
            if(color) setPixel(i,j);
            else clearPixel(i,j);
        }
    }

void bitblt(int x, int y, int sx, int sy, int *pic) {
    int i,j;

    for(i=x;i<sx;i++) {
        for(j=y;j<sy;j++) {
            if(pic[i][j]) setPixel(i,j);
            else clearPixel(i,j);
        }
    }
}

然后在你的while循环中:

while(1) {
    clearScreen(1); //You seem to clear to black
    bitblt(34,0,60,64,zaky); //60x64 is the largest for the given aspect
}
相关问题