- Timestamp:
- Mar 22, 2006, 5:09:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/src/cacaview.c
r653 r662 41 41 #define ZOOM_FACTOR 1.08f 42 42 #define ZOOM_MAX 50 43 #define GAMMA_FACTOR 1.04f 44 #define GAMMA_MAX 100 45 #define GAMMA(g) (((g) < 0) ? 1.0 / gammatab[-(g)] : gammatab[(g)]) 43 46 #define PAD_STEP 0.15 44 47 … … 50 53 static void print_help(int, int); 51 54 static void set_zoom(int); 55 static void set_gamma(int); 52 56 static void load_image(char const *); 53 57 static void unload_image(void); … … 71 75 72 76 float zoomtab[ZOOM_MAX + 1]; 77 float gammatab[GAMMA_MAX + 1]; 73 78 float xfactor = 1.0, yfactor = 1.0, dx = 0.5, dy = 0.5; 74 int zoom = 0, fullscreen = 0, mode, ww, wh;79 int zoom = 0, g = 0, fullscreen = 0, mode, ww, wh; 75 80 76 81 int main(int argc, char **argv) … … 107 112 zoomtab[0] = 1.0; 108 113 for(i = 0; i < ZOOM_MAX; i++) 109 zoomtab[i + 1] = zoomtab[i] * 1.08; 114 zoomtab[i + 1] = zoomtab[i] * ZOOM_FACTOR; 115 116 /* Fill the gamma table */ 117 gammatab[0] = 1.0; 118 for(i = 0; i < GAMMA_MAX; i++) 119 gammatab[i + 1] = gammatab[i] * GAMMA_FACTOR; 110 120 111 121 /* Load items into playlist */ … … 227 237 set_zoom(zoom - 1); 228 238 break; 239 case 'G': 240 update = 1; 241 set_gamma(g + 1); 242 break; 243 case 'g': 244 update = 1; 245 set_gamma(g - 1); 246 break; 229 247 case 'x': 230 248 case 'X': 231 249 update = 1; 232 250 set_zoom(0); 251 set_gamma(0); 233 252 break; 234 253 case 'k': … … 313 332 update = 1; 314 333 set_zoom(0); 334 set_gamma(0); 315 335 316 336 free(buffer); … … 392 412 if(help) 393 413 { 394 print_help(ww - 2 5, 2);414 print_help(ww - 26, 2); 395 415 } 396 416 … … 412 432 cucul_draw_line(qq, 0, 0, ww - 1, 0, ' '); 413 433 cucul_draw_line(qq, 0, wh - 2, ww - 1, wh - 2, '-'); 414 cucul_putstr(qq, 0, 0, "q:Quit np:Next/Prev +-x:Zoom "415 "hjkl:Move d:Dither inga:Antialias");434 cucul_putstr(qq, 0, 0, "q:Quit np:Next/Prev +-x:Zoom gG:Gamma " 435 "hjkl:Move d:Dither a:Antialias"); 416 436 cucul_putstr(qq, ww - strlen("?:Help"), 0, "?:Help"); 417 437 cucul_printf(qq, 3, wh - 2, "cacaview %s", VERSION); 438 cucul_printf(qq, ww - 30, wh - 2, "(gamma: %#.3g)", GAMMA(g)); 418 439 cucul_printf(qq, ww - 14, wh - 2, "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom); 419 440 … … 426 447 static char const *help[] = 427 448 { 428 " +: zoom in ", 429 " -: zoom out ", 430 " x: reset zoom ", 431 " ---------------------- ", 432 " hjkl: move view ", 433 " arrows: move view ", 434 " ---------------------- ", 435 " a: antialiasing method ", 436 " d: dithering method ", 437 " b: background mode ", 438 " ---------------------- ", 439 " ?: help ", 440 " q: quit ", 449 " +: zoom in ", 450 " -: zoom out ", 451 " g: decrease gamma ", 452 " G: increase gamma ", 453 " x: reset zoom and gamma ", 454 " ----------------------- ", 455 " hjkl: move view ", 456 " arrows: move view ", 457 " ----------------------- ", 458 " a: antialiasing method ", 459 " d: dithering method ", 460 " b: background mode ", 461 " ----------------------- ", 462 " ?: help ", 463 " q: quit ", 441 464 NULL 442 465 }; … … 473 496 yfactor = tmp; 474 497 } 498 } 499 500 static void set_gamma(int new_gamma) 501 { 502 g = new_gamma; 503 504 if(g > GAMMA_MAX) g = GAMMA_MAX; 505 if(g < -GAMMA_MAX) g = -GAMMA_MAX; 506 507 cucul_set_bitmap_gamma(bitmap, (g < 0) ? 1.0 / gammatab[-g] : gammatab[g]); 475 508 } 476 509
Note: See TracChangeset
for help on using the changeset viewer.