Пример #1
0
/* Callback for ios_load_random_image(), called after we have loaded an
   image from the iOS device's Photo Library.  See iosgrabimage.m.
 */
static void
ios_load_random_image_cb (void *uiimage, const char *filename, 
                          int width, int height, void *closure)
{
  struct pipe_closure *clo2 = (struct pipe_closure *) closure;
  Display *dpy = DisplayOfScreen (clo2->screen);
  XRectangle geom;
  XWindowAttributes xgwa;
  Window r;
  int x, y;
  unsigned int w, h, bbw, d;
  int rot = 0;

  XGetWindowAttributes (dpy, clo2->xwindow, &xgwa);
  XGetGeometry (dpy, clo2->drawable, &r, &x, &y, &w, &h, &bbw, &d);

  /* If the image is portrait and the window is landscape, or vice versa,
     rotate the image. The idea is to fill up as many pixels as possible,
     and assume the user will just rotate their phone until it looks right.
     This makes "decayscreen", etc. much more easily viewable.
   */
  if (get_boolean_resource (dpy, "rotateImages", "RotateImages")) {
    if ((width > height) != (w > h))
      rot = 5;
  }

  if (uiimage)
    {
      jwxyz_draw_NSImage_or_CGImage (DisplayOfScreen (clo2->screen), 
                                     clo2->drawable,
                                     True, uiimage, &geom,
                                     rot);
    }
  else  /* Probably means no images in the gallery. */
    {
      draw_colorbars (clo2->screen, xgwa.visual, clo2->drawable, xgwa.colormap,
                      0, 0, w, h);
      geom.x = geom.y = 0;
      geom.width = w;
      geom.height = h;
      filename = 0;
    }

  clo2->callback (clo2->screen, clo2->xwindow, clo2->drawable,
                  filename, &geom, clo2->closure);
  clo2->callback = 0;
  if (clo2->directory) free (clo2->directory);
  free (clo2);
}
Пример #2
0
/* Callback for ios_load_random_image(), called after we have loaded an
   image from the iOS device's Photo Library.  See iosgrabimage.m.
 */
static void
ios_load_random_image_cb (void *uiimage, const char *filename, void *closure)
{
  struct pipe_closure *clo2 = (struct pipe_closure *) closure;
  Display *dpy = DisplayOfScreen (clo2->screen);
  XRectangle geom;

  if (uiimage)
    {
      jwxyz_draw_NSImage_or_CGImage (DisplayOfScreen (clo2->screen), 
                                     clo2->drawable,
                                     True, uiimage, &geom,
                                     0);
    }
  else  /* Probably means no images in the gallery. */
    {
      XWindowAttributes xgwa;
      Window r;
      int x, y;
      unsigned int w, h, bbw, d;
      XGetWindowAttributes (dpy, clo2->xwindow, &xgwa);
      XGetGeometry (dpy, clo2->drawable, &r, &x, &y, &w, &h, &bbw, &d);
      draw_colorbars (clo2->screen, xgwa.visual, clo2->drawable, xgwa.colormap,
                      0, 0, w, h);
      geom.x = geom.y = 0;
      geom.width = w;
      geom.height = h;
      filename = 0;
    }

  clo2->callback (clo2->screen, clo2->xwindow, clo2->drawable,
                  filename, &geom, clo2->closure);
  clo2->callback = 0;
  if (clo2->directory) free (clo2->directory);
  free (clo2);
}