Update of /cvsroot/fink/dists/10.4/unstable/main/finkinfo/graphics
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14925

Modified Files:
        pil-systempython25.info 
Added Files:
        TkAlpha-Imaging-1.1.6.patch 
Log Message:
Patch file no longer available from the asymptote server. Add it to cvs.

--- NEW FILE: TkAlpha-Imaging-1.1.6.patch ---
diff -ru Imaging-1.1.6/Tk/tkImaging.c Imaging-1.1.6J/Tk/tkImaging.c
--- Imaging-1.1.6/Tk/tkImaging.c        2006-12-03 04:37:29.000000000 -0700
+++ Imaging-1.1.6J/Tk/tkImaging.c       2007-11-14 20:22:02.000000000 -0700
@@ -48,6 +48,9 @@
    for the Tcl_CreateCommand command. */
 #define USE_COMPAT_CONST
 
+#define CONST84 const
+#define CONST84_RETURN const
+
 #include "tk.h"
 
 #include "Imaging.h"
@@ -76,6 +79,13 @@
     Imaging im;
     Tk_PhotoHandle photo;
     Tk_PhotoImageBlock block;
+    int renderalpha;
+    char *max_alpha_area;
+    int maxarea;
+    Tk_PhotoImageBlock run;
+
+    unsigned char back[3]={255,255,255};
+    char *background=getenv("PIL_BACKGROUND");
 
     if (argc != 3) {
         Tcl_AppendResult(interp, "usage: ", argv[0],
@@ -117,6 +127,15 @@
 
     /* Mode */
 
+#ifndef MAX_ALPHA_AREA
+#define MAX_ALPHA_AREA 10000;
+#endif
+    
+    maxarea=MAX_ALPHA_AREA;
+    max_alpha_area=getenv("PIL_MAX_ALPHA_AREA");
+    if(max_alpha_area != NULL) maxarea=atoi(max_alpha_area);
+    renderalpha=(maxarea < 0) ? 1 : (im->xsize*im->ysize < maxarea);
+    
     if (strcmp(im->mode, "1") == 0 || strcmp(im->mode, "L") == 0) {
        block.pixelSize = 1;
        block.offset[0] = block.offset[1] = block.offset[2] = 0;
@@ -125,7 +144,10 @@
        block.offset[0] = 0;
        block.offset[1] = 1;
        block.offset[2] = 2;
-       block.offset[3] = 0; /* no alpha (or reserved, under 8.2) */
+       if(renderalpha && strcmp(im->mode,"RGBA") == 0)
+       block.offset[3] = 3; /* alpha (or reserved, under 8.2) */
+       else
+       block.offset[3] = 0; /* no alpha */
     } else {
         Tcl_AppendResult(interp, "Bad mode", (char*) NULL);
        return TCL_ERROR;
@@ -140,15 +162,30 @@
                     src_yoffset * im->linesize +
                     src_xoffset * im->pixelsize;
 #endif
-
-    if (strcmp(im->mode, "RGBA") == 0) {
-        /* Copy non-transparent pixels to photo image */
+    if (!renderalpha && strcmp(im->mode, "RGBA") == 0) {
+        int bytes =block.height*block.pitch;
+       unsigned char *pixelPtr;
         int x, y;
-        Tk_PhotoImageBlock run;
+       int j;
+       
+       /* Buffer image block for pseudo-antialiasing */
+        if (bytes <= 0)
+         bytes=1;
+       pixelPtr=(unsigned char *) malloc(bytes);
+       if (!pixelPtr) {
+         Tcl_AppendResult(interp, "bad display memory", (char*) NULL);
+         return TCL_ERROR;
+        }
 
-        /* Clear current contents */
-        Tk_PhotoBlank(photo);
+      /* Copy non-transparent pixels to photo image */
 
+       if(background && strlen(background) == 6) {
+         for(j=0; j < 3; ++j) {
+           char h[3]={background[2*j],background[2*j+1],0};
+           back[j]=strtol(h,NULL,16);
+         }
+       }
+       
         /* Setup run descriptor */
         run.height = 1;
         run.pitch = block.pitch;
@@ -161,13 +198,19 @@
         /* Copy opaque runs to photo image */
         for (y = 0; y < block.height; y++) {
             unsigned char* p = block.pixelPtr + y*block.pitch;
-            unsigned char* s = p;
+            unsigned char* q = pixelPtr + y*block.pitch;
+            unsigned char* s = q;
             int   w = 0;
             for (x = 0; x < block.width; x++) {
                 if (p[3]) {
                     /* opaque: add pixel to current run */
-                    if (w == 0)
-                        s = p;
+                 double opacity=p[3]/255.0;
+                 double transparency=1.0-opacity;
+                 q[0]=(int) (opacity*p[0]+transparency*back[0]);
+                 q[1]=(int) (opacity*p[1]+transparency*back[1]);
+                 q[2]=(int) (opacity*p[2]+transparency*back[2]);
+                 if (w == 0)
+                        s = q;
                     w = w + 1;
                 } else if (s) {
                     /* copy run to photo image */
@@ -179,6 +222,7 @@
                     w = 0;
                 }
                 p += block.pixelSize;
+                q += block.pixelSize;
             }
             if (w > 0) {
                 /* copy final run, if any */
@@ -188,10 +232,15 @@
           }
         }
 
-    } else
-
-        /* Copy opaque block to photo image, and leave the rest to TK */
-        Tk_PhotoPutBlock(photo, &block, 0, 0, block.width, block.height);
+    } else {
+      /* Copy block to photo image, and leave the rest to TK */
+      Tk_PhotoPutBlock(photo, &block, 0, 0, block.width, block.height);
+    
+      if (strcmp(im->mode, "RGBA") == 0)
+        /* Tk workaround: we need apply ToggleComplexAlphaIfNeeded */
+        /* (fixed in Tk 8.5a3) */
+        Tk_PhotoSetSize(photo, block.width, block.height);
+    }
 
     return TCL_OK;
 }
diff -ru Imaging-1.1.6/_imagingtk.c Imaging-1.1.6J/_imagingtk.c
--- Imaging-1.1.6/_imagingtk.c  2006-12-03 04:51:25.000000000 -0700
+++ Imaging-1.1.6J/_imagingtk.c 2007-11-14 17:42:54.000000000 -0700
@@ -17,6 +17,9 @@
 #include "Python.h"
 #include "Imaging.h"
 
+#define CONST84 const
+#define CONST84_RETURN const
+
 #include "tk.h"
 
 /* must link with Tk/tkImaging.c */

Index: pil-systempython25.info
===================================================================
RCS file: 
/cvsroot/fink/dists/10.4/unstable/main/finkinfo/graphics/pil-systempython25.info,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pil-systempython25.info     29 Mar 2009 05:57:25 -0000      1.2
+++ pil-systempython25.info     26 Jun 2009 06:08:02 -0000      1.3
@@ -1,6 +1,6 @@
 Package: pil-systempython25
 Version: 1.1.6
-Revision: 1
+Revision: 2
 Distribution: 10.5
 Description: Python Imaging Library 
 DescDetail: <<
@@ -10,8 +10,6 @@
 <<
 Source: http://effbot.org/downloads/Imaging-%v.tar.gz
 Source-MD5: 3a9b5c20ca52f0a9900512d2c7347622
-Source2: 
http://asymptote.svn.sourceforge.net/viewvc/asymptote/trunk/asymptote/patches/TkAlpha-Imaging-1.1.6.patch
-Source2-MD5: 72f870774db731ffbbd4058c09e1f1e2
 BuildDepends: libpng3, libjpeg, freetype219, fink (>= 0.24.12)
 Depends: libpng3-shlibs, libjpeg-shlibs, freetype219-shlibs
 NoSetCPPFLAGS: true
@@ -23,7 +21,7 @@
 PatchFile-MD5: 91f1a62d996f63771e4e0bf01e128231
 PatchScript: <<
   sed 's|@PREFIX@|%p|g' < %{PatchFile} | patch -p1
-  patch -p1 < ../TkAlpha-Imaging-1.1.6.patch  
+  patch -p1 < %a/TkAlpha-Imaging-1.1.6.patch  
 <<
 CompileScript: <<
  ARCHFLAGS=" " /usr/bin/python  setup.py build


------------------------------------------------------------------------------
_______________________________________________
Fink-commits mailing list
[email protected]
http://news.gmane.org/gmane.os.apple.fink.cvs

Reply via email to