On Tue, Jul 14, 2009 at 07:34:20PM +0100, Martin Ling wrote:
> [...]
>
> Attached is a very quick patch against current CVS which adds a rotation
> control to the transformations page of the GUI. This is not intended for
> a commit yet, but it might be a useful start for anyone who'd like to
> start tackling the issues of how arbitrary rotations interact with the
> existing transformation controls.
I've corrected the interaction with the image flipping. Also, the angle
can now take arbitrary values including negative ones:
diff --git a/ufraw.h b/ufraw.h
index 0417abd..6d4c225 100644
--- a/ufraw.h
+++ b/ufraw.h
@@ -320,6 +320,7 @@ void ufraw_auto_curve(ufraw_data *uf);
void ufraw_rotate_row(image_data *image, void *pixbuf, double angle,
int bitDepth, int row, int offset, int width);
void ufraw_rotate_image_buffer(ufraw_image_data *img, double angle);
+void ufraw_normalize_rotation(ufraw_data *uf);
void ufraw_img_get_subarea_coord (ufraw_image_data *img, unsigned saidx,
int *x, int *y, int *w, int *h);
diff --git a/ufraw_preview.c b/ufraw_preview.c
index 2a89ac9..f82c08e 100644
--- a/ufraw_preview.c
+++ b/ufraw_preview.c
@@ -2022,6 +2022,19 @@ static void flip_image(GtkWidget *widget, int flip)
data->SpotY2 = temp;
}
}
+ switch (flip) {
+ case 6:
+ gtk_adjustment_set_value(data->RotationAdjustment,
data->unnormalized_angle + 90);
+ break;
+ case 5:
+ gtk_adjustment_set_value(data->RotationAdjustment,
data->unnormalized_angle - 90);
+ break;
+ case 1:
+ case 2:
+ data->reference_orientation ^= flip;
+ gtk_adjustment_set_value(data->RotationAdjustment,
-data->unnormalized_angle);
+ break;
+ }
render_init(data);
if ( data->RenderSubArea >= 0 ) {
/* We are in the middle or a rendering scan,
@@ -2702,6 +2715,13 @@ static void adjustment_update(GtkAdjustment *adj, double
*valuep)
CFG->Scale = 0;
create_base_image(data);
}
+ else if (valuep==&data->unnormalized_angle)
+ {
+ CFG->rotationAngle = data->unnormalized_angle;
+ CFG->orientation = data->reference_orientation;
+ ufraw_normalize_rotation(data->UF);
+ create_base_image(data);
+ }
else if (valuep==&CFG->threshold)
preview_invalidate_layer (data, ufraw_denoise_phase);
else
@@ -4613,6 +4633,26 @@ static void transformations_fill_interface(preview_data
*data,
gtk_table_attach(table, button, 4, 5, 0, 1, 0, 0, 0, 0);
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(flip_image), (gpointer)2);
+
+ /* Rotation controls */
+ data->unnormalized_angle = CFG->rotationAngle;
+ data->reference_orientation = CFG->orientation;
+ table = GTK_TABLE(table_with_frame(page, NULL, TRUE));
+ label = gtk_label_new(_("Rotation"));
+ gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 0, 0);
+ data->RotationAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(
+ data->unnormalized_angle, -1e100, 1e100, 1, 10, 0));
+ g_object_set_data(G_OBJECT(data->RotationAdjustment),
+ "Adjustment-Accuracy", (gpointer)3);
+ data->RotationSpin = GTK_SPIN_BUTTON(gtk_spin_button_new(
+ data->RotationAdjustment, 1, 3));
+ g_object_set_data(G_OBJECT(data->RotationAdjustment), "Parent-Widget",
+ data->RotationSpin);
+ g_signal_connect(G_OBJECT(data->RotationAdjustment), "value-changed",
+ G_CALLBACK(adjustment_update), &data->unnormalized_angle);
+ gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(data->RotationSpin),
+ 1, 2, 0, 1, 0, 0, 0, 0);
+
/* End of transformation page */
}
diff --git a/ufraw_ufraw.c b/ufraw_ufraw.c
index adf6852..96fdc13 100644
--- a/ufraw_ufraw.c
+++ b/ufraw_ufraw.c
@@ -452,19 +452,7 @@ int ufraw_config(ufraw_data *uf, conf_data *rc, conf_data
*conf, conf_data *cmd)
} else {
if ( !uf->LoadingID || uf->conf->orientation<0 )
uf->conf->orientation = raw->flip;
-
- // Normalise rotations to a flip, then rotation of 0 < a < 90 degrees.
- uf->conf->rotationAngle = fmod(uf->conf->rotationAngle, 360.0);
- if (uf->conf->rotationAngle < 0.0) uf->conf->rotationAngle += 360.0;
- int angle, flip = 0;
- angle = floor(uf->conf->rotationAngle/90)*90;
- switch (angle) {
- case 90: flip = 6; break;
- case 180: flip = 3; break;
- case 270: flip = 5; break;
- }
- ufraw_flip_orientation(uf, flip);
- uf->conf->rotationAngle -= angle;
+ ufraw_normalize_rotation(uf);
}
if (uf->inputExifBuf==NULL) {
@@ -1845,3 +1833,23 @@ void ufraw_rotate_image_buffer(ufraw_image_data *img,
double angle)
}
g_free(in);
}
+
+/*
+ * Normalize arbitrary rotations into a 0..90 degree range.
+ */
+void ufraw_normalize_rotation(ufraw_data *uf)
+{
+ int angle, flip = 0;
+
+ uf->conf->rotationAngle = fmod(uf->conf->rotationAngle, 360.0);
+ if (uf->conf->rotationAngle < 0.0)
+ uf->conf->rotationAngle += 360.0;
+ angle = floor(uf->conf->rotationAngle / 90) * 90;
+ switch (angle) {
+ case 90: flip = 6; break;
+ case 180: flip = 3; break;
+ case 270: flip = 5; break;
+ }
+ ufraw_flip_orientation(uf, flip);
+ uf->conf->rotationAngle -= angle;
+}
diff --git a/ufraw_ui.h b/ufraw_ui.h
index 1d4b65b..9aadd2e 100644
--- a/ufraw_ui.h
+++ b/ufraw_ui.h
@@ -83,6 +83,7 @@ typedef struct {
GtkSpinButton *ShrinkSpin;
GtkSpinButton *HeightSpin;
GtkSpinButton *WidthSpin;
+ GtkSpinButton *RotationSpin;
/* We need the adjustments for update_scale() */
GtkAdjustment *WBTuningAdjustment;
GtkAdjustment *TemperatureAdjustment;
@@ -107,6 +108,7 @@ typedef struct {
GtkAdjustment *ShrinkAdjustment;
GtkAdjustment *HeightAdjustment;
GtkAdjustment *WidthAdjustment;
+ GtkAdjustment *RotationAdjustment;
GtkAdjustment *GrayscaleMixers[3];
#ifdef HAVE_LENSFUN
/* The GtkEntry with camera maker/model name */
@@ -156,6 +158,8 @@ typedef struct {
double SpotHue;
CursorType CropMotionType;
int DrawnCropX1, DrawnCropX2, DrawnCropY1, DrawnCropY2;
+ double unnormalized_angle;
+ int reference_orientation;
double shrink, height, width;
gboolean OptionsChanged;
int PageNum;
--
Frank
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
ufraw-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ufraw-devel