summaryrefslogtreecommitdiff
path: root/gui_app_window.c
diff options
context:
space:
mode:
Diffstat (limited to 'gui_app_window.c')
-rw-r--r--gui_app_window.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gui_app_window.c b/gui_app_window.c
index 56a42f6..7c2bedd 100644
--- a/gui_app_window.c
+++ b/gui_app_window.c
@@ -44,6 +44,8 @@ struct _GuiAppWindowPrivate {
GtkComboBoxText *resolution_combo_box;
GtkAdjustment *exposure_adj;
GtkAdjustment *gain_adj;
+ GtkCheckButton *wb_button;
+ GtkButton *wb_cal_button;
GtkCheckButton *rotate_button;
GtkButton *save_button;
GdkRectangle allocation;
@@ -51,6 +53,9 @@ struct _GuiAppWindowPrivate {
cairo_surface_t *surface;
struct image *image;
struct image *image_converted;
+ bool white_balance;
+ bool white_balance_calibrated;
+ struct image_white_balance_reference white_balance_reference;
bool rotate;
int width;
int height;
@@ -113,6 +118,14 @@ video_ready_cb(GuiApp *app, gpointer user_data)
image_unref(priv->image);
priv->image = NULL;
}
+ /* White balance. */
+ if (priv->white_balance && !priv->white_balance_calibrated) {
+ image_white_balance_calibrate(image,
+ &priv->white_balance_reference);
+ priv->white_balance_calibrated = true;
+ }
+ if (priv->white_balance)
+ image_white_balance(image, &priv->white_balance_reference);
/* Different format? Convert. */
if (image->format != IMAGE_FORMAT_XBGR32) {
if (priv->image_converted &&
@@ -278,6 +291,26 @@ gain_adj_value_changed_cb(GtkAdjustment *adj, gpointer user_data)
}
static void
+wb_button_toggled_cb(GtkToggleButton *button, gpointer user_data)
+{
+ GuiAppWindow *win =
+ GUI_APP_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button)));
+ GuiAppWindowPrivate *priv = gui_app_window_get_instance_private(win);
+ priv->white_balance = gtk_toggle_button_get_active(button);
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->wb_cal_button),
+ priv->white_balance);
+}
+
+static void
+wb_cal_button_clicked_cb(GtkButton *button, gpointer user_data)
+{
+ GuiAppWindow *win =
+ GUI_APP_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button)));
+ GuiAppWindowPrivate *priv = gui_app_window_get_instance_private(win);
+ priv->white_balance_calibrated = false;
+}
+
+static void
rotate_button_toggled_cb(GtkToggleButton *button, gpointer user_data)
{
GuiAppWindow *win =
@@ -362,6 +395,8 @@ gui_app_window_init(GuiAppWindow *win)
priv->surface = NULL;
priv->image = NULL;
priv->image_converted = NULL;
+ priv->white_balance = false;
+ priv->white_balance_calibrated = false;
priv->rotate = true;
priv->width = -1;
priv->height = -1;
@@ -386,6 +421,10 @@ gui_app_window_class_init(GuiAppWindowClass *class)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class),
GuiAppWindow, gain_adj);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class),
+ GuiAppWindow, wb_button);
+ gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class),
+ GuiAppWindow, wb_cal_button);
+ gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class),
GuiAppWindow, rotate_button);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class),
GuiAppWindow, save_button);
@@ -404,6 +443,10 @@ gui_app_window_class_init(GuiAppWindowClass *class)
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class),
gain_adj_value_changed_cb);
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class),
+ wb_button_toggled_cb);
+ gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class),
+ wb_cal_button_clicked_cb);
+ gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class),
rotate_button_toggled_cb);
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class),
save_button_clicked_cb);
@@ -431,6 +474,10 @@ gui_app_window_open(GuiAppWindow *win, struct device *device)
gtk_adjustment_set_lower(priv->gain_adj, info->gain_min);
gtk_adjustment_set_upper(priv->gain_adj, info->gain_max);
gtk_adjustment_set_value(priv->gain_adj, info->gain_default);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->wb_button),
+ priv->white_balance);
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->wb_cal_button),
+ priv->white_balance);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->rotate_button),
priv->rotate);
gtk_combo_box_text_remove_all(priv->resolution_combo_box);