"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "caca/dither.c" between
libcaca-0.99.beta19.tar.gz and libcaca-0.99.beta20.tar.bz2

About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).

dither.c  (libcaca-0.99.beta19):dither.c  (libcaca-0.99.beta20.tar.bz2)
/* /*
* libcaca Colour ASCII-Art library * libcaca Colour ASCII-Art library
* Copyright (c) 2002-2012 Sam Hocevar <sam@hocevar.net> * Copyright © 2002—2018 Sam Hocevar <sam@hocevar.net>
* All Rights Reserved * All Rights Reserved
* *
* This library is free software. It comes without any warranty, to * This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it * the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What the Fuck You Want * and/or modify it under the terms of the Do What the Fuck You Want
* to Public License, Version 2, as published by Sam Hocevar. See * to Public License, Version 2, as published by the WTFPL Task Force.
* http://www.wtfpl.net/ for more details. * See http://www.wtfpl.net/ for more details.
*/ */
/* /*
* This file contains bitmap dithering functions. * This file contains bitmap dithering functions.
*/ */
#include "config.h" #include "config.h"
#if !defined(__KERNEL__) #if !defined(__KERNEL__)
# if defined(HAVE_ENDIAN_H) # if defined(HAVE_ENDIAN_H)
skipping to change at line 119 skipping to change at line 119
COLOR_MODE_8, COLOR_MODE_8,
COLOR_MODE_16, COLOR_MODE_16,
COLOR_MODE_FULLGRAY, COLOR_MODE_FULLGRAY,
COLOR_MODE_FULL8, COLOR_MODE_FULL8,
COLOR_MODE_FULL16 COLOR_MODE_FULL16
}; };
struct caca_dither struct caca_dither
{ {
int bpp, has_palette, has_alpha; int bpp, has_palette, has_alpha;
int w, h, pitch; size_t w, h, pitch;
int rmask, gmask, bmask, amask; int rmask, gmask, bmask, amask;
int rright, gright, bright, aright; int rright, gright, bright, aright;
int rleft, gleft, bleft, aleft; int rleft, gleft, bleft, aleft;
void (*get_hsv)(caca_dither_t *, char *, int, int); void (*get_hsv)(caca_dither_t *, char *, int, int);
int red[256], green[256], blue[256], alpha[256]; int red[256], green[256], blue[256], alpha[256];
/* Colour features */ /* Colour features */
float gamma, brightness, contrast; float gamma, brightness, contrast;
int gammatab[4097]; int gammatab[4097];
skipping to change at line 994 skipping to change at line 994
int fromx, fromy, tox, toy, myx, myy, dots, dist; int fromx, fromy, tox, toy, myx, myy, dots, dist;
int outfg = 0, outbg = 0; int outfg = 0, outbg = 0;
uint32_t outch; uint32_t outch;
rgba[0] = rgba[1] = rgba[2] = rgba[3] = 0; rgba[0] = rgba[1] = rgba[2] = rgba[3] = 0;
/* First get RGB */ /* First get RGB */
if(d->antialias) if(d->antialias)
{ {
fromx = (x - x1) * w / deltax; fromx = (uint64_t)(x - x1) * w / deltax;
fromy = (y - y1) * h / deltay; fromy = (uint64_t)(y - y1) * h / deltay;
tox = (x - x1 + 1) * w / deltax; tox = (uint64_t)(x - x1 + 1) * w / deltax;
toy = (y - y1 + 1) * h / deltay; toy = (uint64_t)(y - y1 + 1) * h / deltay;
/* We want at least one pixel */ /* We want at least one pixel */
if(tox == fromx) tox++; if(tox == fromx) tox++;
if(toy == fromy) toy++; if(toy == fromy) toy++;
dots = 0; dots = 0;
for(myx = fromx; myx < tox; myx++) for(myx = fromx; myx < tox; myx++)
for(myy = fromy; myy < toy; myy++) for(myy = fromy; myy < toy; myy++)
{ {
skipping to change at line 1020 skipping to change at line 1020
} }
/* Normalize */ /* Normalize */
rgba[0] /= dots; rgba[0] /= dots;
rgba[1] /= dots; rgba[1] /= dots;
rgba[2] /= dots; rgba[2] /= dots;
rgba[3] /= dots; rgba[3] /= dots;
} }
else else
{ {
fromx = (x - x1) * w / deltax; fromx = (uint64_t)(x - x1) * w / deltax;
fromy = (y - y1) * h / deltay; fromy = (uint64_t)(y - y1) * h / deltay;
tox = (x - x1 + 1) * w / deltax; tox = (uint64_t)(x - x1 + 1) * w / deltax;
toy = (y - y1 + 1) * h / deltay; toy = (uint64_t)(y - y1 + 1) * h / deltay;
/* tox and toy can overflow the canvas, but they cannot overflow /* tox and toy can overflow the canvas, but they cannot overflow
* when averaged with fromx and fromy because these are guaranteed * when averaged with fromx and fromy because these are guaranteed
* to be within the pixel boundaries. */ * to be within the pixel boundaries. */
myx = (fromx + tox) / 2; myx = (fromx + tox) / 2;
myy = (fromy + toy) / 2; myy = (fromy + toy) / 2;
get_rgba_default(d, pixels, myx, myy, rgba); get_rgba_default(d, pixels, myx, myy, rgba);
} }
skipping to change at line 1577 skipping to change at line 1577
outfg = i; outfg = i;
distfg = dist; distfg = dist;
} }
} }
hsv_distances[v][s][h] = (outfg << 4) | outbg; hsv_distances[v][s][h] = (outfg << 4) | outbg;
} }
return 0; return 0;
} }
/*
* XXX: The following functions are aliases.
*/
cucul_dither_t *cucul_create_dither(int, int, int, int, uint32_t, uint32_t,
uint32_t, uint32_t)
CACA_ALIAS(caca_create_dither);
int cucul_set_dither_palette(cucul_dither_t *, uint32_t r[], uint32_t g[],
uint32_t b[], uint32_t a[])
CACA_ALIAS(caca_set_dither_palette);
int cucul_set_dither_brightness(cucul_dither_t *, float)
CACA_ALIAS(caca_set_dither_brightness);
float cucul_get_dither_brightness(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_brightness);
int cucul_set_dither_gamma(cucul_dither_t *, float)
CACA_ALIAS(caca_set_dither_gamma);
float cucul_get_dither_gamma(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_gamma);
int cucul_set_dither_contrast(cucul_dither_t *, float)
CACA_ALIAS(caca_set_dither_contrast);
float cucul_get_dither_contrast(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_contrast);
int cucul_set_dither_antialias(cucul_dither_t *, char const *)
CACA_ALIAS(caca_set_dither_antialias);
char const * const * cucul_get_dither_antialias_list(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_antialias_list);
char const * cucul_get_dither_antialias(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_antialias);
int cucul_set_dither_color(cucul_dither_t *, char const *)
CACA_ALIAS(caca_set_dither_color);
char const * const * cucul_get_dither_color_list(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_color_list);
char const * cucul_get_dither_color(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_color);
int cucul_set_dither_charset(cucul_dither_t *, char const *)
CACA_ALIAS(caca_set_dither_charset);
char const * const * cucul_get_dither_charset_list(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_charset_list);
char const * cucul_get_dither_charset(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_charset);
int cucul_set_dither_algorithm(cucul_dither_t *, char const *)
CACA_ALIAS(caca_set_dither_algorithm);
char const * const * cucul_get_dither_algorithm_list(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_algorithm_list);
char const * cucul_get_dither_algorithm(cucul_dither_t const *)
CACA_ALIAS(caca_get_dither_algorithm);
int cucul_dither_bitmap(cucul_canvas_t *, int, int, int, int,
cucul_dither_t const *, void *)
CACA_ALIAS(caca_dither_bitmap);
int cucul_free_dither(cucul_dither_t *) CACA_ALIAS(caca_free_dither);
 End of changes. 6 change blocks. 
14 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)