Explorar el Código

Reactivate pipi_dither_24to16, it's wrong but useful.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@4737 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam hace 14 años
padre
commit
d047d4bde1
Se han modificado 1 ficheros con 19 adiciones y 16 borrados
  1. +19
    -16
      pipi/dither.c

+ 19
- 16
pipi/dither.c Ver fichero

@@ -25,32 +25,34 @@
#include "pipi.h"
#include "pipi_internals.h"

/* FIXME: this is not the right place for this... see pixels.c instead */
void pipi_dither_24to16(pipi_image_t *img)
{
/* XXX: disabled because this is not the right place... see pixels.c instead */
#if 0
int *error, *nexterror;
pipi_pixels_t *p;
uint32_t *p32;
int x, y;

error = malloc(sizeof(int) * 3 * (img->width + 2));
nexterror = malloc(sizeof(int) * 3 * (img->width + 2));
p32 = (uint32_t *)img->pixels;
error = malloc(sizeof(int) * 3 * (img->w + 2));
nexterror = malloc(sizeof(int) * 3 * (img->w + 2));
p = pipi_get_pixels(img, PIPI_PIXELS_RGBA_U8);
p32 = (uint32_t *)p->pixels;

memset(error, 0, sizeof(int) * 3 * (img->width + 2));
memset(error, 0, sizeof(int) * 3 * (img->w + 2));

for(y = 0; y < img->height; y++)
for(y = 0; y < img->h; y++)
{
int er = 0, eg = 0, eb = 0;

memset(nexterror, 0, sizeof(int) * 3 * (img->width + 2));
memset(nexterror, 0, sizeof(int) * 3 * (img->w + 2));

for(x = 0; x < img->width; x++)
for(x = 0; x < img->w; x++)
{
int r, g, b, r2, g2, b2;
r = p32[y * img->width + x] & 0xff;
g = (p32[y * img->width + x] >> 8) & 0xff;
b = (p32[y * img->width + x] >> 16) & 0xff;
int r, g, b, a, r2, g2, b2;
r = p32[y * img->w + x] & 0xff;
g = (p32[y * img->w + x] >> 8) & 0xff;
b = (p32[y * img->w + x] >> 16) & 0xff;
a = (p32[y * img->w + x] >> 24) & 0xff;
r += er + error[x * 3 + 3];
g += eg + error[x * 3 + 4];
b += eb + error[x * 3 + 5];
@@ -61,7 +63,7 @@ void pipi_dither_24to16(pipi_image_t *img)
/* hack */
if(r2 == 0x88 && g2 == 0x88 && b2 == 0x88) g2 = 0x84;
/* hack */
p32[y * img->width + x] = (b2 << 16) | (g2 << 8) | r2;
p32[y * img->w + x] = (a << 24) | (b2 << 16) | (g2 << 8) | r2;

er = r - (r2 / 8 * 255 / 31);
eg = g - (g2 / 4 * 255 / 63);
@@ -80,11 +82,12 @@ void pipi_dither_24to16(pipi_image_t *img)
eb -= eb * 3 / 8 + eb * 7 / 8 + eb * 1 / 8;
}

memcpy(error, nexterror, sizeof(int) * 3 * (img->width + 2));
memcpy(error, nexterror, sizeof(int) * 3 * (img->w + 2));
}

pipi_release_pixels(img, p);

free(error);
free(nexterror);
#endif
}


Cargando…
Cancelar
Guardar