#include #include #include void pause() { int continuer = 1; SDL_Event event; while (continuer) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: continuer = 0; } } } int main(int argc, char *argv[]) { if (argc != 3) { fprintf(stderr, "Nombre d'arguments invalide : %i, attendus 2 (width et height)", argc); return 0; } int w = 0, h = 0, x; char fileName[64]; // on obtient les largeurs et hauteurs x = 0; while (argv[1][x]) w = 10*w + argv[1][x++] - '0'; x = 0; while (argv[2][x]) h = 10*h + argv[2][x++] - '0'; sprintf(fileName, "font_frame_%ix%i.bmp", w, h); // on créé la fenêtre SDL_Init(SDL_INIT_VIDEO); SDL_Surface *scr = SDL_SetVideoMode(16*(w+2), 16*(h+2), 32, SDL_HWSURFACE); SDL_FillRect(scr, NULL, SDL_MapRGB(scr->format, 255,255,255)); // on dessine les rectangles SDL_Rect r1 = (SDL_Rect) {0, 0, 16*(w+2), 1}; SDL_Rect r2 = (SDL_Rect) {0, 0, 1, 16*(h+2)}; for (x=0; x <= 16; x++) { // lignes horizontales if (x < 16) SDL_FillRect(scr, &r1, SDL_MapRGB(scr->format, 244,198, 236)); r1.y--; if (x) SDL_FillRect(scr, &r1, SDL_MapRGB(scr->format, 244,198, 236)); r1.y += h+3; // lignes verticales if (x < 16) SDL_FillRect(scr, &r2, SDL_MapRGB(scr->format, 244,198, 236)); r2.x--; if (x) SDL_FillRect(scr, &r2, SDL_MapRGB(scr->format, 244,198, 236)); r2.x += w+3; } SDL_SaveBMP(scr, fileName); SDL_Flip(scr); pause(); SDL_Quit(); return 1; }