svpng icon indicating copy to clipboard operation
svpng copied to clipboard

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

Open Pearlfish-H opened this issue 4 years ago • 0 comments

使用者可能使用不同的方式构建 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 *

Pearlfish-H avatar Dec 30 '20 04:12 Pearlfish-H