[Pkg-e-commits] [SCM] Python bindings for Evas branch, upstream-vcs, updated. a2d7e40fb9fbbe948f479174a461f735a2f530fb

barbieri barbieri at alioth.debian.org
Sat May 24 16:31:52 UTC 2008


The following commit has been merged in the upstream-vcs branch:
commit 9e6d6d278f5c22fe475384b3f7318883c71ee543
Author: barbieri <barbieri>
Date:   Wed Mar 12 18:53:55 2008 +0000

    Reformat to fit coding style + unify headers
    
    This should change no logic, just coding style. Next commits will
    change types and break some functions into smaller pieces.

diff --git a/evas/evas.c_evas_object_image.pxi b/evas/evas.c_evas_object_image.pxi
index 0d76ae7..da2bf96 100644
--- a/evas/evas.c_evas_object_image.pxi
+++ b/evas/evas.c_evas_object_image.pxi
@@ -1,30 +1,9 @@
 # This file is included verbatim by c_evas.pyx
 
 
-## for mask support
-cdef extern from "evas_object_image_mask.h":
-    int evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask, 
-        Evas_Object *surface, int x_mask, int y_mask, int x_surface, int y_surface)
-
-def image_mask_fill(source, mask, surface, int x_mask, int y_mask, 
-    int x_surface, int y_surface):
-        cdef Image isource = <Image> source
-        cdef Image imask = <Image> mask
-        cdef Image isurface = <Image> surface
-        evas_object_image_mask_fill(isource.obj, imask.obj, isurface.obj, 
-           x_mask, y_mask, x_surface, y_surface)
-
-
-## for rotate support
-cdef extern from "evas_object_image_rotate.h":
-    ctypedef enum Rotation:
-            ROTATE_NONE
-            ROTATE_90
-            ROTATE_180
-            ROTATE_270
-
-    void evas_object_image_rotate(Evas_Object *image, Rotation rotation)
-
+def image_mask_fill(Image source, Image mask, Image surface, int x_mask, int y_mask, int x_surface, int y_surface):
+    evas_object_image_mask_fill(source.obj, mask.obj, surface.obj,
+                                x_mask, y_mask, x_surface, y_surface)
 
 cdef int _data_size_get(Evas_Object *obj):
     cdef int stride, h, bpp, cspace, have_alpha
@@ -464,7 +443,7 @@ cdef public class Image(Object) [object PyEvasImage, type PyEvasImage_Type]:
             self.colorspace_set(value)
 
     def rotate(self, int rotation):
-        evas_object_image_rotate(self.obj, <Rotation>rotation)
+        evas_object_image_rotate(self.obj, <Evas_Object_Image_Rotation>rotation)
 
     def reload(self):
         "Force reload of image data."
diff --git a/evas/evas_object_image_mask.c b/evas/evas_object_image_mask.c
index e172010..1f13b51 100644
--- a/evas/evas_object_image_mask.c
+++ b/evas/evas_object_image_mask.c
@@ -2,51 +2,42 @@
 #include <stdlib.h>
 #include <Evas.h>
 
-#include "evas_object_image_mask.h"
-
-typedef unsigned char DATA8;
-typedef short int DATA16;
-typedef int DATA32;
-
-enum {FALSE, TRUE};
-
+#include "evas_object_image_python_extras.h"
 
 #define BPIXEL(base, x, y, stride) (base + (y * stride + x))
-
 #define MEDPIXEL(src, msk, srf) (((src) * (msk)) + (srf) * (255 - (msk)))/255
 
 
 static void
-_argb8888_image_mask_fill(char *dst, const char *src,
-    const char *msk, const char *srf,
-    int x_msk, int y_msk, int x_srf, int y_srf,
-    int src_stride, int src_width, int src_height,
-    int msk_stride, int msk_width, int msk_height,
-    int srf_stride, int srf_width, int srf_height)
+_argb8888_image_mask_fill(char *dst, const char *src, const char *msk, const char *srf, int x_msk, int y_msk, int x_srf, int y_srf, int src_stride, int src_width, int src_height, int msk_stride, int msk_width, int msk_height, int srf_stride, int srf_width, int srf_height)
 {
-    int x, y, xp, yp, xs, ys;
-    int r, g, b, a;
-    DATA32 pixel, pxa, pxb;
-    DATA32 *sp = (DATA32 *) src;
-    DATA32 *mp = (DATA32 *) msk;
-    DATA32 *fp = (DATA32 *) srf;
-    DATA32 *dp = (DATA32 *) dst;
-
-    for (y = 0; y < src_height; y++)
-        for (x = 0; x < src_width; x++)
-        {
-            xp = x - x_msk;
-            yp = y - y_msk;
-            xs = x - x_srf;
-            ys = y - y_srf;
-
-            pixel = *(BPIXEL(sp, x, y, src_stride));
-
-            if (xp >= 0 && xp < msk_width && yp >= 0 && yp < msk_height
-                && xs >= 0 && xs < srf_width && ys >= 0 && ys < srf_height) {
-                pxa = *(BPIXEL(mp, xp, yp, msk_stride));
-                pxb = *(BPIXEL(fp, xs, ys, srf_stride));
-                if(pxa != 0) {
+   int x, y, xp, yp, xs, ys;
+   int r, g, b, a;
+   DATA32 pixel, pxa, pxb;
+   DATA32 *sp = (DATA32 *) src;
+   DATA32 *mp = (DATA32 *) msk;
+   DATA32 *fp = (DATA32 *) srf;
+   DATA32 *dp = (DATA32 *) dst;
+
+   for (y = 0; y < src_height; y++)
+     for (x = 0; x < src_width; x++)
+       {
+	  xp = x - x_msk;
+	  yp = y - y_msk;
+	  xs = x - x_srf;
+	  ys = y - y_srf;
+
+	  pixel = *(BPIXEL(sp, x, y, src_stride));
+
+	  if ((xp >= 0) && (xp < msk_width) &&
+	      (yp >= 0) && (yp < msk_height) &&
+	      (xs >= 0) && (xs < srf_width) &&
+	      (ys >= 0) && (ys < srf_height))
+	    {
+	       pxa = *(BPIXEL(mp, xp, yp, msk_stride));
+	       pxb = *(BPIXEL(fp, xs, ys, srf_stride));
+	       if (pxa != 0)
+		 {
                     a = MEDPIXEL((pixel >> 24) & 0xFF,
                                  (pxa >> 24) & 0xFF, (pxb >> 24) & 0xFF);
                     r = MEDPIXEL((pixel >> 16) & 0xFF,
@@ -55,75 +46,75 @@ _argb8888_image_mask_fill(char *dst, const char *src,
                                  (pxa >> 8) & 0xFF, (pxb >> 8) & 0xFF);
                     b = MEDPIXEL(pixel & 0xFF, pxa & 0xFF, pxb & 0xFF);
                     pixel = (a << 24) | (r << 16) | (g << 8) | b;
-                }
+		 }
             }
 
-            *(BPIXEL(dp, x, y, src_stride)) = pixel;
-        }
+	  *(BPIXEL(dp, x, y, src_stride)) = pixel;
+       }
 }
 
 
 int
-evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask,
-    Evas_Object *surface, int x_mask, int y_mask, int x_surface, int y_surface)
+evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask, Evas_Object *surface, int x_mask, int y_mask, int x_surface, int y_surface)
 {
-    int alloc_size;
-    unsigned char has_alpha;
-    char *src_data;
-    char *msk_data;
-    char *srf_data;
-    char *new_buffer;
-    int src_stride, src_width, src_height;
-    int msk_stride, msk_width, msk_height;
-    int srf_stride, srf_width, srf_height;
-
-    Evas_Colorspace src_colorspace = evas_object_image_colorspace_get(src);
-    Evas_Colorspace msk_colorspace = evas_object_image_colorspace_get(mask);
-    Evas_Colorspace srf_colorspace = evas_object_image_colorspace_get(surface);
-
-    if (src_colorspace != msk_colorspace || src_colorspace != srf_colorspace) {
-        /* force use the same colorspace */
-        return 1;
-    }
-
-    evas_object_image_size_get(src, &src_width, &src_height);
-    src_stride = evas_object_image_stride_get(src);
-    evas_object_image_size_get(mask, &msk_width, &msk_height);
-    msk_stride = evas_object_image_stride_get(mask);
-    evas_object_image_size_get(surface, &srf_width, &srf_height);
-    srf_stride = evas_object_image_stride_get(surface);
-
-    has_alpha = evas_object_image_alpha_get(src);
-
-    switch(src_colorspace) {
-        case EVAS_COLORSPACE_ARGB8888:
-            alloc_size = IMG_BYTE_SIZE_ARGB8888(src_stride, src_height, src_stride);
-            new_buffer = (char *) malloc(alloc_size);
-            if(new_buffer == NULL)
-                return 3;
-
-            src_data = (char *) evas_object_image_data_get(src, FALSE);
-            msk_data = (char *) evas_object_image_data_get(mask, FALSE);
-            srf_data = (char *) evas_object_image_data_get(surface, FALSE);
-
-            _argb8888_image_mask_fill(new_buffer, src_data, msk_data,
-                srf_data, x_mask, y_mask, x_surface, y_surface,
-                src_stride, src_width, src_height,
-                msk_stride, msk_width, msk_height,
-                srf_stride, srf_width, srf_height);
-            break;
-        case EVAS_COLORSPACE_RGB565_A5P:
-            /* TODO */
-            return 2;
-        default:
-            /* invalid colorspace */
-            return 2;
-    }
-
-    evas_object_image_data_update_add(src, 0, 0, src_width, src_height);
-    evas_object_image_data_copy_set(src, new_buffer);
-
-    free(new_buffer);
-
-    return 0;
+   int alloc_size;
+   unsigned char has_alpha;
+   char *src_data;
+   char *msk_data;
+   char *srf_data;
+   char *new_buffer;
+   int src_stride, src_width, src_height;
+   int msk_stride, msk_width, msk_height;
+   int srf_stride, srf_width, srf_height;
+
+   Evas_Colorspace src_colorspace = evas_object_image_colorspace_get(src);
+   Evas_Colorspace msk_colorspace = evas_object_image_colorspace_get(mask);
+   Evas_Colorspace srf_colorspace = evas_object_image_colorspace_get(surface);
+
+   if ((src_colorspace != msk_colorspace) || (src_colorspace != srf_colorspace))
+     /* force use the same colorspace */
+     return 1;
+
+   evas_object_image_size_get(src, &src_width, &src_height);
+   src_stride = evas_object_image_stride_get(src);
+   evas_object_image_size_get(mask, &msk_width, &msk_height);
+   msk_stride = evas_object_image_stride_get(mask);
+   evas_object_image_size_get(surface, &srf_width, &srf_height);
+   srf_stride = evas_object_image_stride_get(surface);
+
+   has_alpha = evas_object_image_alpha_get(src);
+
+   switch (src_colorspace)
+     {
+      case EVAS_COLORSPACE_ARGB8888:
+	 alloc_size = IMG_BYTE_SIZE_ARGB8888(src_stride, src_height, src_stride);
+	 new_buffer = malloc(alloc_size);
+	 if (!new_buffer)
+	   return 3;
+
+	 src_data = evas_object_image_data_get(src, 0);
+	 msk_data = evas_object_image_data_get(mask, 0);
+	 srf_data = evas_object_image_data_get(surface, 0);
+
+	 _argb8888_image_mask_fill(new_buffer, src_data, msk_data,
+				   srf_data, x_mask, y_mask,
+				   x_surface, y_surface,
+				   src_stride, src_width, src_height,
+				   msk_stride, msk_width, msk_height,
+				   srf_stride, srf_width, srf_height);
+	 break;
+      case EVAS_COLORSPACE_RGB565_A5P:
+	 /* TODO */
+	 return 2;
+      default:
+	 /* invalid colorspace */
+	 return 2;
+     }
+
+   evas_object_image_data_update_add(src, 0, 0, src_width, src_height);
+   evas_object_image_data_copy_set(src, new_buffer);
+
+   free(new_buffer);
+
+   return 0;
 }
diff --git a/evas/evas_object_image_rotate.c b/evas/evas_object_image_rotate.c
index 1a0b52f..fb6cb95 100644
--- a/evas/evas_object_image_rotate.c
+++ b/evas/evas_object_image_rotate.c
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <Evas.h>
 
-#include "evas_object_image_rotate.h"
+#include "evas_object_image_python_extras.h"
 
 static inline int
 _calc_stride(int w)
@@ -15,422 +15,424 @@ _calc_stride(int w)
 }
 
 static inline int
-_calc_image_byte_size(Evas_Colorspace colorspace, Rotation rotation,
-                      int stride, int w, int h, unsigned char has_alpha)
+_calc_image_byte_size(Evas_Colorspace colorspace, Evas_Object_Image_Rotation rotation, int stride, int w, int h, unsigned char has_alpha)
 {
-    int dst_stride, dst_height;
-    int image_byte_size;
+   int dst_stride, dst_height;
+   int image_byte_size;
 
-    if (rotation == ROTATE_90 || rotation == ROTATE_270) {
+   if ((rotation == ROTATE_90) || (rotation == ROTATE_270))
+     {
         dst_stride = _calc_stride(h);
         dst_height = w;
-    } else {
+     }
+   else
+     {
         dst_stride = stride;
         dst_height = h;
-    }
-
-    switch (colorspace) {
-        case EVAS_COLORSPACE_ARGB8888:
-            image_byte_size = IMG_BYTE_SIZE_ARGB8888(dst_stride, dst_height, has_alpha);
-            break;
-        case EVAS_COLORSPACE_RGB565_A5P:
-            image_byte_size = IMG_BYTE_SIZE_RGB565(dst_stride, dst_height, has_alpha);
-            break;
-        default:
-            image_byte_size = -1;
-            break;
-    }
-
-    return image_byte_size;
+     }
+
+   switch (colorspace)
+     {
+      case EVAS_COLORSPACE_ARGB8888:
+	 image_byte_size = IMG_BYTE_SIZE_ARGB8888(dst_stride, dst_height, has_alpha);
+	 break;
+      case EVAS_COLORSPACE_RGB565_A5P:
+	 image_byte_size = IMG_BYTE_SIZE_RGB565(dst_stride, dst_height, has_alpha);
+	 break;
+      default:
+	 image_byte_size = -1;
+	 break;
+     }
+
+   return image_byte_size;
 }
 
 static void
-_data8_image_rotate_90(char *dst, const char *src,
-                       int dst_stride, int src_stride,
-                       int out_x, int out_y, int w, int h)
+_data8_image_rotate_90(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA8 *dp, *sp;
-    int x, y;
+   DATA8 *dp, *sp;
+   int x, y;
 
-    sp = (DATA8 *) src;
-    dp = ((DATA8 *) dst) + ((out_x +
-         (w + out_y - 1) * dst_stride));
+   sp = (DATA8 *) src;
+   dp = ((DATA8 *) dst) + ((out_x +
+			    (w + out_y - 1) * dst_stride));
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA8 *dp_itr, *sp_itr;
 
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
-            *dp_itr = *sp_itr;
+        for (x = 0; x < w; x++)
+	  {
+	     *dp_itr = *sp_itr;
 
-            sp_itr++;
-            dp_itr -= dst_stride;
-        }
+	     sp_itr++;
+	     dp_itr -= dst_stride;
+	  }
         sp += src_stride;
         dp++;
-    }
+     }
 }
 
 static void
-_data16_image_rotate_90(char *dst, const char *src,
-                        int dst_stride, int src_stride,
-                        int out_x, int out_y, int w, int h)
+_data16_image_rotate_90(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA16 *dp, *sp;
-    int x, y;
+   DATA16 *dp, *sp;
+   int x, y;
 
-    sp = (DATA16 *) src;
-    dp = ((DATA16 *) dst) + ((out_x +
-         (w + out_y - 1) * dst_stride));
+   sp = (DATA16 *) src;
+   dp = ((DATA16 *) dst) + ((out_x +
+			     (w + out_y - 1) * dst_stride));
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA16 *dp_itr, *sp_itr;
 
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
-            *dp_itr = *sp_itr;
+        for (x = 0; x < w; x++)
+	  {
+	     *dp_itr = *sp_itr;
 
-            sp_itr++;
-            dp_itr -= dst_stride;
-        }
+	     sp_itr++;
+	     dp_itr -= dst_stride;
+	  }
         sp += src_stride;
         dp++;
-    }
+     }
 }
 
 static void
-_data32_image_rotate_90(char *dst, const char *src,
-                        int dst_stride, int src_stride,
-                        int out_x, int out_y, int w, int h)
+_data32_image_rotate_90(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA32 *dp, *sp;
-    int x, y;
+   DATA32 *dp, *sp;
+   int x, y;
 
-    sp = (DATA32 *) src;
-    dp = ((DATA32 *) dst) + ((out_x +
-         (w + out_y - 1) * dst_stride));
+   sp = (DATA32 *) src;
+   dp = ((DATA32 *) dst) + ((out_x +
+			     (w + out_y - 1) * dst_stride));
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA32 *dp_itr, *sp_itr;
 
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
-            *dp_itr = *sp_itr;
+        for (x = 0; x < w; x++)
+	  {
+	     *dp_itr = *sp_itr;
 
-            sp_itr++;
-            dp_itr -= dst_stride;
-        }
+	     sp_itr++;
+	     dp_itr -= dst_stride;
+	  }
         sp += src_stride;
         dp++;
-    }
+     }
 }
 
 static void
-_data8_image_rotate_180(char *dst, const char *src,
-                        int dst_stride, int src_stride,
-                        int out_x, int out_y, int w, int h)
+_data8_image_rotate_180(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA8 *dp, *sp;
-    int x, y;
+   DATA8 *dp, *sp;
+   int x, y;
 
-    sp = (DATA8 *) src;
-    dp = ((DATA8 *) dst) + ((w + out_x - 1) +
-         (h + out_y - 1) * dst_stride);
+   sp = (DATA8 *) src;
+   dp = ((DATA8 *) dst) + ((w + out_x - 1) +
+			   (h + out_y - 1) * dst_stride);
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA8 *dp_itr, *sp_itr;
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
+        for (x = 0; x < w; x++)
+	  {
              *dp_itr = *sp_itr;
 
              sp_itr++;
              dp_itr--;
-        }
+	  }
         sp += src_stride;
         dp -= dst_stride;
-    }
+     }
 }
 
 static void
-_data16_image_rotate_180(char *dst, const char *src,
-                         int dst_stride, int src_stride,
-                         int out_x, int out_y, int w, int h)
+_data16_image_rotate_180(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA16 *dp, *sp;
-    int x, y;
+   DATA16 *dp, *sp;
+   int x, y;
 
-    sp = (DATA16 *) src;
-    dp = ((DATA16 *) dst) + ((w + out_x - 1) +
-         (h + out_y - 1) * dst_stride);
+   sp = (DATA16 *) src;
+   dp = ((DATA16 *) dst) + ((w + out_x - 1) +
+			    (h + out_y - 1) * dst_stride);
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA16 *dp_itr, *sp_itr;
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
+        for (x = 0; x < w; x++)
+	  {
              *dp_itr = *sp_itr;
 
              sp_itr++;
              dp_itr--;
-        }
+	  }
         sp += src_stride;
         dp -= dst_stride;
-    }
+     }
 }
 static void
-_data32_image_rotate_180(char *dst, const char *src,
-                         int dst_stride, int src_stride,
-                         int out_x, int out_y, int w, int h)
+_data32_image_rotate_180(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA32 *dp, *sp;
-    int x, y;
+   DATA32 *dp, *sp;
+   int x, y;
 
-    sp = (DATA32 *) src;
-    dp = ((DATA32 *) dst) + ((w + out_x - 1) +
-         (h + out_y - 1) * dst_stride);
+   sp = (DATA32 *) src;
+   dp = ((DATA32 *) dst) + ((w + out_x - 1) +
+			    (h + out_y - 1) * dst_stride);
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA32 *dp_itr, *sp_itr;
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
+        for (x = 0; x < w; x++)
+	  {
              *dp_itr = *sp_itr;
 
              sp_itr++;
              dp_itr--;
-        }
+	  }
         sp += src_stride;
         dp -= dst_stride;
-    }
+     }
 }
 
 static void
-_data8_image_rotate_270(char *dst, const char *src,
-                        int dst_stride, int src_stride,
-                        int out_x, int out_y, int w, int h)
+_data8_image_rotate_270(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA8 *dp, *sp;
-    int x, y;
+   DATA8 *dp, *sp;
+   int x, y;
 
-    sp = (DATA8 *) src;
-    dp = ((DATA8 *) dst) + ((h + out_x - 1) +
-         out_y * dst_stride);
+   sp = (DATA8 *) src;
+   dp = ((DATA8 *) dst) + ((h + out_x - 1) +
+			   out_y * dst_stride);
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA8 *dp_itr, *sp_itr;
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
+        for (x = 0; x < w; x++)
+	  {
              *dp_itr = *sp_itr;
 
              sp_itr++;
              dp_itr += dst_stride;
-        }
+	  }
         sp += src_stride;
         dp--;
-    }
+     }
 }
 
 static void
-_data16_image_rotate_270(char *dst, const char *src,
-                         int dst_stride, int src_stride,
-                         int out_x, int out_y, int w, int h)
+_data16_image_rotate_270(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA16 *dp, *sp;
-    int x, y;
+   DATA16 *dp, *sp;
+   int x, y;
 
-    sp = (DATA16 *) src;
-    dp = ((DATA16 *) dst) + ((h + out_x - 1) +
-         out_y * dst_stride);
+   sp = (DATA16 *) src;
+   dp = ((DATA16 *) dst) + ((h + out_x - 1) +
+			    out_y * dst_stride);
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA16 *dp_itr, *sp_itr;
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
+        for (x = 0; x < w; x++)
+	  {
              *dp_itr = *sp_itr;
 
              sp_itr++;
              dp_itr += dst_stride;
-        }
+	  }
         sp += src_stride;
         dp--;
-    }
+     }
 }
 
 static void
-_data32_image_rotate_270(char *dst, const char *src,
-                         int dst_stride, int src_stride,
-                         int out_x, int out_y, int w, int h)
+_data32_image_rotate_270(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
 {
-    DATA32 *dp, *sp;
-    int x, y;
+   DATA32 *dp, *sp;
+   int x, y;
 
-    sp = (DATA32 *) src;
-    dp = ((DATA32 *) dst) + ((h + out_x - 1) +
-         out_y * dst_stride);
+   sp = (DATA32 *) src;
+   dp = ((DATA32 *) dst) + ((h + out_x - 1) +
+			    out_y * dst_stride);
 
-    for (y = 0; y < h; y++) {
+   for (y = 0; y < h; y++)
+     {
         DATA32 *dp_itr, *sp_itr;
         sp_itr = sp;
         dp_itr = dp;
 
-        for (x = 0; x < w; x++) {
+        for (x = 0; x < w; x++)
+	  {
              *dp_itr = *sp_itr;
 
              sp_itr++;
              dp_itr += dst_stride;
-        }
+	  }
         sp += src_stride;
         dp--;
-    }
+     }
 }
 
 static void
-_rgb565_image_rotate(Rotation rotation,
-                     char *dst, const char *src,
-                     int src_stride, unsigned char has_alpha,
-                     int out_x, int out_y, int w, int h)
+_rgb565_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const char *src, int src_stride, unsigned char has_alpha, int out_x, int out_y, int w, int h)
 {
-    int dst_stride;
-
-    char *dst_alpha;
-    const char *src_alpha;
-
-    if (has_alpha)
-        src_alpha = src + src_stride * h * 2;
-
-    switch (rotation) {
-        case ROTATE_90:
-            dst_stride = _calc_stride(h);
-            _data16_image_rotate_90(dst, src,
-                                    dst_stride, src_stride,
-                                    out_x, out_y, w, h);
-            if (has_alpha) {
-                dst_alpha = dst + dst_stride * w * 2;
-                _data8_image_rotate_90(dst_alpha, src_alpha,
-                                       dst_stride, src_stride,
-                                       out_x, out_y, w, h);
-            }
-            break;
-        case ROTATE_180:
-            dst_stride = src_stride;
-            _data16_image_rotate_180(dst, src,
-                                     dst_stride, src_stride,
-                                     out_x, out_y, w, h);
-            if (has_alpha) {
-                dst_alpha = dst + dst_stride * h * 2;
-                _data8_image_rotate_180(dst_alpha, src_alpha,
-                                        dst_stride, src_stride,
-                                        out_x, out_y, w, h);
-            }
-            break;
-        case ROTATE_270:
-            dst_stride = _calc_stride(h);
-            _data16_image_rotate_270(dst, src,
-                                     dst_stride, src_stride,
-                                     out_x, out_y, w, h);
-            if (has_alpha) {
-                dst_alpha = dst + dst_stride * w * 2;
-                _data8_image_rotate_270(dst_alpha, src_alpha,
-                                        dst_stride, src_stride,
-                                        out_x, out_y, w, h);
-            }
-            break;
-        case ROTATE_NONE:
-	    break;
-    }
+   int dst_stride;
+   char *dst_alpha;
+   const char *src_alpha;
+
+   if (has_alpha)
+     src_alpha = src + src_stride * h * 2;
+
+   switch (rotation)
+     {
+      case ROTATE_90:
+	 dst_stride = _calc_stride(h);
+	 _data16_image_rotate_90(dst, src,
+				 dst_stride, src_stride,
+				 out_x, out_y, w, h);
+	 if (has_alpha)
+	   {
+	      dst_alpha = dst + dst_stride * w * 2;
+	      _data8_image_rotate_90(dst_alpha, src_alpha,
+				     dst_stride, src_stride,
+				     out_x, out_y, w, h);
+	   }
+	 break;
+      case ROTATE_180:
+	 dst_stride = src_stride;
+	 _data16_image_rotate_180(dst, src,
+				  dst_stride, src_stride,
+				  out_x, out_y, w, h);
+	 if (has_alpha)
+	   {
+	      dst_alpha = dst + dst_stride * h * 2;
+	      _data8_image_rotate_180(dst_alpha, src_alpha,
+				      dst_stride, src_stride,
+				      out_x, out_y, w, h);
+	   }
+	 break;
+      case ROTATE_270:
+	 dst_stride = _calc_stride(h);
+	 _data16_image_rotate_270(dst, src,
+				  dst_stride, src_stride,
+				  out_x, out_y, w, h);
+	 if (has_alpha)
+	   {
+	      dst_alpha = dst + dst_stride * w * 2;
+	      _data8_image_rotate_270(dst_alpha, src_alpha,
+				      dst_stride, src_stride,
+				      out_x, out_y, w, h);
+	   }
+	 break;
+      case ROTATE_NONE:
+	 break;
+     }
 }
 
 static void
-_argb8888_image_rotate(Rotation rotation,
-                       char *dst, const char *src,
-                       int src_stride,
-                       int out_x, int out_y, int w, int h)
+_argb8888_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const char *src, int src_stride, int out_x, int out_y, int w, int h)
 {
-    int dst_stride;
-
-    switch(rotation) {
-        case ROTATE_90:
-            dst_stride = h;
-            _data32_image_rotate_90(dst, src,
-                                    dst_stride, src_stride,
-                                    out_x, out_y, w, h);
-            break;
-        case ROTATE_180:
-            dst_stride = src_stride;
-            _data32_image_rotate_180(dst, src,
-                                     dst_stride, src_stride,
-                                     out_x, out_y, w, h);
-            break;
-        case ROTATE_270:
-            dst_stride = h;
-            _data32_image_rotate_270(dst, src,
-                                     dst_stride, src_stride,
-                                     out_x, out_y, w, h);
-            break;
-        case ROTATE_NONE:
-	    break;
-    }
+   int dst_stride;
+
+   switch(rotation)
+     {
+      case ROTATE_90:
+	 dst_stride = h;
+	 _data32_image_rotate_90(dst, src,
+				 dst_stride, src_stride,
+				 out_x, out_y, w, h);
+	 break;
+      case ROTATE_180:
+	 dst_stride = src_stride;
+	 _data32_image_rotate_180(dst, src,
+				  dst_stride, src_stride,
+				  out_x, out_y, w, h);
+	 break;
+      case ROTATE_270:
+	 dst_stride = h;
+	 _data32_image_rotate_270(dst, src,
+				  dst_stride, src_stride,
+				  out_x, out_y, w, h);
+	 break;
+      case ROTATE_NONE:
+	 break;
+     }
 }
 
 void
-evas_object_image_rotate(Evas_Object *image, Rotation rotation)
+evas_object_image_rotate(Evas_Object *image, Evas_Object_Image_Rotation rotation)
 {
-    Evas_Colorspace colorspace = evas_object_image_colorspace_get(image);
-    int image_byte_size;
-    int stride, width, height;
-    unsigned char has_alpha;
-    char *new_buffer;
-    char *src_data;
-
-    evas_object_image_size_get(image, &width, &height);
-    stride = evas_object_image_stride_get(image);
-    has_alpha = evas_object_image_alpha_get(image);
-
-    image_byte_size = _calc_image_byte_size(colorspace, rotation,
-                                            stride, width,
-                                            height, has_alpha);
-    if (image_byte_size <= 0)
-        return;
-
-    new_buffer = malloc(image_byte_size);
-    src_data = evas_object_image_data_get(image, FALSE);
-
-    switch (colorspace) {
-        case EVAS_COLORSPACE_ARGB8888:
-            _argb8888_image_rotate(rotation, new_buffer, src_data,
-                                   stride, 0, 0, width, height);
-            break;
-        case EVAS_COLORSPACE_RGB565_A5P:
-            _rgb565_image_rotate(rotation, new_buffer, src_data,
-                                 stride, has_alpha, 0, 0, width, height);
-            break;
-        case EVAS_COLORSPACE_YCBCR422P601_PL:
-	   fputs("Colorspace YCBCR422P601_PL not handled\n", stderr);
-	   break;
-        case EVAS_COLORSPACE_YCBCR422P709_PL:
-	   fputs("Colorspace YCBCR422P709_PL not handled\n", stderr);
-	   break;
-    }
-
-    if (rotation == ROTATE_90 || rotation == ROTATE_270)
-        evas_object_image_size_set(image, height, width);
-
-    evas_object_image_data_update_add(image, 0, 0, width, height);
-    evas_object_image_data_copy_set(image, new_buffer);
-
-    free(new_buffer);
+   Evas_Colorspace colorspace = evas_object_image_colorspace_get(image);
+   int image_byte_size;
+   int stride, width, height;
+   unsigned char has_alpha;
+   char *new_buffer;
+   char *src_data;
+
+   evas_object_image_size_get(image, &width, &height);
+   stride = evas_object_image_stride_get(image);
+   has_alpha = evas_object_image_alpha_get(image);
+
+   image_byte_size = _calc_image_byte_size(colorspace, rotation,
+					   stride, width,
+					   height, has_alpha);
+   if (image_byte_size <= 0)
+     return;
+
+   new_buffer = malloc(image_byte_size);
+   src_data = evas_object_image_data_get(image, 0);
+
+   switch (colorspace)
+     {
+      case EVAS_COLORSPACE_ARGB8888:
+	 _argb8888_image_rotate(rotation, new_buffer, src_data,
+				stride, 0, 0, width, height);
+	 break;
+      case EVAS_COLORSPACE_RGB565_A5P:
+	 _rgb565_image_rotate(rotation, new_buffer, src_data,
+			      stride, has_alpha, 0, 0, width, height);
+	 break;
+      case EVAS_COLORSPACE_YCBCR422P601_PL:
+	 fputs("Colorspace YCBCR422P601_PL not handled\n", stderr);
+	 break;
+      case EVAS_COLORSPACE_YCBCR422P709_PL:
+	 fputs("Colorspace YCBCR422P709_PL not handled\n", stderr);
+	 break;
+     }
+
+   if ((rotation == ROTATE_90) || (rotation == ROTATE_270))
+     evas_object_image_size_set(image, height, width);
+
+   evas_object_image_data_update_add(image, 0, 0, width, height);
+   evas_object_image_data_copy_set(image, new_buffer);
+
+   free(new_buffer);
 }
diff --git a/include/evas/c_evas.pxd b/include/evas/c_evas.pxd
index 15cb763..978d31a 100644
--- a/include/evas/c_evas.pxd
+++ b/include/evas/c_evas.pxd
@@ -531,6 +531,18 @@ cdef extern from "Evas.h":
     void evas_object_text_style_pad_get(Evas_Object *obj, int *l, int *r, int *t, int *b)
 
 
+cdef extern from "evas_object_image_python_extras.h":
+    ctypedef enum Evas_Object_Image_Rotation:
+            ROTATE_NONE
+            ROTATE_90
+            ROTATE_180
+            ROTATE_270
+
+    int evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask, Evas_Object *surface, int x_mask, int y_mask, int x_surface, int y_surface)
+    void evas_object_image_rotate(Evas_Object *image, Evas_Object_Image_Rotation rotation)
+
+
+
 cdef public class Rect [object PyEvasRect, type PyEvasRect_Type]:
     cdef int x0, y0, x1, y1, cx, cy, _w, _h
 
diff --git a/include/evas_object_image_python_extras.h b/include/evas_object_image_python_extras.h
new file mode 100644
index 0000000..e1f9a2e
--- /dev/null
+++ b/include/evas_object_image_python_extras.h
@@ -0,0 +1,25 @@
+#ifndef __EVAS_OBJECT_IMAGE_PYTHON_EXTRAS__
+#define __EVAS_OBJECT_IMAGE_PYTHON_EXTRAS__
+
+typedef unsigned char DATA8;
+typedef unsigned short int DATA16;
+typedef unsigned int DATA32;
+
+typedef enum {
+    ROTATE_NONE,
+    ROTATE_90,
+    ROTATE_180,
+    ROTATE_270
+} Evas_Object_Image_Rotation;
+
+#define IMG_BYTE_SIZE_ARGB8888(stride, height, has_alpha)	\
+  ((stride) * (height) * 4)
+
+#define IMG_BYTE_SIZE_RGB565(stride, height, has_alpha)	\
+  ((stride) * (height) * (!(has_alpha) ? 2 : 3))
+
+void evas_object_image_rotate(Evas_Object *image, Evas_Object_Image_Rotation rotation);
+int evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask, Evas_Object *surface, int x_mask, int y_mask, int x_surface, int y_surface);
+
+
+#endif /* __EVAS_OBJECT_IMAGE_PYTHON_EXTRAS__ */

-- 
Python bindings for Evas



More information about the Pkg-e-commits mailing list