[Pixman] [PATCH] demo/scale: Add a spin button to set the number of subsample bits
Søren Sandmann
sandmann at cs.au.dk
Fri Jan 25 21:37:11 PST 2013
From: Søren Sandmann Pedersen <ssp at redhat.com>
For large upscalings the level of subsampling for the filter has a
quite visible effect, so make it settable in the UI so that people can
experiment with various values.
---
demos/scale.c | 16 +++++++++++++++-
demos/scale.ui | 30 ++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/demos/scale.c b/demos/scale.c
index 9100ff7..676919b 100644
--- a/demos/scale.c
+++ b/demos/scale.c
@@ -39,6 +39,7 @@ typedef struct
GtkAdjustment * scale_x_adjustment;
GtkAdjustment * scale_y_adjustment;
GtkAdjustment * rotate_adjustment;
+ GtkAdjustment * subsample_adjustment;
int scaled_width;
int scaled_height;
} app_t;
@@ -182,6 +183,16 @@ to_scale (double v)
return pow (1.15, v);
}
+static int
+get_subsample (app_t *app)
+{
+ GtkAdjustment *adjustment =
+ GTK_ADJUSTMENT (gtk_builder_get_object (
+ app->builder, "subsample_adjustment"));
+
+ return gtk_adjustment_get_value (adjustment);
+}
+
static void
rescale (GtkWidget *may_be_null, app_t *app)
{
@@ -236,7 +247,7 @@ rescale (GtkWidget *may_be_null, app_t *app)
get_value (app, filters, "reconstruct_y_combo_box"),
get_value (app, filters, "sample_x_combo_box"),
get_value (app, filters, "sample_y_combo_box"),
- 4, 4);
+ get_subsample (app), get_subsample (app));
pixman_image_set_filter (app->original, PIXMAN_FILTER_SEPARABLE_CONVOLUTION, params, n_params);
@@ -360,10 +371,13 @@ app_new (pixman_image_t *original)
GTK_ADJUSTMENT (gtk_builder_get_object (app->builder, "scale_y_adjustment"));
app->rotate_adjustment =
GTK_ADJUSTMENT (gtk_builder_get_object (app->builder, "rotate_adjustment"));
+ app->subsample_adjustment =
+ GTK_ADJUSTMENT (gtk_builder_get_object (app->builder, "subsample_adjustment"));
g_signal_connect (app->scale_x_adjustment, "value_changed", G_CALLBACK (rescale), app);
g_signal_connect (app->scale_y_adjustment, "value_changed", G_CALLBACK (rescale), app);
g_signal_connect (app->rotate_adjustment, "value_changed", G_CALLBACK (rescale), app);
+ g_signal_connect (app->subsample_adjustment, "value_changed", G_CALLBACK (rescale), app);
widget = get_widget (app, "scale_x_scale");
gtk_scale_add_mark (GTK_SCALE (widget), 0.0, GTK_POS_LEFT, NULL);
diff --git a/demos/scale.ui b/demos/scale.ui
index f7c0c80..b3450d3 100644
--- a/demos/scale.ui
+++ b/demos/scale.ui
@@ -23,6 +23,14 @@
<property name="page_increment">10</property>
<property name="page_size">10</property>
</object>
+ <object class="GtkAdjustment" id="subsample_adjustment">
+ <property name="lower">1</property>
+ <property name="upper">12</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">1</property>
+ <property name="page_size">0</property>
+ <property name="value">4</property>
+ </object>
<object class="GtkWindow" id="main">
<child>
<object class="GtkHBox" id="u">
@@ -51,6 +59,7 @@
<child>
<object class="GtkVBox" id="box1">
<property name="visible">True</property>
+ <property name="spacing">12</property>
<child>
<object class="GtkHBox" id="box2">
<property name="visible">True</property>
@@ -234,6 +243,17 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>Subsample:</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkComboBox" id="reconstruct_x_combo_box">
<property name="visible">True</property>
</object>
@@ -277,6 +297,16 @@
<property name="top_attach">4</property>
</packing>
</child>
+ <child>
+ <object class="GtkSpinButton" id="subsample_spin_button">
+ <property name="visible">True</property>
+ <property name="adjustment">subsample_adjustment</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
--
1.7.11.7
More information about the Pixman
mailing list