Bläddra i källkod

* pixels.c: allow to call pipi_getpixels with PIPI_PIXELS_MASK_C.

* pixels.c: simplify Floyd-Steinberg coefficients.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2773 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 år sedan
förälder
incheckning
f3a19b6ce5
1 ändrade filer med 14 tillägg och 10 borttagningar
  1. +14
    -10
      pipi/pixels.c

+ 14
- 10
pipi/pixels.c Visa fil

@@ -48,6 +48,10 @@ pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type)
if(img->last_modified == type)
return &img->p[type];

/* Handle special cases */
if(type == PIPI_PIXELS_MASK_C)
return &img->p[type];

/* Preliminary conversions */
if(img->last_modified == PIPI_PIXELS_RGBA_C
&& type == PIPI_PIXELS_Y_F)
@@ -152,16 +156,16 @@ pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type)

dest[4 * (y * img->w + x) + i] = d;

e = p - u8tof32(d);
e = (p - u8tof32(d)) / 8;
if(x < img->w - 1)
src[4 * (y * img->w + x + 1) + i] += e * .4375;
src[4 * (y * img->w + x + 1) + i] += e * 7;
if(y < img->h - 1)
{
if(x > 0)
src[4 * ((y + 1) * img->w + x - 1) + i] += e * .1875;
src[4 * ((y + 1) * img->w + x) + i] += e * .3125;
src[4 * ((y + 1) * img->w + x - 1) + i] += e * 3;
src[4 * ((y + 1) * img->w + x) + i] += e * 5;
if(x < img->w - 1)
src[4 * ((y + 1) * img->w + x + 1) + i] += e * .0625;
src[4 * ((y + 1) * img->w + x + 1) + i] += e;
}
}
}
@@ -188,16 +192,16 @@ pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type)

dest[3 * (y * img->w + x) + i] = d;

e = p - u8tof32(d);
e = (p - u8tof32(d));
if(x < img->w - 1)
src[4 * (y * img->w + x + 1) + i] += e * .4375;
src[4 * (y * img->w + x + 1) + i] += e * 7;
if(y < img->h - 1)
{
if(x > 0)
src[4 * ((y + 1) * img->w + x - 1) + i] += e * .1875;
src[4 * ((y + 1) * img->w + x) + i] += e * .3125;
src[4 * ((y + 1) * img->w + x - 1) + i] += e * 3;
src[4 * ((y + 1) * img->w + x) + i] += e * 5;
if(x < img->w - 1)
src[4 * ((y + 1) * img->w + x + 1) + i] += e * .0625;
src[4 * ((y + 1) * img->w + x + 1) + i] += e;
}
}
}


Laddar…
Avbryt
Spara