Update of /cvsroot/ufraw/ufraw In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24341
Modified Files: ufraw.h ufraw_conf.c ufraw_preview.c ufraw_ufraw.c ufraw_ui.h Log Message: Add auto-crop button. Index: ufraw_preview.c =================================================================== RCS file: /cvsroot/ufraw/ufraw/ufraw_preview.c,v retrieving revision 1.333 retrieving revision 1.334 diff -u -d -r1.333 -r1.334 --- ufraw_preview.c 5 Feb 2010 23:22:15 -0000 1.333 +++ ufraw_preview.c 7 Feb 2010 22:26:49 -0000 1.334 @@ -31,6 +31,7 @@ void ufraw_chooser_toggle(GtkToggleButton *button, GtkFileChooser *filechooser); #endif +static void update_crop_ranges(preview_data *data, gboolean render); static void adjustment_update(GtkAdjustment *adj, double *valuep); static void button_update(GtkWidget *button, gpointer user_data); @@ -910,6 +911,14 @@ uf_get_display_profile(data->PreviewWidget, &data->UF->displayProfile, &data->UF->displayProfileSize); } + if (CFG->autoCrop == apply_state) { + CFG->CropX1 = (data->UF->rotatedWidth - data->UF->autoCropWidth)/2; + CFG->CropX2 = (data->UF->rotatedWidth + data->UF->autoCropWidth)/2; + CFG->CropY1 = (data->UF->rotatedHeight - data->UF->autoCropHeight)/2; + CFG->CropY2 = (data->UF->rotatedHeight + data->UF->autoCropHeight)/2; + update_crop_ranges(data, FALSE); + CFG->autoCrop = enabled_state; + } ufraw_developer_prepare(data->UF, display_developer); render_init(data); @@ -1462,6 +1471,7 @@ &CFG->profile[out_profile][CFG->profileIndex[out_profile]].BitDepth); gtk_toggle_button_set_active(data->AutoExposureButton, CFG->autoExposure); gtk_toggle_button_set_active(data->AutoBlackButton, CFG->autoBlack); + gtk_toggle_button_set_active(data->AutoCropButton, CFG->autoCrop); curveeditor_widget_set_curve(data->CurveWidget, &CFG->curve[CFG->curveIndex]); @@ -1749,7 +1759,6 @@ return TRUE; } -static void update_crop_ranges(preview_data *data, gboolean render); static void fix_crop_aspect(preview_data *data, CursorType cursor, gboolean render); static void set_new_aspect(preview_data *data); @@ -2617,6 +2626,12 @@ break; } } + if (button == GTK_WIDGET(data->AutoCropButton)) { + CFG->autoCrop = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); + if (CFG->autoCrop == enabled_state) + CFG->autoCrop = apply_state; + } if (CFG->autoExposure==enabled_state) CFG->autoExposure = apply_state; if (CFG->autoBlack==enabled_state) CFG->autoBlack = apply_state; ufraw_invalidate_layer(data->UF, ufraw_develop_phase); @@ -2889,6 +2904,7 @@ if ( (int *)valuep==&CFG->CropY1) cursor = top_cursor; if ( (int *)valuep==&CFG->CropY2) cursor = bottom_cursor; fix_crop_aspect(data, cursor, TRUE); + if (CFG->autoCrop==enabled_state) CFG->autoCrop = apply_state; return; } /* Do nothing if value didn't really change */ @@ -2961,6 +2977,8 @@ */ void resize_canvas(preview_data *data) { + if (CFG->autoCrop == enabled_state) + CFG->autoCrop = apply_state; gboolean FullCrop = CFG->CropX1==0 && CFG->CropX2==data->UF->rotatedWidth && CFG->CropY1==0 && CFG->CropY2==data->UF->rotatedHeight; @@ -4895,10 +4913,21 @@ g_signal_connect(G_OBJECT(data->CropY2Adjustment), "value-changed", G_CALLBACK(adjustment_update), &CFG->CropY2); + data->AutoCropButton = GTK_TOGGLE_BUTTON(gtk_toggle_button_new()); + gtk_container_add(GTK_CONTAINER(data->AutoCropButton), + gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_BUTTON)); + gtk_table_attach(table, GTK_WIDGET(data->AutoCropButton), 4, 5, 1, 2, + 0, 0, 0, 0); + uf_widget_set_tooltip(GTK_WIDGET(data->AutoCropButton), + _("Auto fit crop area")); + gtk_toggle_button_set_active(data->AutoCropButton, CFG->autoCrop); + g_signal_connect(G_OBJECT(data->AutoCropButton), "clicked", + G_CALLBACK(button_update), NULL); + // Crop reset button: button = reset_button( _("Reset the crop region"), G_CALLBACK(crop_reset), NULL); - gtk_table_attach(table, button, 4, 5, 1, 2, 0, 0, 0, 0); + gtk_table_attach(table, button, 5, 6, 1, 2, 0, 0, 0, 0); /* Aspect ratio controls */ table = GTK_TABLE(table_with_frame(page, NULL, FALSE)); Index: ufraw.h =================================================================== RCS file: /cvsroot/ufraw/ufraw/ufraw.h,v retrieving revision 1.146 retrieving revision 1.147 diff -u -d -r1.146 -r1.147 --- ufraw.h 5 Feb 2010 23:22:15 -0000 1.146 +++ ufraw.h 7 Feb 2010 22:26:49 -0000 1.147 @@ -209,7 +209,7 @@ double exposure, saturation, black; /* black is only used in CMD */ int ExposureNorm; int restoreDetails, clipHighlights; - int autoExposure, autoBlack; + int autoExposure, autoBlack, autoCrop; int BaseCurveIndex, BaseCurveCount; CurveData BaseCurve[max_curves]; int curveIndex, curveCount; @@ -301,6 +301,7 @@ char filename[max_path]; int initialHeight, initialWidth, rgbMax, colors, raw_color, useMatrix; int rotatedHeight, rotatedWidth; + int autoCropHeight, autoCropWidth; gboolean LoadingID; /* Indication that we are loading an ID file */ gboolean WBDirty; float rgb_cam[3][4]; Index: ufraw_conf.c =================================================================== RCS file: /cvsroot/ufraw/ufraw/ufraw_conf.c,v retrieving revision 1.157 retrieving revision 1.158 diff -u -d -r1.157 -r1.158 --- ufraw_conf.c 27 Jan 2010 21:23:22 -0000 1.157 +++ ufraw_conf.c 7 Feb 2010 22:26:49 -0000 1.158 @@ -37,6 +37,7 @@ digital_highlights, /* clipHighlights */ disabled_state, /* autoExposure */ disabled_state, /* autoBlack */ + disabled_state, /* autoCrop */ camera_curve, camera_curve+1, /* BaseCurveIndex, BaseCurveCount */ /* BaseCurve data defaults */ { { N_("Manual curve"), TONE_CURVE, 0.0, 1.0, 0.0, 1.0, 1.0, @@ -614,6 +615,7 @@ } if (!strcmp("AutoExposure", element)) sscanf(temp, "%d", &c->autoExposure); if (!strcmp("AutoBlack", element)) sscanf(temp, "%d", &c->autoBlack); + if (!strcmp("AutoCrop", element)) sscanf(temp, "%d", &c->autoCrop); if (!strcmp("CurvePath", element)) { char *utf8 = g_filename_from_utf8(temp, -1, NULL, NULL, NULL); if (utf8!=NULL) @@ -937,6 +939,8 @@ "<AutoExposure>%d</AutoExposure>\n", c->autoExposure); if (c->autoBlack!=conf_default.autoBlack) buf = uf_markup_buf(buf, "<AutoBlack>%d</AutoBlack>\n", c->autoBlack); + if (c->autoCrop!=conf_default.autoCrop) + buf = uf_markup_buf(buf, "<AutoCrop>%d</AutoCrop>\n", c->autoCrop); if (c->saturation!=conf_default.saturation) buf = uf_markup_buf(buf, "<Saturation>%lf</Saturation>\n", c->saturation); @@ -1214,6 +1218,7 @@ dst->black = src->black; dst->autoExposure = src->autoExposure; dst->autoBlack = src->autoBlack; + dst->autoCrop = src->autoCrop; dst->restoreDetails = src->restoreDetails; dst->clipHighlights = src->clipHighlights; memcpy(dst->lightnessAdjustment, src->lightnessAdjustment, @@ -1379,6 +1384,9 @@ if (cmd->embeddedImage!=-1) conf->embeddedImage = cmd->embeddedImage; if (cmd->rotate!=-1) conf->rotate = cmd->rotate; if (cmd->rotationAngle!=NULLF) conf->rotationAngle = cmd->rotationAngle; + if (cmd->CropX1 != -1 || cmd->CropX2 != -1 || + cmd->CropY1 != -1 || cmd->CropY2 != -1) + conf->autoCrop = disabled_state; if (cmd->CropX1 !=-1) conf->CropX1 = cmd->CropX1; if (cmd->CropY1 !=-1) conf->CropY1 = cmd->CropY1; if (cmd->CropX2 !=-1) conf->CropX2 = cmd->CropX2; Index: ufraw_ufraw.c =================================================================== RCS file: /cvsroot/ufraw/ufraw/ufraw_ufraw.c,v retrieving revision 1.234 retrieving revision 1.235 diff -u -d -r1.234 -r1.235 --- ufraw_ufraw.c 5 Feb 2010 23:22:16 -0000 1.234 +++ ufraw_ufraw.c 7 Feb 2010 22:26:49 -0000 1.235 @@ -1437,16 +1437,21 @@ ufraw_convert_prepare_transform(uf, width, height, FALSE); uf->rotatedWidth = iWidth; uf->rotatedHeight = iHeight; + uf->autoCropWidth = iWidth; + uf->autoCropHeight = iHeight; return; } const float sine = sin(uf->conf->rotationAngle * 2 * M_PI / 360); const float cosine = cos(uf->conf->rotationAngle * 2 * M_PI / 360); + const float aspectRatio = (float)(uf->conf->CropX2 - uf->conf->CropX1) / + (uf->conf->CropY2 - uf->conf->CropY1); const float midX = iWidth/2.0 - 0.5; const float midY = iHeight/2.0 - 0.5; #ifdef HAVE_LENSFUN gboolean applyLF = uf->modifier != NULL && (uf->modFlags & UF_LF_TRANSFORM); #endif float maxX = 0, maxY = 0; + float minX = 999999, minY = 999999; int i; for (i = 0; i < iWidth + iHeight - 1; i++) { int x, y; @@ -1474,10 +1479,16 @@ float srcY = (buff[0]-midX)*sine + (buff[1]-midY)*cosine; maxX = MAX(maxX, fabs(srcX)); maxY = MAX(maxY, fabs(srcY)); + if (fabs(srcX/srcY) > aspectRatio) + minX = MIN(minX, fabs(srcX)); + else + minY = MIN(minY, fabs(srcY)); } // Do not allow increasing canvas size by more than a factor of 2 uf->rotatedWidth = MIN(ceil(2*maxX), 2*iWidth); uf->rotatedHeight = MIN(ceil(2*maxY), 2*iHeight); + uf->autoCropWidth = MIN(floor(2*minX), 2*iWidth); + uf->autoCropHeight = MIN(floor(2*minY), 2*iHeight); int newWidth = uf->rotatedWidth * width / iWidth; int newHeight = uf->rotatedHeight * height / iHeight; ufraw_image_init(img, newWidth, newHeight, 8); Index: ufraw_ui.h =================================================================== RCS file: /cvsroot/ufraw/ufraw/ufraw_ui.h,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- ufraw_ui.h 5 Feb 2010 23:22:16 -0000 1.35 +++ ufraw_ui.h 7 Feb 2010 22:26:49 -0000 1.36 @@ -58,7 +58,8 @@ GtkLabel *SpotPatch; GtkLabel *HotpixelCount; colorLabels *SpotLabels, *AvrLabels, *DevLabels, *OverLabels, *UnderLabels; - GtkToggleButton *AutoExposureButton, *AutoBlackButton, *LockAspectButton; + GtkToggleButton *AutoExposureButton, *AutoBlackButton; + GtkToggleButton *AutoCropButton, *LockAspectButton; GtkWidget *AutoCurveButton; GtkWidget *ResetGammaButton, *ResetLinearButton; GtkWidget *ResetExposureButton, *ResetSaturationButton; ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ ufraw-cvs mailing list ufraw-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ufraw-cvs