Update of /cvsroot/ufraw/ufraw
In directory vz-cvs-2.sog:/tmp/cvs-serv3685

Modified Files:
        ufraw_ufraw.c 
Log Message:
Fix spurious warning message about image size too small.


Index: ufraw_ufraw.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_ufraw.c,v
retrieving revision 1.257
retrieving revision 1.258
diff -u -d -r1.257 -r1.258
--- ufraw_ufraw.c       20 Feb 2011 06:15:20 -0000      1.257
+++ ufraw_ufraw.c       27 Feb 2011 06:34:37 -0000      1.258
@@ -38,11 +38,11 @@
 static void ufraw_convert_image_vignetting(ufraw_data *uf,
         ufraw_image_data *img, UFRectangle *area);
 static void ufraw_convert_image_tca(ufraw_data *uf, ufraw_image_data *img,
-                                    ufraw_image_data *outimg, UFRectangle 
*area);
+        ufraw_image_data *outimg, UFRectangle *area);
 void ufraw_prepare_tca(ufraw_data *uf);
 #endif
 static void ufraw_image_format(int *colors, int *bytes, ufraw_image_data *img,
-                               const char *formats, const char *caller);
+        const char *formats, const char *caller);
 static void ufraw_convert_image_raw(ufraw_data *uf, UFRawPhase phase);
 static void ufraw_convert_image_first(ufraw_data *uf, UFRawPhase phase);
 static void ufraw_convert_image_transform(ufraw_data *uf, ufraw_image_data 
*img,
@@ -52,7 +52,8 @@
 static void ufraw_convert_prepare_transform_buffer(ufraw_data *uf,
         ufraw_image_data *img, int width, int height);
 static void ufraw_convert_reverse_wb(ufraw_data *uf, UFRawPhase phase);
-static void ufraw_convert_import_buffer(ufraw_data *uf, UFRawPhase phase, 
dcraw_image_data *dcimg);
+static void ufraw_convert_import_buffer(ufraw_data *uf, UFRawPhase phase,
+        dcraw_image_data *dcimg);
 
 static int make_temporary(char *basefilename, char **tmpfilename)
 {
@@ -729,8 +730,7 @@
 
 /* Return the subarea index given some X,Y image coordinates.
  */
-unsigned ufraw_img_get_subarea_idx(
-    ufraw_image_data *img, int x, int y)
+unsigned ufraw_img_get_subarea_idx(ufraw_image_data *img, int x, int y)
 {
     int saw = (img->width + 3) / 4;
     int sah = (img->height + 7) / 8;
@@ -882,7 +882,7 @@
  * -   use uf->rgbMax (check, must be about 64k)
  */
 static void ufraw_shave_hotpixels(ufraw_data *uf, dcraw_image_type *img,
-                                  int width, int height, int colors, unsigned 
rgbMax)
+        int width, int height, int colors, unsigned rgbMax)
 {
     int w, h, c, i, count;
     unsigned delta, t, v, hi;
@@ -942,7 +942,7 @@
 }
 
 static void ufraw_despeckle_line(guint16 *base, int step, int size, int window,
-                                 double decay, int colors, int c)
+        double decay, int colors, int c)
 {
     unsigned lum[size];
     int i, j, start, end, next, v, cold, hot, coldj, hotj, fix;
@@ -1055,6 +1055,13 @@
 
 static int ufraw_calculate_scale(ufraw_data *uf)
 {
+    /* In the first call to ufraw_calculate_scale() the crop coordinates
+     * are not set. They cannot be set, since uf->rotatedHeight/Width are
+     * only calculated later in ufraw_convert_prepare_transform_buffer().
+     * Therefore, if size > 0, scale = 1 will be returned.
+     * Since the first call is from ufraw_convert_prepare_first_buffer(),
+     * this is not a real issue. There should always be a second call to 
+     * this function before the actual buffer allocation. */
     dcraw_data *raw = uf->raw;
     int scale = 1;
 
@@ -1065,8 +1072,8 @@
         scale = uf->conf->shrink * MIN(raw->pixel_aspect, 1 / 
raw->pixel_aspect);
     } else if (uf->conf->interpolation == half_interpolation) {
         scale = 2;
-        /* Wanted size is smaller than raw size (size is after a raw->shrink)
-         * (assuming there are filters). */
+    /* Wanted size is smaller than raw size (size is after a raw->shrink)
+     * (assuming there are filters). */
     } else if (uf->conf->size > 0 && uf->HaveFilters) {
         int cropHeight = uf->conf->CropY2 - uf->conf->CropY1;
         int cropWidth = uf->conf->CropX2 - uf->conf->CropX1;
@@ -1096,9 +1103,15 @@
                            scale * MAX(final->height, final->width) / 
uf->conf->shrink);
     }
     if (uf->conf->size > 0) {
-        int cropHeight = uf->conf->CropY2 - uf->conf->CropY1;
-        int cropWidth = uf->conf->CropX2 - uf->conf->CropX1;
-        int cropSize = MAX(cropHeight, cropWidth);
+        int finalSize = scale * MAX(final->height, final->width);
+        int cropSize;
+        if (uf->conf->CropX1 == -1) {
+            cropSize = finalSize;
+        } else {
+            int cropHeight = uf->conf->CropY2 - uf->conf->CropY1;
+            int cropWidth = uf->conf->CropX2 - uf->conf->CropX1;
+            cropSize = MAX(cropHeight, cropWidth);
+        }
         // cropSize needs to be a integer multiplier of scale
         cropSize = cropSize / scale * scale;
         if (uf->conf->size > cropSize) {
@@ -1108,7 +1121,6 @@
             /* uf->conf->size holds the size of the cropped image.
              * We need to calculate from it the desired size of
              * the uncropped image. */
-            int finalSize = scale * MAX(final->height, final->width);
             dcraw_image_resize(final, uf->conf->size * finalSize / cropSize);
         }
     }
@@ -1220,7 +1232,7 @@
 #ifdef HAVE_LENSFUN
 /* Apply TCA */
 static void ufraw_convert_image_tca(ufraw_data *uf, ufraw_image_data *img,
-                                    ufraw_image_data *outimg, UFRectangle 
*area)
+        ufraw_image_data *outimg, UFRectangle *area)
 {
     if (uf->TCAmodifier == NULL)
         return;
@@ -1272,7 +1284,8 @@
 }
 #endif // HAVE_LENSFUN
 
-static void ufraw_convert_import_buffer(ufraw_data *uf, UFRawPhase phase, 
dcraw_image_data *dcimg)
+static void ufraw_convert_import_buffer(ufraw_data *uf, UFRawPhase phase,
+        dcraw_image_data *dcimg)
 {
     ufraw_image_data *img = &uf->Images[phase];
 
@@ -1285,7 +1298,7 @@
 }
 
 static void ufraw_image_init(ufraw_image_data *img,
-                             int width, int height, int bitdepth)
+        int width, int height, int bitdepth)
 {
     if (img->height == height && img->width == width &&
             img->depth == bitdepth && img->buffer != NULL)
@@ -1314,9 +1327,15 @@
         img->height = img->height * scale / uf->conf->shrink;
     }
     if (uf->conf->size > 0) {
-        int cropHeight = uf->conf->CropY2 - uf->conf->CropY1;
-        int cropWidth = uf->conf->CropX2 - uf->conf->CropX1;
-        int cropSize = MAX(cropHeight, cropWidth);
+        int finalSize = scale * MAX(img->height, img->width);
+        int cropSize;
+        if (uf->conf->CropX1 == -1) {
+            cropSize = finalSize;
+        } else {
+            int cropHeight = uf->conf->CropY2 - uf->conf->CropY1;
+            int cropWidth = uf->conf->CropX2 - uf->conf->CropX1;
+            cropSize = MAX(cropHeight, cropWidth);
+        }
         // cropSize needs to be a integer multiplier of scale
         cropSize = cropSize / scale * scale;
         if (uf->conf->size > cropSize) {
@@ -1326,7 +1345,6 @@
             /* uf->conf->size holds the size of the cropped image.
              * We need to calculate from it the desired size of
              * the uncropped image. */
-            int finalSize = scale * MAX(img->height, img->width);
             int mul = uf->conf->size * finalSize / cropSize;
             int div = MAX(img->height, img->width);
             img->height = img->height * mul / div;
@@ -1337,7 +1355,7 @@
 
 #ifdef HAVE_LENSFUN
 void ufraw_convert_prepare_transform(ufraw_data *uf,
-                                     int width, int height, gboolean reverse, 
float scale);
+        int width, int height, gboolean reverse, float scale);
 #endif
 
 static void ufraw_convert_prepare_transform_buffer(ufraw_data *uf,
@@ -1484,7 +1502,7 @@
  * constants by variables may turn off some compiler optimizations.
  */
 static void ufraw_image_format(int *colors, int *bytes, ufraw_image_data *img,
-                               const char *formats, const char *caller)
+        const char *formats, const char *caller)
 {
     int b, c;
 
@@ -1517,7 +1535,7 @@
 }
 
 ufraw_image_data *ufraw_get_image(ufraw_data *uf, UFRawPhase phase,
-                                  gboolean bufferok)
+        gboolean bufferok)
 {
     ufraw_convert_prepare_buffers(uf, phase);
     // Find the closest phase that is actually rendered:


------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
ufraw-cvs mailing list
ufraw-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ufraw-cvs

Reply via email to