Changeset 230
- Timestamp:
- Nov 28, 2003, 9:39:54 PM (17 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/NOTES
r226 r230 18 18 19 19 From the xterm-16color terminfo: 20 (http://www.sct.gu.edu.au/~anthony/info/X/Xterm_xf86.terminfo) 20 21 21 22 setab=\E[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm, 22 23 setaf=\E[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm, 23 24 24 (http://www.sct.gu.edu.au/~anthony/info/X/Xterm_xf86.terminfo)25 These values can be simply retrieved with a tigetstr() call. 25 26 26 27 o I tested the following terminals: … … 76 77 + konsole (no bright bg, $blink really blinks) 77 78 78 o In an XTerm-compatible terminal, \e[9xm sets bright foreground and 79 \e[10xm bright background colours. Unfortunately all terminals don't 80 support these escape sequences. Here is a testcase: 79 o In an XTerm-compatible terminal, \e[9xm sets bright foreground 80 and \e[10xm bright background colours. Documentation on this can be 81 found at http://ftp.xfree86.org/pub/XFree86/4.2.1/doc/ctlseqs.TXT . 82 Unfortunately all terminals don't support these escape sequences. Here 83 is a testcase: 81 84 82 85 for fgpre in 3 9; do for fg in 0 4 2 6 1 5 3 7; do -
libcaca/trunk/examples/view.c
r217 r230 25 25 26 26 #include <stdio.h> 27 #include <string.h> 27 28 28 29 #define X_DISPLAY_MISSING 1 … … 41 42 int main(int argc, char **argv) 42 43 { 43 int quit = 0, update = 1 ;44 int quit = 0, update = 1, help = 0; 44 45 int x, y, w, h, zoom = 0; 45 46 … … 109 110 update = 1; 110 111 break; 112 case CACA_EVENT_KEY_PRESS | 'k': 113 case CACA_EVENT_KEY_PRESS | 'K': 111 114 case CACA_EVENT_KEY_PRESS | CACA_KEY_UP: 112 115 if(zoom > 0) y -= 1 + h / (2 + zoom) / 8; 113 116 update = 1; 114 117 break; 118 case CACA_EVENT_KEY_PRESS | 'j': 119 case CACA_EVENT_KEY_PRESS | 'J': 115 120 case CACA_EVENT_KEY_PRESS | CACA_KEY_DOWN: 116 121 if(zoom > 0) y += 1 + h / (2 + zoom) / 8; 117 122 update = 1; 118 123 break; 124 case CACA_EVENT_KEY_PRESS | 'h': 125 case CACA_EVENT_KEY_PRESS | 'H': 119 126 case CACA_EVENT_KEY_PRESS | CACA_KEY_LEFT: 120 127 if(zoom > 0) x -= 1 + w / (2 + zoom) / 8; 121 128 update = 1; 122 129 break; 130 case CACA_EVENT_KEY_PRESS | 'l': 131 case CACA_EVENT_KEY_PRESS | 'L': 123 132 case CACA_EVENT_KEY_PRESS | CACA_KEY_RIGHT: 124 133 if(zoom > 0) x += 1 + w / (2 + zoom) / 8; 134 update = 1; 135 break; 136 case CACA_EVENT_KEY_PRESS | '?': 137 help = !help; 125 138 update = 1; 126 139 break; … … 134 147 if(update) 135 148 { 149 int ww = caca_get_width(); 150 int wh = caca_get_height(); 151 136 152 caca_clear(); 137 153 caca_set_dithering(dithering_list[dithering]); 138 154 if(zoom < 0) 139 155 { 140 int xo = ( caca_get_width()- 1) / 2;141 int yo = ( caca_get_height()- 1) / 2;142 int xn = ( caca_get_width()- 1) / (2 - zoom);143 int yn = ( caca_get_height()- 1) / (2 - zoom);156 int xo = (ww - 1) / 2; 157 int yo = (wh - 1) / 2; 158 int xn = (ww - 1) / (2 - zoom); 159 int yn = (wh - 1) / (2 - zoom); 144 160 caca_draw_bitmap(xo - xn, yo - yn, xo + xn, yo + yn, 145 161 bitmap, pixels); … … 155 171 if(yn + y > h) y = h - yn; 156 172 newbitmap = caca_create_bitmap(32, 2 * xn, 2 * yn, 4 * w, 157 0x00ff0000, 0x0000ff00, 0x000000ff); 158 caca_draw_bitmap(0, 0, caca_get_width() - 1, 159 caca_get_height() - 1, newbitmap, 173 0x00ff0000, 0x0000ff00, 0x000000ff); 174 caca_draw_bitmap(0, 0, ww - 1, wh - 1, newbitmap, 160 175 pixels + 4 * (x - xn) + 4 * w * (y - yn)); 161 176 caca_free_bitmap(newbitmap); … … 163 178 else 164 179 { 165 caca_draw_bitmap(0, 0, caca_get_width() - 1, 166 caca_get_height() - 1, bitmap, pixels); 167 } 180 caca_draw_bitmap(0, 0, ww - 1, wh - 1, bitmap, pixels); 181 } 182 183 caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE); 184 caca_draw_line(0, 0, ww - 1, 0, ' '); 185 caca_printf(1, 0, "cacaview %s", VERSION); 186 caca_putstr(ww - strlen("'?' for help") - 1, 0, 187 "'?' for help"); 188 189 if(help) 190 { 191 caca_putstr(2, 2, " +: zoom in "); 192 caca_putstr(2, 3, " -: zoom out "); 193 caca_putstr(2, 4, " x: reset zoom "); 194 caca_putstr(2, 5, " ------------------- "); 195 caca_putstr(2, 6, " hjkl: move view "); 196 caca_putstr(2, 7, " arrows: move view "); 197 caca_putstr(2, 8, " ------------------- "); 198 caca_putstr(2, 9, " d: dithering method "); 199 caca_putstr(2, 10, " ------------------- "); 200 caca_putstr(2, 11, " ?: help "); 201 caca_putstr(2, 12, " q: quit "); 202 203 help = 0; 204 } 205 168 206 caca_refresh(); 169 207 update = 0; -
libcaca/trunk/src/bitmap.c
r229 r230 222 222 break; 223 223 case 3: 224 bits = (pixels[0] << 16) 225 | (pixels[1] << 8) 226 | (pixels[2]); 224 bits = (pixels[0] << 16) | (pixels[1] << 8) | (pixels[2]); 227 225 break; 228 226 case 2: … … 257 255 if(min > b) min = b; if(max < b) max = b; 258 256 259 delta = max - min; /* 0 - 65535 */ 260 *val = max; /* 0 - 65535 */ 261 *sat = max ? 0x100 * delta / max * 0x100: 0; /* 0 - 65536 */ 262 263 if(*sat > (_get_dither() + 24) * 0x400) 264 { 265 /* XXX: Values should be between 1 and 6, but since we 266 * are dithering, there may be overflows, hence our bigger 267 * *_colors[] tables. */ 257 delta = max - min; /* 0 - 0xffff */ 258 *val = max; /* 0 - 0xffff */ 259 260 if(delta) 261 { 262 *sat = 0x1000 * delta / max * 0x10; /* 0 - 0xffff */ 263 264 /* Generate *hue between 0 and 0x5ffff */ 268 265 if( r == max ) 269 266 *hue = 0x10000 + 0x100 * (g - b) / delta * 0x100; … … 272 269 else 273 270 *hue = 0x50000 + 0x100 * (r - g) / delta * 0x100; 274 275 *hue = (*hue + 0x8000 + 0x1000 * _get_dither()) / 0x10000;276 271 } 277 272 else 278 273 { 279 274 *sat = 0; 275 *hue = 0; 280 276 } 281 277 } … … 360 356 int fromx = w * (x - x1) / (x2 - x1 + 1); 361 357 int fromy = h * (y - y1) / (y2 - y1 + 1); 358 359 /* Clip values (yuck) */ 360 if(fromx == 0) fromx = 1; 361 if(fromy == 0) fromy = 1; 362 362 363 363 /* First get RGB */ … … 378 378 rgb2hsv_default(R, G, B, &hue, &sat, &val); 379 379 380 if( !sat)380 if(sat < 0x6000 + _get_dither() * 0x800) 381 381 caca_set_color(white_colors[val * 3 / 0x10000], CACA_COLOR_BLACK); 382 382 else if(val > (_get_dither() + 40) * 0x400) 383 caca_set_color(light_colors[ hue], CACA_COLOR_BLACK);383 caca_set_color(light_colors[(hue + 0x8000 + _get_dither() * 0x1000) / 0x10000], CACA_COLOR_BLACK); 384 384 else 385 caca_set_color(dark_colors[ hue], CACA_COLOR_BLACK);385 caca_set_color(dark_colors[(hue + 0x8000 + _get_dither() * 0x1000) / 0x10000], CACA_COLOR_BLACK); 386 386 387 387 /* FIXME: choose better characters! */
Note: See TracChangeset
for help on using the changeset viewer.