From 375f5ec5c5d2a6cc3586f57e36fdf08a3d0ac4e4 Mon Sep 17 00:00:00 2001 From: Bill Spitzak Date: Tue, 30 Aug 2016 22:03:07 -0700 Subject: demos/scale: Added pulldown to choose PIXMAN_FILTER_* value This is very useful for comparing the results of SEPARABLE_CONVOLUTION with BILINEAR and NEAREST. v14: Removed good/best items v15: Skip filter generation so gnuplot output continues showing previous value Signed-off-by: Bill Spitzak Reviewed-by: Oded Gabbay --- demos/scale.c | 41 ++++++++++++++++++++++++++++++----------- demos/scale.ui | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 60 insertions(+), 21 deletions(-) diff --git a/demos/scale.c b/demos/scale.c index 0995ad0..0c6b533 100644 --- a/demos/scale.c +++ b/demos/scale.c @@ -127,6 +127,13 @@ typedef struct int value; } named_int_t; +static const named_int_t filter_types[] = +{ + { "Separable", PIXMAN_FILTER_SEPARABLE_CONVOLUTION }, + { "Nearest", PIXMAN_FILTER_NEAREST }, + { "Bilinear", PIXMAN_FILTER_BILINEAR }, +}; + static const named_int_t filters[] = { { "Box", PIXMAN_KERNEL_BOX }, @@ -249,18 +256,29 @@ rescale (GtkWidget *may_be_null, app_t *app) pixman_transform_from_pixman_f_transform (&transform, &ftransform); pixman_image_set_transform (app->original, &transform); - params = pixman_filter_create_separable_convolution ( - &n_params, - sx * 65536.0 + 0.5, - sy * 65536.0 + 0.5, - get_value (app, filters, "reconstruct_x_combo_box"), - get_value (app, filters, "reconstruct_y_combo_box"), - get_value (app, filters, "sample_x_combo_box"), - get_value (app, filters, "sample_y_combo_box"), - gtk_adjustment_get_value (app->subsample_adjustment), - gtk_adjustment_get_value (app->subsample_adjustment)); + if (get_value (app, filter_types, "filter_combo_box") == + PIXMAN_FILTER_SEPARABLE_CONVOLUTION) + { + params = pixman_filter_create_separable_convolution ( + &n_params, + sx * 65536.0 + 0.5, + sy * 65536.0 + 0.5, + get_value (app, filters, "reconstruct_x_combo_box"), + get_value (app, filters, "reconstruct_y_combo_box"), + get_value (app, filters, "sample_x_combo_box"), + get_value (app, filters, "sample_y_combo_box"), + gtk_adjustment_get_value (app->subsample_adjustment), + gtk_adjustment_get_value (app->subsample_adjustment)); + } + else + { + params = 0; + n_params = 0; + } - pixman_image_set_filter (app->original, PIXMAN_FILTER_SEPARABLE_CONVOLUTION, params, n_params); + pixman_image_set_filter (app->original, + get_value (app, filter_types, "filter_combo_box"), + params, n_params); pixman_image_set_repeat ( app->original, get_value (app, repeats, "repeat_combo_box")); @@ -402,6 +420,7 @@ app_new (pixman_image_t *original) widget = get_widget (app, "drawing_area"); g_signal_connect (widget, "expose_event", G_CALLBACK (on_expose), app); + set_up_combo_box (app, "filter_combo_box", G_N_ELEMENTS (filter_types), filter_types); set_up_filter_box (app, "reconstruct_x_combo_box"); set_up_filter_box (app, "reconstruct_y_combo_box"); set_up_filter_box (app, "sample_x_combo_box"); diff --git a/demos/scale.ui b/demos/scale.ui index d498d26..7e999c1 100644 --- a/demos/scale.ui +++ b/demos/scale.ui @@ -191,6 +191,14 @@ True 8 6 + + + True + 1 + <b>Filter:</b> + True + + True @@ -198,6 +206,9 @@ <b>Reconstruct X:</b> True + + 1 + @@ -207,7 +218,7 @@ True - 1 + 2 @@ -218,7 +229,7 @@ True - 2 + 3 @@ -229,7 +240,7 @@ True - 3 + 4 @@ -240,7 +251,7 @@ True - 4 + 5 @@ -251,7 +262,15 @@ True - 5 + 6 + + + + + True + + + 1 @@ -260,6 +279,7 @@ 1 + 1 @@ -268,7 +288,7 @@ 1 - 1 + 2 @@ -277,7 +297,7 @@ 1 - 2 + 3 @@ -286,7 +306,7 @@ 1 - 3 + 4 @@ -295,7 +315,7 @@ 1 - 4 + 5 @@ -306,7 +326,7 @@ 1 - 5 + 6 -- cgit v1.2.3