forked from AuroraMiddleware/gtk
New function to make sure that the weights sum up to the correct total
* pixops/pixops.c (correct_total): New function to make sure that the weights sum up to the correct total without introducing negative weights. (tile_make_weights, bilinear_make_fast_weights, bilinear_make_weights): Use correct_total.
This commit is contained in:
parent
dbe4dbe8e9
commit
bc90028d8d
@ -1,3 +1,11 @@
|
|||||||
|
2002-02-15 Matthias Clasen <matthias@YAST_ASK>
|
||||||
|
|
||||||
|
* pixops/pixops.c (correct_total): New function to make sure
|
||||||
|
that the weights sum up to the correct total without introducing
|
||||||
|
negative weights.
|
||||||
|
(tile_make_weights, bilinear_make_fast_weights,
|
||||||
|
bilinear_make_weights): Use correct_total.
|
||||||
|
|
||||||
2002-02-10 Matthias Clasen <matthias@local>
|
2002-02-10 Matthias Clasen <matthias@local>
|
||||||
|
|
||||||
* test-images.h (tiff1_test_3), test-loaders.c (main): Add a
|
* test-images.h (tiff1_test_3), test-loaders.c (main): Add a
|
||||||
|
@ -1077,6 +1077,25 @@ pixops_process (guchar *dest_buf,
|
|||||||
g_free (line_bufs);
|
g_free (line_bufs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
correct_total (int *weights,
|
||||||
|
int n_x,
|
||||||
|
int n_y,
|
||||||
|
int total,
|
||||||
|
double overall_alpha)
|
||||||
|
{
|
||||||
|
int correction = (int)(0.5 + 65536 * overall_alpha) - total;
|
||||||
|
int i;
|
||||||
|
for (i = n_x * n_y - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (*(weights + i) + correction >= 0)
|
||||||
|
{
|
||||||
|
*(weights + i) += correction;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double overall_alpha)
|
tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double overall_alpha)
|
||||||
{
|
{
|
||||||
@ -1144,7 +1163,7 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double
|
|||||||
*(pixel_weights + n_x * i + j) = weight;
|
*(pixel_weights + n_x * i + j) = weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(pixel_weights + n_x * n_y - 1) += (int)(0.5 + 65536 * overall_alpha) - total;
|
correct_total (pixel_weights, n_x, n_y, total, overall_alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1266,7 +1285,7 @@ bilinear_make_fast_weights (PixopsFilter *filter, double x_scale, double y_scale
|
|||||||
total += weight;
|
total += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(pixel_weights + n_x * n_y - 1) += (int)(0.5 + 65536 * overall_alpha) - total;
|
correct_total (pixel_weights, n_x, n_y, total, overall_alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (x_weights);
|
g_free (x_weights);
|
||||||
@ -1368,7 +1387,7 @@ bilinear_make_weights (PixopsFilter *filter, double x_scale, double y_scale, dou
|
|||||||
total += weight;
|
total += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(pixel_weights + n_x * n_y - 1) += (int)(0.5 + 65536 * overall_alpha) - total;
|
correct_total (pixel_weights, n_x, n_y, total, overall_alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user