| CODE |
| #include <conio.h> #include <stdlib.h> #include "allegro.h" #define MODE GFX_AUTODETECT_WINDOWED #define WIDTH 640 #define HEIGHT 480 #define WHITE makecol(255, 255, 255) #define BLACK makecol(0, 0, 0) void makeNew(); void makeNew() { BITMAP *bmp; bmp = create_bitmap(200, 200); rectfill(screen, 0, 0, SCREEN_W, SCREEN_H, BLACK); int x1, y1, x2, y2; int red, green, blue, color; for(int i = 0; i < 10; i++) { x1 = rand() % (bmp->w - 20); y1 = rand() % (bmp->h - 20); x2 = rand() % (bmp->w - 20); y2 = rand() % (bmp->h - 20); red = rand() % 255; green = rand() % 255; blue = rand() % 255; color = makecol(red, green, blue); rectfill(bmp, x1, y1, x2, y2, color); } blit(bmp, screen, 0, 0, (SCREEN_W - bmp->w) / 2, (SCREEN_H - bmp->h) / 2, bmp->w, bmp->h); textout_centre(screen, font, "Are you satisfied with this image? (Y - N)", SCREEN_W/2, SCREEN_H - 40, WHITE); while(!key[KEY_Y] || !key[KEY_N]) { if(key[KEY_Y]) { save_bitmap("C:\\ImageFromSave.bmp", bmp, NULL); destroy_bitmap(bmp); rectfill(screen, 0, 0, SCREEN_W, SCREEN_H, BLACK); textout_centre(screen, font, "Image Saved to Drive C", SCREEN_W/2, SCREEN_H/2, WHITE); textout_centre(screen, font, "Path: C:\\ImageFromSave.bmp", SCREEN_W/2, (SCREEN_H + 30)/2, WHITE); rest(3000); rectfill(screen, 0, 0, SCREEN_W, SCREEN_H, BLACK); return; } else if(key[KEY_N]) { destroy_bitmap(bmp); rectfill(screen, 0, 0, SCREEN_W, SCREEN_H, BLACK); return; } } destroy_bitmap(bmp); return; } void main(void) { allegro_init(); install_keyboard(); install_timer(); srand(time(NULL)); set_color_depth(16); if(set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0) != 0) { allegro_message(allegro_error); return; } while(!key[KEY_ESC]) { textout(screen, font, "Random Bitmap Creator - http://www.nox-tech.com/kswp88", 0, 0, WHITE); textout_centre(screen, font, "Rmstn1580's Bitmap Creator", SCREEN_W / 2, SCREEN_H / 2, WHITE); textout_centre(screen, font, "Press A to start", SCREEN_W / 2, (SCREEN_H + 30) / 2, WHITE); textout_centre(screen, font, "Press ESC to quit", SCREEN_W / 2, (SCREEN_H + 60) / 2, WHITE); if(key[KEY_A]) { makeNew(); } } allegro_exit(); return; } END_OF_MAIN(); |
| QUOTE |
| #define WHITE makecol(255, 255, 255) #define BLACK makecol(0, 0, 0) |