demos/scale: Added pulldown to choose PIXMAN_FILTER_* value
authorBill Spitzak <spitzak@gmail.com>
Wed, 31 Aug 2016 05:03:07 +0000 (22:03 -0700)
committerSøren Sandmann Pedersen <soren.sandmann@gmail.com>
Fri, 2 Sep 2016 04:40:11 +0000 (00:40 -0400)
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 <spitzak@gmail.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
demos/scale.c
demos/scale.ui

index 0995ad08da9d8b19d09ac953c9f395943693ce3f..0c6b533fadfca7fdecb95bfd5601d18ef7a867ac 100644 (file)
@@ -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");
index d498d26e8c9b3d2f2329ccb2201d84b0ea9ff4fe..7e999c1ff86d76665e4b4d2cc0bf63b30ccbedab 100644 (file)
                     <property name="visible">True</property>
                     <property name="column_spacing">8</property>
                     <property name="row_spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="labelF">
+                        <property name="visible">True</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Filter:&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
                     <child>
                       <object class="GtkLabel" id="label4">
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">&lt;b&gt;Reconstruct X:&lt;/b&gt;</property>
                         <property name="use_markup">True</property>
                       </object>
+                      <packing>
+                        <property name="top_attach">1</property>
+                      </packing>
                     </child>
                     <child>
                       <object class="GtkLabel" id="label5">
                         <property name="use_markup">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">1</property>
+                        <property name="top_attach">2</property>
                       </packing>
                     </child>
                     <child>
                         <property name="use_markup">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">2</property>
+                        <property name="top_attach">3</property>
                       </packing>
                     </child>
                     <child>
                         <property name="use_markup">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">3</property>
+                        <property name="top_attach">4</property>
                       </packing>
                     </child>
                     <child>
                         <property name="use_markup">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">4</property>
+                        <property name="top_attach">5</property>
                       </packing>
                     </child>
                     <child>
                         <property name="use_markup">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">5</property>
+                        <property name="top_attach">6</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="filter_combo_box">
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
                       </packing>
                     </child>
                     <child>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                     <child>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">1</property>
+                        <property name="top_attach">2</property>
                       </packing>
                     </child>
                     <child>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">2</property>
+                        <property name="top_attach">3</property>
                       </packing>
                     </child>
                     <child>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">3</property>
+                        <property name="top_attach">4</property>
                       </packing>
                     </child>
                     <child>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">4</property>
+                        <property name="top_attach">5</property>
                       </packing>
                     </child>
                     <child>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">5</property>
+                        <property name="top_attach">6</property>
                       </packing>
                     </child>
                   </object>