Hello everyone,

I've written a small patch making it possible to split the output screen
while color correcting with the histogram, enabling the user to do some
before-after comparsion.

Could you please review it and tell me what you think?

Thanks,
 Jonas


diff -uarbBN hvirtual_clean/plugins/histogram/histogram.C hvirtual/plugins/histogram/histogram.C
--- hvirtual_clean/plugins/histogram/histogram.C	2006-01-23 22:50:26.000000000 +0100
+++ hvirtual/plugins/histogram/histogram.C	2006-01-23 20:48:59.000000000 +0100
@@ -171,7 +171,9 @@
 	mode = defaults->get("MODE", mode);
 	CLAMP(mode, 0, HISTOGRAM_MODES - 1);
 	config.threshold = defaults->get("THRESHOLD", config.threshold);
+	config.split = defaults->get("SPLIT", config.split);
 	config.boundaries();
+	
 	return 0;
 }
 
@@ -212,6 +214,7 @@
 	defaults->update("AUTOMATIC", config.automatic);
 	defaults->update("MODE", mode);
 	defaults->update("THRESHOLD", config.threshold);
+	defaults->update("SPLIT", config.split);
 	defaults->save();
 	return 0;
 }
@@ -240,6 +243,7 @@
 
 	output.tag.set_property("AUTOMATIC", config.automatic);
 	output.tag.set_property("THRESHOLD", config.threshold);
+	output.tag.set_property("SPLIT", config.split);
 	output.append_tag();
 	output.append_newline();
 
@@ -308,6 +312,8 @@
 				}
 				config.automatic = input.tag.get_property("AUTOMATIC", config.automatic);
 				config.threshold = input.tag.get_property("THRESHOLD", config.threshold);
+				config.split = input.tag.get_property("SPLIT", config.split);
+
 			}
 			else
 			if(input.tag.title_is("POINTS"))
@@ -839,8 +844,13 @@
 	for(int i = pkg->start; i < pkg->end; i++) \
 	{ \
 		type *row = (type*)input->get_rows()[i]; \
-		for(int j = 0; j < w; j++) \
+		for (int j = 0; j < w; j++) \
+		{ \
+			if (plugin->config.split) \
 		{ \
+			  if ((j + i * w / h) < w) \
+			    continue; \
+			} \
 			row[0] = lookup_r[row[0]]; \
 			row[1] = lookup_g[row[1]]; \
 			row[2] = lookup_b[row[2]]; \
@@ -856,6 +866,11 @@
 		type *row = (type*)input->get_rows()[i]; \
 		for(int j = 0; j < w; j++) \
 		{ \
+			if (plugin->config.split) \
+			{ \
+			  if ((j + i * w / h) < w) \
+			    continue; \
+			} \
 /* Convert to 16 bit RGB */ \
 			if(max == 0xff) \
 			{ \
@@ -904,6 +920,11 @@
 		float *row = (float*)input->get_rows()[i]; \
 		for(int j = 0; j < w; j++) \
 		{ \
+			if (plugin->config.split) \
+			{ \
+			  if ((j + i * w / h) < w) \
+			    continue; \
+			} \
 			float r = row[0]; \
 			float g = row[1]; \
 			float b = row[2]; \
diff -uarbBN hvirtual_clean/plugins/histogram/histogramconfig.C hvirtual/plugins/histogram/histogramconfig.C
--- hvirtual_clean/plugins/histogram/histogramconfig.C	2006-01-23 22:50:26.000000000 +0100
+++ hvirtual/plugins/histogram/histogramconfig.C	2006-01-23 20:37:48.000000000 +0100
@@ -163,6 +163,7 @@
 	{
 		automatic = 0;
 		threshold = 0.1;
+		split = 0;
 	}
 }
 
@@ -214,6 +215,7 @@
 
 	automatic = that.automatic;
 	threshold = that.threshold;
+	split = that.split;
 }
 
 void HistogramConfig::interpolate(HistogramConfig &prev, 
@@ -234,6 +236,7 @@
 
 	threshold = prev.threshold * prev_scale + next.threshold * next_scale;
 	automatic = prev.automatic;
+	split = prev.split;
 }
 
 
diff -uarbBN hvirtual_clean/plugins/histogram/histogramconfig.h hvirtual/plugins/histogram/histogramconfig.h
--- hvirtual_clean/plugins/histogram/histogramconfig.h	2006-01-23 22:50:26.000000000 +0100
+++ hvirtual/plugins/histogram/histogramconfig.h	2006-01-23 20:36:08.000000000 +0100
@@ -61,6 +61,7 @@
 	float output_max[HISTOGRAM_MODES];
 	int automatic;
 	float threshold;
+	int split;
 };
 
 
diff -uarbBN hvirtual_clean/plugins/histogram/histogramwindow.C hvirtual/plugins/histogram/histogramwindow.C
--- hvirtual_clean/plugins/histogram/histogramwindow.C	2006-01-23 22:50:26.000000000 +0100
+++ hvirtual/plugins/histogram/histogramwindow.C	2006-01-23 20:35:37.000000000 +0100
@@ -181,6 +181,13 @@
 		&plugin->config.threshold);
 	threshold->create_objects();
 
+	x = x1;
+	y += 40;
+	
+	add_subwindow(split = new HistogramSplit(plugin, x, y));
+
+	x += 100;
+
 
 	show_window();
 
@@ -684,6 +688,20 @@
 }
 
 
+HistogramSplit::HistogramSplit(HistogramMain *plugin, 
+	int x, 
+	int y)
+ : BC_CheckBox(x, y, plugin->config.split, _("Split picture"))
+{
+	this->plugin = plugin;
+}
+
+int HistogramSplit::handle_event()
+{
+	plugin->config.split = get_value();
+	plugin->send_configure_change();
+	return 1;
+}
 
 
 HistogramMode::HistogramMode(HistogramMain *plugin, 
diff -uarbBN hvirtual_clean/plugins/histogram/histogramwindow.h hvirtual/plugins/histogram/histogramwindow.h
--- hvirtual_clean/plugins/histogram/histogramwindow.h	2006-01-23 22:50:26.000000000 +0100
+++ hvirtual/plugins/histogram/histogramwindow.h	2006-01-23 20:33:15.000000000 +0100
@@ -49,6 +49,17 @@
 	HistogramMain *plugin;
 };
 
+class HistogramSplit : public BC_CheckBox
+{
+public:
+	HistogramSplit(HistogramMain *plugin, 
+		int x, 
+		int y);
+	int handle_event();
+	HistogramMain *plugin;
+};
+
+
 class HistogramMode : public BC_Radial
 {
 public:
@@ -136,6 +147,7 @@
 
 	HistogramSlider *output;
 	HistogramAuto *automatic;
+	HistogramSplit *split;
 	HistogramMode *mode_v, *mode_r, *mode_g, *mode_b /*,  *mode_a */;
 	HistogramOutputText *output_min;
 	HistogramOutputText *output_max;

Reply via email to