.4.51 pl 28

This commit is contained in:
tTh
2022-09-17 11:23:21 +02:00
parent 20754c17e9
commit dec52079cd
51 changed files with 276 additions and 380 deletions

View File

@@ -30,13 +30,12 @@ static uint8_t priv_fonte[T_FONTE];
/*
* for now, parameter *ou must be NULL
*/
int
Image_load_fnt8x8(char *nomfnt, uint8_t *ou, int flags)
int Image_load_fnt8x8(char *nomfnt, uint8_t *ou, int flags)
{
int fd, foo;
#if DEBUG_LEVEL > 1
fprintf(stderr, "%s: %s %p %d\n", __func__, nomfnt, ou, flags);
#if DEBUG_LEVEL > -1
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, nomfnt, ou, flags);
#endif
if (NULL != ou)
@@ -51,15 +50,13 @@ if (NULL == nomfnt) {
}
/* on pourrait aussi mettre la fonte par ddefaut dans l'environ */
if ( (fd=Image_must_open(nomfnt, O_RDONLY, 0)) < 0 )
{
if ( (fd=Image_must_open(nomfnt, O_RDONLY, 0)) < 0 ) {
perror (nomfnt);
exit(5);
}
foo = read(fd, priv_fonte, T_FONTE);
if ( foo != T_FONTE )
{
if ( foo != T_FONTE ) {
fprintf(stderr, "%s: error when reading font datas\n", __func__);
exit(5);
}
@@ -75,8 +72,7 @@ return OLL_KORRECT;
/*
* XXX nasty bug in the alpha channel gestion XXX
*/
int
Image_trace_caractere_2(Image_Desc *im, uint8_t *fnt, int x, int y, int code,
int Image_trace_caractere_2(Image_Desc *im, uint8_t *fnt, int x, int y, int code,
RGBA *paper, RGBA *ink)
{
int foo, bar, xi, yi;
@@ -88,17 +84,14 @@ fprintf(stderr, "trace car 2: xy= %4d %4d c= %c\n", x, y,
isprint(code) ? code : ' ');
#endif
if (NULL==fnt)
{
if (NULL==fnt) {
fnt = priv_fonte; /* use local static storage */
}
for (foo=0; foo<8; foo++)
{
for (foo=0; foo<8; foo++) {
yi = y+foo;
octet = fnt[(code*8)+foo];
for (bar=0; bar<8; bar++)
{
for (bar=0; bar<8; bar++) {
xi = x+7-bar;
/* lecture contenu image */
@@ -106,14 +99,12 @@ for (foo=0; foo<8; foo++)
gs = (im->Gpix[yi])[xi];
bs = (im->Bpix[yi])[xi];
if (octet & 1) /* ENCRE */
{
if (octet & 1) { /* ENCRE */
rp = ((rs*(255-ink->a))+(ink->r*ink->a)) / 255;
gp = ((gs*(255-ink->a))+(ink->g*ink->a)) / 255;
bp = ((bs*(255-ink->a))+(ink->b*ink->a)) / 255;
}
else /* PAPIER */
{
else { /* PAPIER */
rp = ((rs*(255-paper->a))+(paper->r*paper->a)) / 255;
gp = ((gs*(255-paper->a))+(paper->g*paper->a)) / 255;
bp = ((bs*(255-paper->a))+(paper->b*paper->a)) / 255;
@@ -131,17 +122,14 @@ return 42;
/*
* fonction très primitive...
*/
int
Image_trace_caractere(Image_Desc *im, int x, int y, int code)
int Image_trace_caractere(Image_Desc *im, int x, int y, int code)
{
int foo, bar;
uint8_t octet;
for (foo=0; foo<8; foo++)
{
for (foo=0; foo<8; foo++) {
octet = priv_fonte[(code*8)+foo];
for (bar=0; bar<8; bar++)
{
for (bar=0; bar<8; bar++) {
if (octet & 1)
Image_plotRGB(im, x+8-bar, y+foo, 255, 255, 255);
else
@@ -214,11 +202,9 @@ fprintf(stderr, "encre %3d %3d %3d %3d\n", ink->r, ink->g, ink->b, ink->a);
#endif
posx = x; posy = y;
for (foo=0; foo<t_texte; foo++)
{
for (foo=0; foo<t_texte; foo++) {
octet = ptrtxt[foo];
if (posx > (im->width-8))
{
if (posx > (im->width-8)) {
fprintf(stderr, "can't plot char '%c' at x=%d\n", octet, posx);
break;
}