#include void my_draw (Npic_image *np1) { if (NpicImageIsOK (np1, __func__) != NPIC_SUCCESS) return; switch (np1->type) { case NPIC_IMAGE_2L : { Npic_image_2l *p1 = NpicCastImage (np1); int x, y; for (y = 0; y < p1->ymax; y++) for (x = 0; x < p1->xmax; x++) p1->pix[y][x] = (x + y) % 16; return; } case NPIC_IMAGE_3L : { Npic_image_3l *p1 = NpicCastImage (np1); int x, y, z; for (z = 0; z < p1->zmax; z++) for (y = 0; y < p1->ymax; y++) for (x = 0; x < p1->xmax; x++) p1->pix[z][y][x] = (x + y + z) % 16; return; } default : np1->gen.ok = NpicError (__func__, NPIC_ERR_UNEX_NPIC, ""); } } int main () { Npic_image *np1; /* Create a 2L image = 2D image with signed long pixels (4 bytes). height is ymax=12, width is xmax=20, external borders are ybor=0, xbor=0. */ np1 = NpicCreateImage_2l (12, 20, 0, 0); if (np1 == NULL) exit (1); /* Assign values to pixels */ my_draw (np1); /* Print image */ NpicPrintImage (np1); /* Destroy image */ NpicDestroyImage (np1); exit(0); }