diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/control.c | 21 | ||||
-rw-r--r-- | test/control.glade | 113 |
2 files changed, 106 insertions, 28 deletions
diff --git a/test/control.c b/test/control.c index 5ff54c6..0db1079 100644 --- a/test/control.c +++ b/test/control.c @@ -16,6 +16,7 @@ typedef struct { int pixel_size; struct uca_camera *cam; struct uca *u; + float scale; } ThreadData; @@ -43,11 +44,11 @@ void convert_8bit_to_rgb(guchar *output, guchar *input, int width, int height) } } -void convert_16bit_to_rgb(guchar *output, guchar *input, int width, int height) +void convert_16bit_to_rgb(guchar *output, guchar *input, int width, int height, float scale) { uint16_t *in = (uint16_t *) input; for (int i = 0, j = 0; i < width*height; i++) { - guchar val = (uint8_t) ((in[i]/65536.0f)*256.0f); + guchar val = (uint8_t) ((in[i]/scale)*256.0f); output[j++] = val; output[j++] = val; output[j++] = val; @@ -83,7 +84,7 @@ void *grab_thread(void *args) if (data->pixel_size == 1) convert_8bit_to_rgb(data->pixels, data->buffer, data->width, data->height); else if (data->pixel_size == 2) - convert_16bit_to_rgb(data->pixels, data->buffer, data->width, data->height); + convert_16bit_to_rgb(data->pixels, data->buffer, data->width, data->height, data->scale); gdk_threads_enter(); gdk_flush(); @@ -108,6 +109,12 @@ void on_destroy(GtkWidget *widget, gpointer data) gtk_main_quit(); } +void on_adjustment_scale_value_changed(GtkAdjustment* adjustment, gpointer user_data) +{ + ThreadData *data = (ThreadData *) user_data; + data->scale = gtk_adjustment_get_value(adjustment); +} + void on_toolbutton_run_clicked(GtkWidget *widget, gpointer args) { ThreadData *data = (ThreadData *) args; @@ -350,15 +357,23 @@ int main(int argc, char *argv[]) td.u = u; td.running = FALSE; td.pixel_size = pixel_size; + td.scale = 65535.0f; gtk_builder_connect_signals(builder, &td); + /* Configure value cell */ ValueCellData value_cell_data; value_cell_data.thread_data = &td; value_cell_data.tree_store = tree_store; g_signal_connect(gtk_builder_get_object(builder, "valuecell"), "edited", G_CALLBACK(on_valuecell_edited), &value_cell_data); + + /* Configure scale adjustment */ + GtkAdjustment *adjustment = (GtkAdjustment *) gtk_builder_get_object(builder, "adjustment_scale"); + gtk_adjustment_configure(adjustment, 65535.0, 1.0, 65535.0, 0.5, 10.0, 0.0); + g_signal_connect(adjustment, "value-changed", + G_CALLBACK(on_adjustment_scale_value_changed), &td); gtk_widget_show(image); gtk_widget_show(window); diff --git a/test/control.glade b/test/control.glade index e20f9ff..a370c72 100644 --- a/test/control.glade +++ b/test/control.glade @@ -186,46 +186,102 @@ </packing> </child> <child> - <object class="GtkTreeView" id="treeview"> + <object class="GtkVBox" id="vbox2"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="model">cameraproperties</property> <child> - <object class="GtkTreeViewColumn" id="namecolumn"> - <property name="title">Name</property> + <object class="GtkScrolledWindow" id="scrolledwindow2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> - <object class="GtkCellRendererText" id="namecell"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> + <object class="GtkTreeView" id="treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">cameraproperties</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <child> + <object class="GtkTreeViewColumn" id="namecolumn"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="namecell"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="valuecolumn"> + <property name="title">Value</property> + <child> + <object class="GtkCellRendererText" id="valuecell"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="unitcolumn"> + <property name="title">Unit</property> + <child> + <object class="GtkCellRendererText" id="unitcell"/> + <attributes> + <attribute name="text">2</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> - <object class="GtkTreeViewColumn" id="valuecolumn"> - <property name="title">Value</property> + <object class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_columns">2</property> + <property name="column_spacing">6</property> <child> - <object class="GtkCellRendererText" id="valuecell"/> - <attributes> - <attribute name="text">1</attribute> - </attributes> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">16-Bit Scale <i>1/x</i>:</property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="x_options"></property> + </packing> </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn" id="unitcolumn"> - <property name="title">Unit</property> <child> - <object class="GtkCellRendererText" id="unitcell"/> - <attributes> - <attribute name="text">2</attribute> - </attributes> + <object class="GtkSpinButton" id="spinbutton1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="adjustment">adjustment_scale</property> + <property name="climb_rate">0.02</property> + <property name="digits">2</property> + <property name="numeric">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="padding">6</property> + <property name="position">1</property> + </packing> </child> </object> <packing> - <property name="resize">False</property> + <property name="resize">True</property> <property name="shrink">True</property> </packing> </child> @@ -247,4 +303,11 @@ </object> </child> </object> + <object class="GtkAdjustment" id="adjustment_scale"> + <property name="value">65534.999999999774</property> + <property name="lower">1</property> + <property name="upper">65535</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> </interface> |