Author: post
Date: 2010-06-23 09:52:05 +0200 (Wed, 23 Jun 2010)
New Revision: 3441

Modified:
   trunk/plugins/resample/resample.c
Log:
Resample: Be sure to copy the image, if one of the dimensions remain unchanged.

Modified: trunk/plugins/resample/resample.c
===================================================================
--- trunk/plugins/resample/resample.c   2010-06-23 07:33:24 UTC (rev 3440)
+++ trunk/plugins/resample/resample.c   2010-06-23 07:52:05 UTC (rev 3441)
@@ -21,8 +21,10 @@
 
 #include <rawstudio.h>
 #include <math.h>
+#include <string.h>  /*memcpy */
 
 
+
 #define RS_TYPE_RESAMPLE (rs_resample_type)
 #define RS_RESAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_RESAMPLE, 
RSResample))
 #define RS_RESAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), 
RS_TYPE_RESAMPLE, RSResampleClass))
@@ -257,6 +259,24 @@
        return mask;
 }
 
+static inline void 
+bit_blt(char* dstp, int dst_pitch, const char* srcp, int src_pitch, int 
row_size, int height) 
+{
+       if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) 
+       {
+               memcpy(dstp, srcp, row_size*height);
+               return;
+       }
+
+       int y;
+       for (y = height; y > 0; --y)
+       {
+               memcpy(dstp, srcp, row_size);
+               dstp += dst_pitch;
+               srcp += src_pitch;
+       }
+}
+
 gpointer
 start_thread_resampler(gpointer _thread_info)
 {
@@ -297,6 +317,11 @@
                else
                        ResizeH(t);
        }
+       /* Unchanged in both directions, have thread 0 copy all the image */
+       else if (t->dest_offset_other == 0)
+               bit_blt((char*)GET_PIXEL(t->output,0,0), t->output->pitch * 2, 
+                       (const char*)GET_PIXEL(t->input,0,0), t->input->pitch * 
2, t->input->pitch * 2, t->input->h);
+
        g_thread_exit(NULL);
 
        return NULL; /* Make the compiler shut up - we'll never return */


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to