- Timestamp:
- Nov 30, 2003, 2:18:10 AM (18 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/TODO
r204 r236 34 34 Documentation 35 35 36 o Everything is still to do .36 o Everything is still to do 37 37 38 39 cacaview 40 41 o Aspect ratio 42 43 o File browser 44 45 o Handle GIF and PNG transparency with checkered background 46 -
libcaca/trunk/doc/cacaview.1
r215 r236 1 .TH cacaview 1 "2003-11-30" "libcaca" 2 .SH NAME 3 cacaview \- ASCII image browser 4 .SH SYNOPSIS 5 .B cacaview [FILE...] 6 .RI 7 .SH DESCRIPTION 8 .B cacaview 9 is a lightweight text mode image viewer. It renders images using colour 10 ASCII characters. It is a powerful add-on to famous console programs such 11 as the mutt email client, the slrn newsreader and the links or w3m web 12 browsers. 13 .PP 14 .B cacaview 15 can load the most widespread image formats: PNG, JPEG, GIF, PNG, BMP etc. 16 .PP 17 You can zoom and scroll the image around for more details, and choose four 18 different dithering modes. All commands are accessible through a single 19 key press. 20 .SH KEYS 21 .TP 22 .B ? 23 show the help screen 24 .TP 25 .B n, p 26 switch to next image, previous image 27 .TP 28 .B Left, Right, Up, Down or h, l, k, j 29 scroll the image around 30 .TP 31 .B +, - 32 zoom in and out 33 .TP 34 .B z 35 reset the zoom level to normal 36 .TP 37 .B d 38 toggle the dithering mode (no dithering, 4x4 ordered dithering, 8x8 ordered 39 dithering and random dithering) 40 .TP 41 .B q 42 exit the program 43 .SH EXAMPLE 44 cacaview /usr/share/pixmaps/*.* 45 .SH BUGS 46 There is no support for aspect ratio yet. Also, since there is no way 47 yet to load an image from 48 .B cacaview 49 it is completely useless when run without an argument. 50 .SH AUTHOR 51 This manual page was written by Sam Hocevar <sam@zoy.org>. -
libcaca/trunk/examples/Makefile.am
r224 r236 28 28 cacaview_SOURCES = view.c 29 29 cacaview_LDADD = ../src/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) 30 cacaview_CPPFLAGS = -I$(top_srcdir)/src 30 cacaview_CPPFLAGS = -I$(top_srcdir)/src -DX_DISPLAY_MISSING=1 31 31 cacaview_CFLAGS = `imlib2-config --cflags` 32 32 cacaview_LDFLAGS = `imlib2-config --libs` -
libcaca/trunk/examples/view.c
r235 r236 27 27 #include <string.h> 28 28 #include <malloc.h> 29 30 #define X_DISPLAY_MISSING 1 29 #include <unistd.h> 30 31 31 #include <Imlib2.h> 32 32 … … 102 102 break; 103 103 case CACA_EVENT_KEY_PRESS | 'd': 104 dithering = (dithering + 1) % 4; 105 update = 1; 106 break; 104 107 case CACA_EVENT_KEY_PRESS | 'D': 105 dithering = (dithering +1) % 4;108 dithering = (dithering - 1) % 4; 106 109 update = 1; 107 110 break; … … 144 147 break; 145 148 case CACA_EVENT_KEY_PRESS | '?': 146 help = !help;149 help = 1; 147 150 update = 1; 148 151 break; … … 174 177 } 175 178 176 if(update) 177 { 178 caca_clear(); 179 caca_set_dithering(dithering); 180 caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE); 181 182 if(!items) 183 caca_printf(ww / 2 - 5, wh / 2, " No image. "); 184 else if(!image) 185 { 186 char *buffer = malloc(ww + 1); 187 snprintf(buffer, ww, " Error loading `%s'. ", list[current]); 188 buffer[ww] = '\0'; 189 caca_putstr((ww - strlen(buffer)) / 2, wh / 2, buffer); 190 free(buffer); 191 } 192 else if(zoom < 0) 193 { 194 int xo = (ww - 1) / 2; 195 int yo = (wh - 1) / 2; 196 int xn = (ww - 1) / (2 - zoom); 197 int yn = (wh - 1) / (2 - zoom); 198 caca_draw_bitmap(xo - xn, yo - yn, xo + xn, yo + yn, 199 bitmap, pixels); 200 } 201 else if(zoom > 0) 202 { 203 struct caca_bitmap *newbitmap; 204 int xn = w / (2 + zoom); 205 int yn = h / (2 + zoom); 206 if(x < xn) x = xn; 207 if(y < yn) y = yn; 208 if(xn + x > w) x = w - xn; 209 if(yn + y > h) y = h - yn; 210 newbitmap = caca_create_bitmap(32, 2 * xn, 2 * yn, 4 * w, 211 0x00ff0000, 0x0000ff00, 0x000000ff); 212 caca_draw_bitmap(0, 0, ww - 1, wh - 1, newbitmap, 213 pixels + 4 * (x - xn) + 4 * w * (y - yn)); 214 caca_free_bitmap(newbitmap); 215 } 216 else 217 { 218 caca_draw_bitmap(0, 0, ww - 1, wh - 1, bitmap, pixels); 219 } 220 221 caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE); 222 caca_draw_line(0, 0, ww - 1, 0, ' '); 223 caca_draw_line(0, wh - 1, ww - 1, wh - 1, '-'); 224 caca_putstr(0, 0, "q:Quit +/-/x:Zoom h/j/k/l: Move " 225 "d:Dithering ?:Help"); 226 caca_printf(3, wh - 1, "cacaview %s", VERSION); 227 caca_printf(ww / 2 - 5, wh - 1, "(dithering: %s)", 228 caca_get_dithering_name(dithering)); 229 caca_printf(ww - 14, wh - 1, 230 "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom); 231 232 if(help) 233 { 234 caca_putstr(2, 2, " +: zoom in "); 235 caca_putstr(2, 3, " -: zoom out "); 236 caca_putstr(2, 4, " x: reset zoom "); 237 caca_putstr(2, 5, " ------------------- "); 238 caca_putstr(2, 6, " hjkl: move view "); 239 caca_putstr(2, 7, " arrows: move view "); 240 caca_putstr(2, 8, " ------------------- "); 241 caca_putstr(2, 9, " d: dithering method "); 242 caca_putstr(2, 10, " ------------------- "); 243 caca_putstr(2, 11, " ?: help "); 244 caca_putstr(2, 12, " q: quit "); 245 246 help = 0; 247 } 248 249 caca_refresh(); 250 update = 0; 251 } 179 if(!update) 180 { 181 usleep(10000); 182 continue; 183 } 184 185 caca_clear(); 186 caca_set_dithering(dithering); 187 caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE); 188 189 if(!items) 190 caca_printf(ww / 2 - 5, wh / 2, " No image. "); 191 else if(!image) 192 { 193 char *buffer = malloc(ww + 1); 194 snprintf(buffer, ww, " Error loading `%s'. ", list[current]); 195 buffer[ww] = '\0'; 196 caca_putstr((ww - strlen(buffer)) / 2, wh / 2, buffer); 197 free(buffer); 198 } 199 else if(zoom < 0) 200 { 201 int xo = (ww - 1) / 2; 202 int yo = (wh - 1) / 2; 203 int xn = (ww - 1) / (2 - zoom); 204 int yn = (wh - 1) / (2 - zoom); 205 caca_draw_bitmap(xo - xn, yo - yn, xo + xn, yo + yn, 206 bitmap, pixels); 207 } 208 else if(zoom > 0) 209 { 210 struct caca_bitmap *newbitmap; 211 int xn = w / (2 + zoom); 212 int yn = h / (2 + zoom); 213 if(x < xn) x = xn; 214 if(y < yn) y = yn; 215 if(xn + x > w) x = w - xn; 216 if(yn + y > h) y = h - yn; 217 newbitmap = caca_create_bitmap(32, 2 * xn, 2 * yn, 4 * w, 218 0x00ff0000, 0x0000ff00, 0x000000ff); 219 caca_draw_bitmap(0, 0, ww - 1, wh - 1, newbitmap, 220 pixels + 4 * (x - xn) + 4 * w * (y - yn)); 221 caca_free_bitmap(newbitmap); 222 } 223 else 224 { 225 caca_draw_bitmap(0, 0, ww - 1, wh - 1, bitmap, pixels); 226 } 227 228 caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE); 229 caca_draw_line(0, 0, ww - 1, 0, ' '); 230 caca_draw_line(0, wh - 1, ww - 1, wh - 1, '-'); 231 caca_putstr(0, 0, "q:Quit n/p:Next/Prev +/-/x:Zoom " 232 "h/j/k/l: Move d:Dithering"); 233 caca_putstr(ww - strlen("?:Help"), 0, "?:Help"); 234 caca_printf(3, wh - 1, "cacaview %s", VERSION); 235 caca_printf(ww / 2 - 5, wh - 1, "(%s dithering)", 236 caca_get_dithering_name(dithering)); 237 caca_printf(ww - 14, wh - 1, 238 "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom); 239 240 if(help) 241 { 242 caca_putstr(ww - 22, 2, " +: zoom in "); 243 caca_putstr(ww - 22, 3, " -: zoom out "); 244 caca_putstr(ww - 22, 4, " x: reset zoom "); 245 caca_putstr(ww - 22, 5, " ------------------- "); 246 caca_putstr(ww - 22, 6, " hjkl: move view "); 247 caca_putstr(ww - 22, 7, " arrows: move view "); 248 caca_putstr(ww - 22, 8, " ------------------- "); 249 caca_putstr(ww - 22, 9, " d: dithering method "); 250 caca_putstr(ww - 22, 10, " ------------------- "); 251 caca_putstr(ww - 22, 11, " ?: help "); 252 caca_putstr(ww - 22, 12, " q: quit "); 253 254 help = 0; 255 } 256 257 caca_refresh(); 258 update = 0; 252 259 } 253 260 -
libcaca/trunk/src/caca.c
r235 r236 185 185 static const char *dithering_names[] = 186 186 { 187 "no ne",188 " ordered 4x4",189 " ordered 8x8",187 "no", 188 "4x4 ordered", 189 "8x8 ordered", 190 190 "random" 191 191 };
Note: See TracChangeset
for help on using the changeset viewer.