diff --git a/pipi/quantize/reduce.c b/pipi/quantize/reduce.c index cf257cf..0237b5b 100644 --- a/pipi/quantize/reduce.c +++ b/pipi/quantize/reduce.c @@ -88,16 +88,18 @@ static hull_t *compute_hull(int ncolors, double const *palette) hull_t *ret = malloc(sizeof(hull_t)); int i, j, n; - debug("\n### NEW HULL ###\n\n"); + debug(""); + debug("### NEW HULL ###"); + debug(""); - debug("Analysing %i colors\n", ncolors); + debug("Analysing %i colors", ncolors); for(i = 0; i < ncolors; i++) { pal[i][R] = palette[i * 3]; pal[i][G] = palette[i * 3 + 1]; pal[i][B] = palette[i * 3 + 2]; - debug(" [%i] (%g,%g,%g)\n", i, pal[i][R], pal[i][G], pal[i][B]); + debug(" [%i] (%g,%g,%g)", i, pal[i][R], pal[i][G], pal[i][B]); } /* @@ -122,7 +124,7 @@ static hull_t *compute_hull(int ncolors, double const *palette) gray[G] = light[G] - dark[G]; gray[B] = light[B] - dark[B]; - debug(" gray axis (%g,%g,%g) - (%g,%g,%g)\n", + debug(" gray axis (%g,%g,%g) - (%g,%g,%g)", dark[R], dark[G], dark[B], light[R], light[G], light[B]); /* @@ -140,13 +142,13 @@ static hull_t *compute_hull(int ncolors, double const *palette) double t = n * 1.0 / STEPS; int npts = 0, left; - debug("Slice %i/%i\n", n, STEPS); + debug("Slice %i/%i", n, STEPS); p0[R] = dark[R] + t * gray[R]; p0[G] = dark[G] + t * gray[G]; p0[B] = dark[B] + t * gray[B]; - debug(" 3D gray (%g,%g,%g)\n", p0[R], p0[G], p0[B]); + debug(" 3D gray (%g,%g,%g)", p0[R], p0[G], p0[B]); /* * 3.1. Find all edges that intersect the t.y + (u,v) plane @@ -273,7 +275,7 @@ static hull_t *compute_hull(int ncolors, double const *palette) /* FIXME: check the last point */ for(i = 0; i < npts; i++) - debug(" 2D pt[%i] (%g,%g)\n", i, pts[i][X], pts[i][Y]); + debug(" 2D pt[%i] (%g,%g)", i, pts[i][X], pts[i][Y]); /* Compute the barycentre coordinates */ ctx = 0.; @@ -316,7 +318,7 @@ static hull_t *compute_hull(int ncolors, double const *palette) cty = 0.5 * (pts[0][Y] + pts[right][Y]); } - debug(" 2D bary (%g,%g)\n", ctx, cty); + debug(" 2D bary (%g,%g)", ctx, cty); /* * 3.3. Store the barycentre and convex hull information. @@ -335,12 +337,12 @@ static hull_t *compute_hull(int ncolors, double const *palette) ret->pts[n][i][Y] = pts[i][Y] - cty; ret->pts[n][i][A] = atan2(pts[i][Y] - cty, pts[i][X] - ctx); - debug(" 3D pt[%i] (%g,%g,%g) angle %g\n", + debug(" 3D pt[%i] (%g,%g,%g) angle %g", i, pts[i][R], pts[i][G], pts[i][B], ret->pts[n][i][A]); } ret->hullsize[n] = npts; - debug(" 3D bary (%g,%g,%g)\n", + debug(" 3D bary (%g,%g,%g)", ret->bary[n][R], ret->bary[n][G], ret->bary[n][B]); } @@ -372,7 +374,9 @@ pipi_image_t *pipi_reduce(pipi_image_t *src, * 4. Load image and change its palette. */ - debug("\n### PROCESSING IMAGE ###\n\n"); + debug(""); + debug("### PROCESSING IMAGE ###"); + debug(""); srcp = pipi_getpixels(src, PIPI_PIXELS_RGBA_F); srcdata = (float *)srcp->pixels; @@ -396,11 +400,11 @@ pipi_image_t *pipi_reduce(pipi_image_t *src, p[G] = srcdata[4 * (j * w + i) + 1]; p[R] = srcdata[4 * (j * w + i) + 2]; - debug("Pixel +%i+%i (%g,%g,%g)\n", i, j, p[R], p[G], p[B]); + debug("Pixel +%i+%i (%g,%g,%g)", i, j, p[R], p[G], p[B]); slice = (int)(BRIGHT(p) * STEPS + 0.5); - debug(" slice %i\n", slice); + debug(" slice %i", slice); /* Convert to 2D. The origin is the slice's barycentre. */ xp = (p[R] - rgbhull->bary[slice][R]) * u[R] @@ -410,7 +414,7 @@ pipi_image_t *pipi_reduce(pipi_image_t *src, + (p[G] - rgbhull->bary[slice][G]) * v[G] + (p[B] - rgbhull->bary[slice][B]) * v[B]; - debug(" 2D pt (%g,%g)\n", xp, yp); + debug(" 2D pt (%g,%g)", xp, yp); /* 1. find the excentricity in RGB space. There is an easier * way to do this, which is to find the intersection of our @@ -446,7 +450,7 @@ pipi_image_t *pipi_reduce(pipi_image_t *src, if(t > 1.0) t = 1.0; - debug(" best RGB %g (%g,%g) (%g,%g)\n", t, xa, ya, xb, yb); + debug(" best RGB %g (%g,%g) (%g,%g)", t, xa, ya, xb, yb); /* 2. apply the excentricity in reduced space. */ @@ -474,7 +478,7 @@ pipi_image_t *pipi_reduce(pipi_image_t *src, yb = myhull->pts[slice][(n + 1) % count][Y]; s = (xp * (yb - ya) - yp * (xb - xa)) / (xa * yb - xb * ya); - debug(" best custom %g (%g,%g) (%g,%g)\n", s, xa, ya, xb, yb); + debug(" best custom %g (%g,%g) (%g,%g)", s, xa, ya, xb, yb); if(s > 0) {