From 8c39330635f5eae9a9629574913316fa2c3d7dd2 Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 27 May 2009 05:04:35 +0000 Subject: [PATCH] Minor cleanup in img2twit. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3530 92316355-f0b4-4df1-b90c-862c8a59935f --- examples/img2twit.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/img2twit.cpp b/examples/img2twit.cpp index f27370d..4fc38ba 100644 --- a/examples/img2twit.cpp +++ b/examples/img2twit.cpp @@ -494,13 +494,6 @@ static inline void get_point(int index, float *x, float *y, float *r, } } -static inline float clip(float x, int modulo) -{ - float mul = (float)modulo + 0.9999; - int round = (int)(x * mul); - return (float)round / (float)modulo; -} - static void add_point(float x, float y, float r, float g, float b, float s) { set_point(npoints, x, y, r, g, b, s); @@ -663,8 +656,10 @@ static void render(pipi_image_t *dst, { for(x = rx; x < rx + rw; x++) { - K::Point_2 m((float)x * dw * RANGE_X / p->w + dw * RANGE_X, - (float)y * dh * RANGE_Y / p->h + dh * RANGE_Y); + float myx = (float)x * dw * RANGE_X / p->w; + float myy = (float)y * dh * RANGE_Y / p->h; + + K::Point_2 m(myx + dw * RANGE_X, myy + dh * RANGE_Y); Point_coordinate_vector coords; CGAL::Triple< std::back_insert_iterator, @@ -696,6 +691,14 @@ static void render(pipi_image_t *dst, //float k = (*it).second * (0.60f + fs); //float k = pow((*it).second, (1.0f + fs)); + // Try to attenuate peak artifacts + //k /= (0.1 * (RANGE_X * RANGE_X + RANGE_Y * RANGE_Y) + // + (myx - fx) * (myx - fx) + (myy - fy) * (myy - fy)); + + // Cute circles + //k = 1.0 / (0.015 * (RANGE_X * RANGE_X + RANGE_Y * RANGE_Y) + // + (myx - fx) * (myx - fx) + (myy - fy) * (myy - fy)); + r += k * fr; g += k * fg; b += k * fb;