Changeset 816
- Timestamp:
- Apr 18, 2006, 6:50:56 PM (15 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/dither.c
r815 r816 695 695 * 696 696 * \param cv A handle to the libcucul canvas. 697 * \param x 1X coordinate of the upper-left corner of the drawing area.698 * \param y 1Y coordinate of the upper-left corner of the drawing area.699 * \param x2 X coordinate of the lower-right cornerof the drawing area.700 * \param y2 Y coordinate of the lower-right cornerof the drawing area.697 * \param x X coordinate of the upper-left corner of the drawing area. 698 * \param y Y coordinate of the upper-left corner of the drawing area. 699 * \param w Width of the drawing area. 700 * \param h Height of the drawing area. 701 701 * \param d Dither object to be drawn. 702 702 * \param pixels Bitmap's pixels. 703 703 */ 704 void cucul_dither_bitmap(cucul_canvas_t *cv, int x 1, int y1, int x2, int y2,704 void cucul_dither_bitmap(cucul_canvas_t *cv, int x, int y, int w, int h, 705 705 cucul_dither_t const *d, void *pixels) 706 706 { 707 707 int *floyd_steinberg, *fs_r, *fs_g, *fs_b; 708 708 int fs_length; 709 int x , y, w, h, pitch, deltax, deltay;709 int x1, y1, x2, y2, pitch, deltax, deltay; 710 710 unsigned int dchmax; 711 711 … … 713 713 return; 714 714 715 x1 = x; x2 = x + w - 1; 716 y1 = y; y2 = y + h - 1; 717 718 /* FIXME: do not overwrite arguments */ 715 719 w = d->w; 716 720 h = d->h; 717 721 pitch = d->pitch; 718 719 if(x1 > x2)720 {721 int tmp = x2; x2 = x1; x1 = tmp;722 }723 724 if(y1 > y2)725 {726 int tmp = y2; y2 = y1; y1 = tmp;727 }728 722 729 723 deltax = x2 - x1 + 1; -
libcaca/trunk/src/aafire.c
r813 r816 238 238 #ifdef LIBCACA 239 239 paused: 240 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,241 cucul_get_canvas_height(cv) - 1, cucul_dither, bitmap);240 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), 241 cucul_get_canvas_height(cv), cucul_dither, bitmap); 242 242 cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); 243 243 cucul_putstr(cv, cucul_get_canvas_width(cv) - 30, -
libcaca/trunk/src/cacaball.c
r813 r816 155 155 /* Draw our virtual buffer to screen, letting libcucul resize it */ 156 156 cucul_dither_bitmap(cv, 0, 0, 157 cucul_get_canvas_width(cv) - 1,158 cucul_get_canvas_height(cv) - 1,157 cucul_get_canvas_width(cv), 158 cucul_get_canvas_height(cv), 159 159 cucul_dither, pixels + (METASIZE / 2) * (1 + XSIZ)); 160 160 cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); -
libcaca/trunk/src/cacamoir.c
r813 r816 108 108 paused: 109 109 cucul_dither_bitmap(cv, 0, 0, 110 cucul_get_canvas_width(cv) - 1,111 cucul_get_canvas_height(cv) - 1,110 cucul_get_canvas_width(cv), 111 cucul_get_canvas_height(cv), 112 112 dither, screen); 113 113 cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); -
libcaca/trunk/src/cacaplas.c
r813 r816 123 123 paused: 124 124 cucul_dither_bitmap(cv, 0, 0, 125 cucul_get_canvas_width(cv) - 1,126 cucul_get_canvas_height(cv) - 1,125 cucul_get_canvas_width(cv), 126 cucul_get_canvas_height(cv), 127 127 dither, screen); 128 128 -
libcaca/trunk/src/cacaview.c
r814 r816 363 363 draw_checkers(ww * (1.0 - xfactor) / 2, 364 364 y + height * (1.0 - yfactor) / 2, 365 ww * (1.0 + xfactor) / 2, 366 y + height * (1.0 + yfactor) / 2); 365 ww * xfactor, height * yfactor); 367 366 368 367 cucul_dither_bitmap(cv, ww * (1.0 - xfactor) * xdelta, 369 y + height * (1.0 - yfactor) * ydelta, 370 ww * (xdelta + (1.0 - xdelta) * xfactor), 371 y + height * (ydelta + (1.0 - ydelta) * yfactor), 372 im->dither, im->pixels); 368 y + height * (1.0 - yfactor) * ydelta, 369 ww * xfactor + 1, height * yfactor + 1, 370 im->dither, im->pixels); 373 371 } 374 372 … … 503 501 } 504 502 505 static void draw_checkers(int x 1, int y1, int x2, int y2)503 static void draw_checkers(int x, int y, int w, int h) 506 504 { 507 505 int xn, yn; 508 506 509 if(x 2 + 1> (int)cucul_get_canvas_width(cv))510 x2 = cucul_get_canvas_width(cv) - 1;511 if(y 2 + 1> (int)cucul_get_canvas_height(cv))512 y2 = cucul_get_canvas_height(cv) - 1;513 514 for(yn = y 1 > 0 ? y1 : 0; yn <= y2; yn++)515 for(xn = x 1 > 0 ? x1 : 0; xn <= x2; xn++)516 { 517 if((((xn - x 1) / 5) ^ ((yn - y1) / 3)) & 1)507 if(x + w > (int)cucul_get_canvas_width(cv)) 508 w = cucul_get_canvas_width(cv) - x; 509 if(y + h > (int)cucul_get_canvas_height(cv)) 510 h = cucul_get_canvas_height(cv) - y; 511 512 for(yn = y > 0 ? y : 0; yn < y + h; yn++) 513 for(xn = x > 0 ? x : 0; xn < x + w; xn++) 514 { 515 if((((xn - x) / 5) ^ ((yn - y) / 3)) & 1) 518 516 cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_DARKGRAY); 519 517 else -
libcaca/trunk/src/img2irc.c
r814 r816 55 55 cucul_set_canvas_size(cv, cols, lines); 56 56 cucul_clear_canvas(cv, CUCUL_COLOR_TRANSPARENT); 57 cucul_dither_bitmap(cv, 0, 0, cols - 1, lines - 1, i->dither, i->pixels);57 cucul_dither_bitmap(cv, 0, 0, cols, lines, i->dither, i->pixels); 58 58 59 59 unload_image(i); -
libcaca/trunk/test/demo.c
r815 r816 505 505 //dither = cucul_create_dither(16, 256, 256, 2 * 256, 0xf800, 0x07e0, 0x001f, 0x0000); 506 506 dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); 507 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1, cucul_get_canvas_height(cv) - 1,507 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv), 508 508 dither, buffer); 509 509 cucul_free_dither(dither); … … 550 550 dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); 551 551 cucul_set_dither_invert(dither, 1); 552 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1, cucul_get_canvas_height(cv) - 1, dither, (char *)buffer);552 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv), dither, (char *)buffer); 553 553 cucul_free_dither(dither); 554 554 } -
libcaca/trunk/test/export.c
r813 r816 81 81 dither = cucul_create_dither(32, 256, 256, 4 * 256, 82 82 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); 83 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,84 cucul_get_canvas_height(cv) - 1, dither, pixels);83 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), 84 cucul_get_canvas_height(cv), dither, pixels); 85 85 cucul_free_dither(dither); 86 86 -
libcaca/trunk/test/font.c
r813 r816 94 94 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff); 95 95 96 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,97 cucul_get_canvas_height(cv) - 1, d, buf);96 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), 97 cucul_get_canvas_height(cv), d, buf); 98 98 caca_display(dp); 99 99 -
libcaca/trunk/test/gamma.c
r814 r816 82 82 83 83 /* Draw the regular dither on the main canvas */ 84 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,85 cucul_get_canvas_height(cv) - 1, left, buffer);84 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), 85 cucul_get_canvas_height(cv), left, buffer); 86 86 87 87 /* Draw the gamma-modified dither on the spare canvas */ 88 88 cucul_set_dither_gamma(right, gam); 89 cucul_dither_bitmap(cw, 0, 0, cucul_get_canvas_width(cw) - 1,90 cucul_get_canvas_height(cw) - 1, right, buffer);89 cucul_dither_bitmap(cw, 0, 0, cucul_get_canvas_width(cw), 90 cucul_get_canvas_height(cw), right, buffer); 91 91 92 92 /* Draw something on the mask */ -
libcaca/trunk/test/hsv.c
r813 r816 47 47 dither = cucul_create_dither(32, 256, 256, 4 * 256, 48 48 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); 49 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,50 cucul_get_canvas_height(cv) - 1, dither, buffer);49 cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), 50 cucul_get_canvas_height(cv), dither, buffer); 51 51 cucul_free_dither(dither); 52 52
Note: See TracChangeset
for help on using the changeset viewer.