Преглед изворни кода

* Changed the cucul_dither_bitmap behaviour so that the 4 coordinates are

now x/y/width/height instead of x1/y1/x2/y2. Avoids unnecessary +1/-1
    computations.
tags/v0.99.beta14
Sam Hocevar sam пре 19 година
родитељ
комит
0deb4abc25
12 измењених фајлова са 43 додато и 51 уклоњено
  1. +10
    -16
      cucul/dither.c
  2. +2
    -2
      src/aafire.c
  3. +2
    -2
      src/cacaball.c
  4. +2
    -2
      src/cacamoir.c
  5. +2
    -2
      src/cacaplas.c
  6. +12
    -14
      src/cacaview.c
  7. +1
    -1
      src/img2irc.c
  8. +2
    -2
      test/demo.c
  9. +2
    -2
      test/export.c
  10. +2
    -2
      test/font.c
  11. +4
    -4
      test/gamma.c
  12. +2
    -2
      test/hsv.c

+ 10
- 16
cucul/dither.c Прегледај датотеку

@@ -694,38 +694,32 @@ char const * const * cucul_get_dither_mode_list(cucul_dither_t const *d)
* and will be stretched to the text area.
*
* \param cv A handle to the libcucul canvas.
* \param x1 X coordinate of the upper-left corner of the drawing area.
* \param y1 Y coordinate of the upper-left corner of the drawing area.
* \param x2 X coordinate of the lower-right corner of the drawing area.
* \param y2 Y coordinate of the lower-right corner of the drawing area.
* \param x X coordinate of the upper-left corner of the drawing area.
* \param y Y coordinate of the upper-left corner of the drawing area.
* \param w Width of the drawing area.
* \param h Height of the drawing area.
* \param d Dither object to be drawn.
* \param pixels Bitmap's pixels.
*/
void cucul_dither_bitmap(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
void cucul_dither_bitmap(cucul_canvas_t *cv, int x, int y, int w, int h,
cucul_dither_t const *d, void *pixels)
{
int *floyd_steinberg, *fs_r, *fs_g, *fs_b;
int fs_length;
int x, y, w, h, pitch, deltax, deltay;
int x1, y1, x2, y2, pitch, deltax, deltay;
unsigned int dchmax;

if(!d || !pixels)
return;

x1 = x; x2 = x + w - 1;
y1 = y; y2 = y + h - 1;

/* FIXME: do not overwrite arguments */
w = d->w;
h = d->h;
pitch = d->pitch;

if(x1 > x2)
{
int tmp = x2; x2 = x1; x1 = tmp;
}

if(y1 > y2)
{
int tmp = y2; y2 = y1; y1 = tmp;
}

deltax = x2 - x1 + 1;
deltay = y2 - y1 + 1;
dchmax = d->glyph_count;


+ 2
- 2
src/aafire.c Прегледај датотеку

@@ -237,8 +237,8 @@ drawfire (void)
firemain ();
#ifdef LIBCACA
paused:
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1, cucul_dither, bitmap);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),
cucul_get_canvas_height(cv), cucul_dither, bitmap);
cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,
cucul_get_canvas_height(cv) - 2, " -=[ Powered by libcaca ]=- ");


+ 2
- 2
src/cacaball.c Прегледај датотеку

@@ -154,8 +154,8 @@ int main(int argc, char **argv)
paused:
/* Draw our virtual buffer to screen, letting libcucul resize it */
cucul_dither_bitmap(cv, 0, 0,
cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1,
cucul_get_canvas_width(cv),
cucul_get_canvas_height(cv),
cucul_dither, pixels + (METASIZE / 2) * (1 + XSIZ));
cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,


+ 2
- 2
src/cacamoir.c Прегледај датотеку

@@ -107,8 +107,8 @@ int main (int argc, char **argv)

paused:
cucul_dither_bitmap(cv, 0, 0,
cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1,
cucul_get_canvas_width(cv),
cucul_get_canvas_height(cv),
dither, screen);
cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,


+ 2
- 2
src/cacaplas.c Прегледај датотеку

@@ -122,8 +122,8 @@ int main (int argc, char **argv)

paused:
cucul_dither_bitmap(cv, 0, 0,
cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1,
cucul_get_canvas_width(cv),
cucul_get_canvas_height(cv),
dither, screen);

cucul_blit(c2, 0, 0, cv, NULL);


+ 12
- 14
src/cacaview.c Прегледај датотеку

@@ -362,14 +362,12 @@ int main(int argc, char **argv)

draw_checkers(ww * (1.0 - xfactor) / 2,
y + height * (1.0 - yfactor) / 2,
ww * (1.0 + xfactor) / 2,
y + height * (1.0 + yfactor) / 2);
ww * xfactor, height * yfactor);

cucul_dither_bitmap(cv, ww * (1.0 - xfactor) * xdelta,
y + height * (1.0 - yfactor) * ydelta,
ww * (xdelta + (1.0 - xdelta) * xfactor),
y + height * (ydelta + (1.0 - ydelta) * yfactor),
im->dither, im->pixels);
y + height * (1.0 - yfactor) * ydelta,
ww * xfactor + 1, height * yfactor + 1,
im->dither, im->pixels);
}

if(!fullscreen)
@@ -502,19 +500,19 @@ static void set_gamma(int new_gamma)
(g < 0) ? 1.0 / gammatab[-g] : gammatab[g]);
}

static void draw_checkers(int x1, int y1, int x2, int y2)
static void draw_checkers(int x, int y, int w, int h)
{
int xn, yn;

if(x2 + 1 > (int)cucul_get_canvas_width(cv))
x2 = cucul_get_canvas_width(cv) - 1;
if(y2 + 1 > (int)cucul_get_canvas_height(cv))
y2 = cucul_get_canvas_height(cv) - 1;
if(x + w > (int)cucul_get_canvas_width(cv))
w = cucul_get_canvas_width(cv) - x;
if(y + h > (int)cucul_get_canvas_height(cv))
h = cucul_get_canvas_height(cv) - y;

for(yn = y1 > 0 ? y1 : 0; yn <= y2; yn++)
for(xn = x1 > 0 ? x1 : 0; xn <= x2; xn++)
for(yn = y > 0 ? y : 0; yn < y + h; yn++)
for(xn = x > 0 ? x : 0; xn < x + w; xn++)
{
if((((xn - x1) / 5) ^ ((yn - y1) / 3)) & 1)
if((((xn - x) / 5) ^ ((yn - y) / 3)) & 1)
cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_DARKGRAY);
else
cucul_set_color(cv, CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_LIGHTGRAY);


+ 1
- 1
src/img2irc.c Прегледај датотеку

@@ -54,7 +54,7 @@ int main(int argc, char **argv)

cucul_set_canvas_size(cv, cols, lines);
cucul_clear_canvas(cv, CUCUL_COLOR_TRANSPARENT);
cucul_dither_bitmap(cv, 0, 0, cols - 1, lines - 1, i->dither, i->pixels);
cucul_dither_bitmap(cv, 0, 0, cols, lines, i->dither, i->pixels);

unload_image(i);



+ 2
- 2
test/demo.c Прегледај датотеку

@@ -504,7 +504,7 @@ static void demo_render(void)
cucul_set_dither_invert(dither, 1);
//dither = cucul_create_dither(16, 256, 256, 2 * 256, 0xf800, 0x07e0, 0x001f, 0x0000);
dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1, cucul_get_canvas_height(cv) - 1,
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv),
dither, buffer);
cucul_free_dither(dither);
}
@@ -549,7 +549,7 @@ static void demo_render(void)

dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
cucul_set_dither_invert(dither, 1);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1, cucul_get_canvas_height(cv) - 1, dither, (char *)buffer);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv), dither, (char *)buffer);
cucul_free_dither(dither);
}



+ 2
- 2
test/export.c Прегледај датотеку

@@ -80,8 +80,8 @@ int main(int argc, char *argv[])

dither = cucul_create_dither(32, 256, 256, 4 * 256,
0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1, dither, pixels);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),
cucul_get_canvas_height(cv), dither, pixels);
cucul_free_dither(dither);

cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);


+ 2
- 2
test/font.c Прегледај датотеку

@@ -93,8 +93,8 @@ int main(int argc, char *argv[])
d = cucul_create_dither(32, w, h, 4 * w,
0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff);

cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1, d, buf);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),
cucul_get_canvas_height(cv), d, buf);
caca_display(dp);

caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);


+ 4
- 4
test/gamma.c Прегледај датотеку

@@ -81,13 +81,13 @@ int main(void)
cucul_set_canvas_size(mask, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));

/* Draw the regular dither on the main canvas */
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1, left, buffer);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),
cucul_get_canvas_height(cv), left, buffer);

/* Draw the gamma-modified dither on the spare canvas */
cucul_set_dither_gamma(right, gam);
cucul_dither_bitmap(cw, 0, 0, cucul_get_canvas_width(cw) - 1,
cucul_get_canvas_height(cw) - 1, right, buffer);
cucul_dither_bitmap(cw, 0, 0, cucul_get_canvas_width(cw),
cucul_get_canvas_height(cw), right, buffer);

/* Draw something on the mask */
cucul_clear_canvas(mask, CUCUL_COLOR_BLACK);


+ 2
- 2
test/hsv.c Прегледај датотеку

@@ -46,8 +46,8 @@ int main(void)

dither = cucul_create_dither(32, 256, 256, 4 * 256,
0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1, dither, buffer);
cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),
cucul_get_canvas_height(cv), dither, buffer);
cucul_free_dither(dither);

caca_display(dp);


Loading…
Откажи
Сачувај