Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/imlib2

Dir     : e17/libs/imlib2/src


Modified Files:
        Imlib2.h api.c 


Log Message:


roatate from buffer patch

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/imlib2/src/Imlib2.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -3 -r1.53 -r1.54
--- Imlib2.h    28 Aug 2001 12:50:15 -0000      1.53
+++ Imlib2.h    20 Apr 2004 07:04:50 -0000      1.54
@@ -417,6 +417,11 @@
 
 /* rotation/skewing */
    Imlib_Image imlib_create_rotated_image(double angle);
+
+/* rotation from buffer to context (without copying)*/
+   void imlib_rotate_image_from_buffer(double angle, 
+                                      Imlib_Image source_image);
+
    void imlib_blend_image_onto_image_at_angle(Imlib_Image source_image,
                                               char merge_alpha, int source_x,
                                               int source_y, int source_width,
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/imlib2/src/api.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -3 -r1.95 -r1.96
--- api.c       15 Feb 2004 01:58:23 -0000      1.95
+++ api.c       20 Apr 2004 07:04:50 -0000      1.96
@@ -3360,6 +3360,77 @@
    return (Imlib_Image) im;
 }
 
+void imlib_rotate_image_from_buffer(double angle,
+                       Imlib_Image source_image)
+{
+   ImlibImage         *im, *im_old;
+   int                 x, y, dx, dy, sz;
+   double              x1, y1, d;
+
+   if (!ctx)
+      ctx = imlib_context_new();
+   // source image (to rotate)
+   CHECK_PARAM_POINTER_RETURN("imlib_rotate_image_from_buffer", "source_image",
+                              source_image, NULL);
+   CAST_IMAGE(im_old, source_image);
+
+   // current context image
+   CHECK_PARAM_POINTER_RETURN("imlib_rotate_image_from_buffer", "image",
+                              ctx->image, NULL);
+   CAST_IMAGE(im, ctx->image);
+
+   if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load))
+    im_old->loader->load(im_old, NULL, 0, 1);
+
+   if (!(im_old->data)) return;
+
+   d = hypot((double)(im_old->w + 4), (double)(im_old->h + 4)) / sqrt(2.0);
+
+   x1 = (double)(im_old->w) / 2.0 - sin(angle + atan(1.0)) * d;
+   y1 = (double)(im_old->h) / 2.0 - cos(angle + atan(1.0)) * d;
+
+   sz = (int)(d * sqrt(2.0));
+   x = (int)(x1 * _ROTATE_PREC_MAX);
+   y = (int)(y1 * _ROTATE_PREC_MAX);
+   dx = (int)(cos(angle) * _ROTATE_PREC_MAX);
+   dy = -(int)(sin(angle) * _ROTATE_PREC_MAX);
+
+   if ( (im->w != im->h) || ((im->w < sz) && (im->h < sz)))  
+     return; // If size is wrong
+   else sz = im->w; // update sz with real width
+
+   /* Not neccesary 'cause destination is context
+      im = __imlib_CreateImage(sz, sz, NULL);
+      im->data = calloc(sz * sz, sizeof(DATA32));
+      if (!(im->data))
+        {
+               __imlib_FreeImage(im);
+           return;
+          }*/
+
+   if (ctx->anti_alias)
+     {
+#ifdef DO_MMX_ASM
+        if (__imlib_get_cpuid() & CPUID_MMX)
+           __imlib_mmx_RotateAA(im_old->data, im->data, im_old->w, im_old->w,
+                                im_old->h, im->w, sz, sz, x, y, dx, dy, -dy,
+                                dx);
+        else
+#endif
+           __imlib_RotateAA(im_old->data, im->data, im_old->w, im_old->w,
+                            im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx);
+     }
+   else
+     {
+        __imlib_RotateSample(im_old->data, im->data, im_old->w, im_old->w,
+                             im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx);
+     }
+   SET_FLAG(im->flags, F_HAS_ALPHA);
+
+
+  return;
+}
+
 void
 imlib_blend_image_onto_image_at_angle(Imlib_Image source_image,
                                       char merge_alpha, int source_x,




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to