/* * Test the graphics module */ #include #include #include #include "gnomegr.h" #ifdef WIN32 #define sleep _sleep #define SLEEPTIME 100 #else #include #define SLEEPTIME 1 #endif // WIN32 GnomeBitmap my_canvas; static void startup() { int i, r, c, n; n = 0; while (n < 2) { n++; for (i = 0; i < 8; ++i) { /* turn on each 8-th row of the bitmap, with shift of i */ for (r = 0; r < my_canvas.height; ++r) { if (r % 8 == i) { /* Here we use the fact that the width is a factor of 8. In general this assumption cannot be made. */ for (c = 0; c < my_canvas.width/8; ++c) { my_canvas.bits[r*my_canvas.width/8 + c] = 0xFF; } } else { /* Here we use the fact that the width is a factor of 8. In general this assumption cannot be made. */ for (c = 0; c < my_canvas.width/8; ++c) { my_canvas.bits[r*my_canvas.width/8 + c] = 0x0; } } } /* Render the bitmap on screen */ Render(&my_canvas); /* Wait a little */ sleep(SLEEPTIME); } } exit(0); } int main(int argc, char** argv) { my_canvas.width = 256; my_canvas.height = 256; my_canvas.bits = (unsigned char *)calloc(8192, sizeof(unsigned char)); if (! my_canvas.bits) return -1; InitGr(&my_canvas, startup); return 0; }