Enlightenment CVS committal

Author  : kwo
Project : e17
Module  : libs/imlib2

Dir     : e17/libs/imlib2/src/lib


Modified Files:
        api.c grab.c grab.h 


Log Message:
imlib_copy_drawable_to_image() and
imlib_create_image_from_drawable():
- When mask is set to (Pixmap)1 (and the context drawable is a window)
  the window shape is used for image alpha.
      
imlib_create_image_from_drawable() and
imlib_create_scaled_image_from_drawable():
- Set image F_HAS_ALPHA alpha flag according to whether or not useful image
  alpha data was generated.


===================================================================
RCS file: /cvs/e/e17/libs/imlib2/src/lib/api.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- api.c       18 May 2006 17:36:08 -0000      1.6
+++ api.c       18 May 2006 19:23:26 -0000      1.7
@@ -2098,11 +2098,12 @@
  * @return a valid image, otherwise NULL.
  * 
  * Return an image (using the mask @p mask to determine the alpha channel)
- * from the current drawable. If the mask is 0 it will not create a
- * useful alpha channel in the image. It will create an image from the
+ * from the current drawable.
+ * If @p mask is 0 it will not create a useful alpha channel in the image.
+ * If @p mask is 1 the mask will be set to the shape mask of the drawable.
+ * It will create an image from the
  * (@p x, @p y, @p width , @p height) rectangle in the drawable. If @p
- * need_to_grab_x
- * is 1 it will also grab the X Server to avoid possible race
+ * need_to_grab_x is 1 it will also grab the X Server to avoid possible race
  * conditions in grabbing. If you have not already grabbed the server
  * you MUST set this to 1. Imlib2 returns a valid image handle on
  * success or NULL on failure. 
@@ -2118,13 +2119,21 @@
    if (!ctx)
       ctx = imlib_context_new();
    if (mask)
-      domask = 1;
+     {
+        domask = 1;
+        if (mask == (Pixmap)1)
+           mask = None;
+     }
    im = __imlib_CreateImage(width, height, NULL);
    im->data = malloc(width * height * sizeof(DATA32));
    __imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height, ctx->display,
                               ctx->drawable, mask, ctx->visual, ctx->colormap,
-                              ctx->depth, x, y, width, height, domask,
+                              ctx->depth, x, y, width, height, &domask,
                               need_to_grab_x);
+   if (domask)
+      SET_FLAG(im->flags, F_HAS_ALPHA);
+   else
+      UNSET_FLAG(im->flags, F_HAS_ALPHA);
    return (Imlib_Image) im;
 }
 
@@ -2265,8 +2274,12 @@
    __imlib_GrabDrawableToRGBA(im->data, 0, 0, destination_width,
                               source_height, ctx->display, p, m,
                               ctx->visual, ctx->colormap, ctx->depth, 0, 0,
-                              destination_width, destination_height, domask,
+                              destination_width, destination_height, &domask,
                               need_to_grab_x);
+   if (domask)
+      SET_FLAG(im->flags, F_HAS_ALPHA);
+   else
+      UNSET_FLAG(im->flags, F_HAS_ALPHA);
    XFreePixmap(ctx->display, p);
    if (m != None)
      {
@@ -2290,10 +2303,11 @@
  * @param need_to_grab_x Grab flag.
  * @return A char.
  * 
- * Grabs a section of the current drawable (optionally using the
- * pixmap @p mask
+ * Grabs a section of the current drawable (optionally using the pixmap @p mask
  * provided as a corresponding mask for that drawable - if @p mask is 0
- * this is not used). It grabs the (@p x, @p y, @p width, @p height) rectangle 
and
+ * this is not used).
+ * If @p mask is 1 the mask will be set to the shape mask of the drawable.
+ * It grabs the (@p x, @p y, @p width, @p height) rectangle and
  * places it at the destination (@p destination_x, @p destination_y) location 
in the current image. If
  * @p need_to_grab_x is 1 it will grab and ungrab the server whilst doing
  * this - you need to do this if you have not already grabbed the
@@ -2314,7 +2328,11 @@
    CHECK_PARAM_POINTER_RETURN("imlib_copy_drawable_to_image", "image",
                               ctx->image, 0);
    if (mask)
-      domask = 1;
+     {
+        domask = 1;
+        if (mask == (Pixmap)1)
+           mask = None;
+     }
    CAST_IMAGE(im, ctx->image);
 
    if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -2365,7 +2383,7 @@
                                      im->w, im->h, ctx->display,
                                      ctx->drawable, mask, ctx->visual,
                                      ctx->colormap, ctx->depth, x, y, width,
-                                     height, domask, need_to_grab_x);
+                                     height, &domask, need_to_grab_x);
 }
 #endif
 
===================================================================
RCS file: /cvs/e/e17/libs/imlib2/src/lib/grab.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- grab.c      13 Jan 2006 21:27:36 -0000      1.3
+++ grab.c      18 May 2006 19:23:26 -0000      1.4
@@ -461,11 +461,12 @@
 __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
                            Display * d, Drawable p, Pixmap m, Visual * v,
                            Colormap cm, int depth, int x, int y,
-                           int w, int h, char domask, char grab)
+                           int w, int h, char *pdomask, char grab)
 {
    XErrorHandler       prev_erh = NULL;
    XWindowAttributes   xatt, ratt;
    char                is_pixmap = 0, created_mask = 0, is_shm = 0, is_mshm = 
0;
+   char                domask;
    int                 i;
    int                 src_x, src_y, src_w, src_h, origw, origh;
    int                 width, height, clipx, clipy;
@@ -474,6 +475,7 @@
    static signed char  x_does_shm = -1;
    XColor              cols[256];
 
+   domask = (pdomask) ? *pdomask : 0;
    /* FIXME: oh isnt used - i wonder if there's a bug looming... */
    oh = 0;
    origw = w;
@@ -785,6 +787,10 @@
       XFreePixmap(d, m);
    if (mxim)
       XDestroyImage(mxim);
+
+   if ((pdomask) && (!m) && (xatt.depth != 32))
+      *pdomask = 0;
+
    return 1;
 }
 
===================================================================
RCS file: /cvs/e/e17/libs/imlib2/src/lib/grab.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- grab.h      9 Apr 2006 08:12:51 -0000       1.2
+++ grab.h      18 May 2006 19:23:26 -0000      1.3
@@ -7,7 +7,7 @@
 __imlib_GrabDrawableToRGBA(DATA32 *data, int ox, int oy, int ow, int oh,
                           Display *d, Drawable p, Pixmap m, Visual *v,
                           Colormap cm, int depth, int x, int y,
-                          int w, int h, char domask, char grab);
+                          int w, int h, char *domask, char grab);
 __hidden void
 __imlib_GrabXImageToRGBA(DATA32 *data, int ox, int oy, int ow, int oh, 
                         Display *d, XImage *xim, XImage *mxim, Visual *v,




-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to