- unsigned int rpos=0, gpos=0, bpos=0, apos=0;
- unsigned int rmsk=0, gmsk=0, bmsk=0, amsk=0;
- unsigned int rsiz=0, gsiz=0, bsiz=0, asiz=0;
+ unsigned long rpos=0, gpos=0, bpos=0, apos=0;
+ unsigned long rmsk=0, gmsk=0, bmsk=0, amsk=0;
+ unsigned long rsiz=0, gsiz=0, bsiz=0, asiz=0;
+
+# ifdef HAVE_COCOA
+ if (filename) {
+ XRectangle geom;
+ Screen *screen = DefaultScreenOfDisplay (dpy);
+ Window window = RootWindowOfScreen (screen);
+ XWindowAttributes xgwa;
+ XGetWindowAttributes (dpy, window, &xgwa);
+ Pixmap pixmap =
+ XCreatePixmap (dpy, window, xgwa.width, xgwa.height, xgwa.depth);
+
+ if (osx_load_image_file (screen, window, pixmap, filename, &geom)) {
+ ximage = XGetImage (dpy, pixmap, geom.x, geom.y, geom.width, geom.height,
+ ~0L, ZPixmap);
+
+ /* Have to convert BGRA to ARGB */
+ if (ximage) {
+ for (y = 0; y < ximage->height; y++)
+ for (x = 0; x < ximage->width; x++) {
+ unsigned long p = XGetPixel (ximage, x, y);
+ unsigned long b = (p >> 24) & 0xFF;
+ unsigned long g = (p >> 16) & 0xFF;
+ unsigned long r = (p >> 8) & 0xFF;
+ unsigned long a = (p >> 0) & 0xFF;
+ p = (a << 24) | (r << 16) | (g << 8) | (b << 0);
+ XPutPixel (ximage, x, y, p);
+ }
+ }
+
+ }
+
+ XFreePixmap (dpy, pixmap);
+
+ if (! ximage)
+ fprintf (stderr, "%s: %s failed\n", progname, filename);
+ return ximage;
+ }
+# endif /* HAVE_COCOA */