Skip to content

参数 img 的类型也许可以改为 void * #4

@Pearlfish-H

Description

@Pearlfish-H

使用者可能使用不同的方式构建 img。比如:

#define ENA  0       /* Enable Alpha channel or not */
#define NX   256     /* Number of X points */
#define NY   256     /* Number of Y points */
#define NCH (3+ENA)  /* Number of Channels */

enum Channel { R, G, B, A };
typedef uint8_t Pixel[NCH];

void fun(FILE *fp)
{
    Pixel img[NX][NY];
    unsigned x, y;

    for (x = 0; x < NX; ++x) {
        for (y = 0; y < NY; ++y) {
            img[x][y][R] = x;
            img[x][y][G] = y;
            img[x][y][B] = 128;
        }
    }
    svpng(fp, NX, NY, (unsigned char *) img, ENA);
}

为了避免在 img 前的强制转换,也许可以将其参数类型定为 void *

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions