Index: xsane/src/xsane-preview.c diff -u xsane/src/xsane-preview.c:1.1.1.1 xsane/src/xsane-preview.c:1.1.1.1.8.2 --- xsane/src/xsane-preview.c:1.1.1.1 Mon Apr 22 18:38:41 2002 +++ xsane/src/xsane-preview.c Wed Jul 3 18:33:40 2002 @@ -182,6 +182,8 @@ static void preview_preset_area_callback(GtkWidget *widget, gpointer call_data); static void preview_rotation_callback(GtkWidget *widget, gpointer call_data); static void preview_autoselect_scanarea_callback(GtkWidget *window, gpointer data); +static void update_color_labels(Preview *p, int x, int y); +static void preview_get_colors(Preview *p, int x, int y, int *red_raw, int *green_raw, int *blue_raw, int *red_enh, int *green_enh, int *blue_enh); void preview_do_gamma_correction(Preview *p); void preview_calculate_raw_histogram(Preview *p, SANE_Int *count_raw, SANE_Int *count_raw_red, SANE_Int *count_raw_green, SANE_Int *count_raw_blue); @@ -2440,6 +2442,8 @@ if (!p->scanning) { + update_color_labels(p, event->button.x, event->button.y); + switch (((GdkEventMotion *)event)->state & GDK_Num_Lock & GDK_Caps_Lock & GDK_Shift_Lock & GDK_Scroll_Lock) /* mask all Locks */ { @@ -3425,10 +3429,36 @@ return; } + +static void update_color_labels(Preview *p, int x, int y) { + int red_raw; + int green_raw; + int blue_raw; + int red_enh; + int green_enh; + int blue_enh; + char buf[64]; + + preview_get_colors(p, x, y, &red_raw, &green_raw, &blue_raw, &red_enh, &green_enh, &blue_enh); + + if ( red_raw >= 0 && red_raw < 256 && + green_raw >= 0 && green_raw < 256 && + blue_raw >= 0 && blue_raw < 256&& + red_enh >= 0 && red_enh < 256 && + green_enh >= 0 && green_enh < 256 && + blue_enh >= 0 && blue_enh < 256 ) { + snprintf(buf, 64, "raw r: %03d g: %03d b: %03d\nenh r: %03d g: %03d b: %03d", red_raw, green_raw, blue_raw, red_enh, green_enh, blue_enh); + } else { + snprintf(buf, 64, "raw r: --- g: --- b: ---\nenh r: --- g: --- b: ---"); + } + gtk_label_set_text(GTK_LABEL(p->rgb_values), buf); +} + /* ---------------------------------------------------------------------------------------------------------------------- */ Preview *preview_new(void) { + GtkStyle *style; GtkWidget *table, *frame; GtkSignalFunc signal_func; GtkWidgetClass *class; @@ -3711,17 +3741,26 @@ p->start = gtk_button_new_with_label(BUTTON_PREVIEW_ACQUIRE); xsane_back_gtk_set_tooltip(xsane.tooltips, p->start, DESC_PREVIEW_ACQUIRE); g_signal_connect(GTK_OBJECT(p->start), "clicked", (GtkSignalFunc) preview_start_button_clicked, p); - gtk_box_pack_start(GTK_BOX(hbox), p->start, TRUE, TRUE, 10); + gtk_box_pack_start(GTK_BOX(hbox), p->start, TRUE, TRUE, 5); gtk_widget_add_accelerator(p->start, "clicked", xsane.accelerator_group, GDK_P, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt P */ /* Cancel button */ p->cancel = gtk_button_new_with_label(BUTTON_PREVIEW_CANCEL); xsane_back_gtk_set_tooltip(xsane.tooltips, p->cancel, DESC_PREVIEW_CANCEL); g_signal_connect(GTK_OBJECT(p->cancel), "clicked", (GtkSignalFunc) preview_cancel_button_clicked, p); - gtk_box_pack_start(GTK_BOX(hbox), p->cancel, TRUE, TRUE, 10); + gtk_box_pack_start(GTK_BOX(hbox), p->cancel, TRUE, TRUE, 5); gtk_widget_add_accelerator(p->cancel, "clicked", xsane.accelerator_group, GDK_Escape, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt ESC */ gtk_widget_set_sensitive(p->cancel, FALSE); + /* red/green/blue values */ + p->rgb_values = gtk_label_new("raw r: --- g: --- b: ---\nenh r: --- g: --- b: ---"); + style = gtk_widget_get_style(p->rgb_values); + style = gtk_style_copy(style); + style->font = gdk_font_load("-misc-fixed-medium-r-normal-*-*-120-*-*-c-*-iso8859-1"); + gtk_widget_set_style(p->rgb_values, style); + gtk_box_pack_start(GTK_BOX(hbox), p->rgb_values, TRUE, TRUE, 0); + gtk_widget_show(p->rgb_values); + gtk_widget_show(p->cancel); gtk_widget_show(p->start); gtk_widget_show(p->viewport); @@ -4410,7 +4449,7 @@ { preview_transform_coordinate_window_to_image(p, x, y, &image_x, &image_y); - if ( (image_x < p->image_width) && (image_y < p->image_height) ) + if ( (image_x >= 0) && (image_x < p->image_width) && (image_y >=0) && (image_y < p->image_height) ) { image_x_min = image_x - range/2; image_y_min = image_y - range/2; @@ -4452,6 +4491,29 @@ *red /= count; *green /= count; *blue /= count; + } + } +} + +static void preview_get_colors(Preview *p, int x, int y, int *red_raw, int *green_raw, int *blue_raw, int *red_enh, int *green_enh, int *blue_enh) +{ + int image_x, image_y; + int offset; + + DBG(DBG_proc, "preview_get_colors\n"); + + if (p->image_data_raw) { + preview_transform_coordinate_window_to_image(p, x, y, &image_x, &image_y); + if ( (image_x >= 0) && (image_x < p->image_width) && (image_y >=0) && (image_y < p->image_height) ) { + offset = 3 * (image_y * p->image_width + image_x); + + *red_raw = (p->image_data_raw[offset ]) >> 8; + *green_raw = (p->image_data_raw[offset + 1]) >> 8; + *blue_raw = (p->image_data_raw[offset + 2]) >> 8; + + *red_enh = p->image_data_enh[offset ]; + *green_enh = p->image_data_enh[offset + 1]; + *blue_enh = p->image_data_enh[offset + 2]; } } } Index: xsane/src/xsane-preview.h diff -u xsane/src/xsane-preview.h:1.1.1.1 xsane/src/xsane-preview.h:1.1.1.1.8.1 --- xsane/src/xsane-preview.h:1.1.1.1 Mon Apr 22 18:38:41 2002 +++ xsane/src/xsane-preview.h Wed Jul 3 17:36:22 2002 @@ -156,6 +156,7 @@ GtkWidget *window; /* the preview window */ GtkWidget *start; /* the start button */ GtkWidget *cancel; /* the cancel button */ + GtkWidget *rgb_values; GtkWidget *button_box; /* hbox for the following buttons */ GtkWidget *pipette_white; /* pipette white button */