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

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


The following commit has been merged in the upstream-vcs branch:
commit 7e1f1c5f688fdcb93a5d877c896f0016e71d924a
Author: barbieri <barbieri>
Date:   Wed Mar 12 14:30:38 2008 +0000

    Bugfixes from Leonardo Sobral.

diff --git a/evas/evas_object_image_rotate.c b/evas/evas_object_image_rotate.c
index 0553a83..1a0b52f 100644
--- a/evas/evas_object_image_rotate.c
+++ b/evas/evas_object_image_rotate.c
@@ -10,10 +10,40 @@ _calc_stride(int w)
    int pad;
 
    pad = w % 4;
-   if (!pad)  return w;
+   if (!pad) return w;
    else return w + 4 - pad;
 }
 
+static inline int
+_calc_image_byte_size(Evas_Colorspace colorspace, Rotation rotation,
+                      int stride, int w, int h, unsigned char has_alpha)
+{
+    int dst_stride, dst_height;
+    int image_byte_size;
+
+    if (rotation == ROTATE_90 || rotation == ROTATE_270) {
+        dst_stride = _calc_stride(h);
+        dst_height = w;
+    } 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;
+}
+
 static void
 _data8_image_rotate_90(char *dst, const char *src,
                        int dst_stride, int src_stride,
@@ -279,42 +309,48 @@ _rgb565_image_rotate(Rotation rotation,
     char *dst_alpha;
     const char *src_alpha;
 
-    if(has_alpha) {
-        dst_alpha = &dst[src_stride * h * 2];
-        src_alpha = &src[h * w * 2];
-    }
+    if (has_alpha)
+        src_alpha = src + src_stride * h * 2;
 
-    switch(rotation) {
+    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)
+            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 = _calc_stride(src_stride);
+            dst_stride = src_stride;
             _data16_image_rotate_180(dst, src,
                                      dst_stride, src_stride,
                                      out_x, out_y, w, h);
-            if(has_alpha)
+            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)
+            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;
     }
 }
 
@@ -345,6 +381,8 @@ _argb8888_image_rotate(Rotation rotation,
                                      dst_stride, src_stride,
                                      out_x, out_y, w, h);
             break;
+        case ROTATE_NONE:
+	    break;
     }
 }
 
@@ -362,33 +400,30 @@ evas_object_image_rotate(Evas_Object *image, Rotation rotation)
     stride = evas_object_image_stride_get(image);
     has_alpha = evas_object_image_alpha_get(image);
 
-    switch(colorspace) {
-        case EVAS_COLORSPACE_ARGB8888:
-            image_byte_size = IMG_BYTE_SIZE_ARGB8888(stride, height, stride);
-            if(image_byte_size <= 0)
-                return;
+    image_byte_size = _calc_image_byte_size(colorspace, rotation,
+                                            stride, width,
+                                            height, has_alpha);
+    if (image_byte_size <= 0)
+        return;
 
-            new_buffer = (char*) malloc(image_byte_size);
-            src_data = (char*) evas_object_image_data_get(image, FALSE);
+    new_buffer = malloc(image_byte_size);
+    src_data = evas_object_image_data_get(image, FALSE);
 
-            /* dst_stride set to original height */
+    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:
-            image_byte_size = IMG_BYTE_SIZE_RGB565(stride, height, stride);
-            if(image_byte_size <= 0)
-                return;
-
-            new_buffer = (char*) malloc(image_byte_size);
-            src_data = (char*) evas_object_image_data_get(image, FALSE);
-
-            /* dst_stride set to original height */
             _rgb565_image_rotate(rotation, new_buffer, src_data,
                                  stride, has_alpha, 0, 0, width, height);
             break;
-        default:
-            return;
+        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)

-- 
Python bindings for Evas



More information about the Pkg-e-commits mailing list