Source for gnu.gcj.xlib.Pixmap

   1: /* Copyright (C) 2000  Free Software Foundation
   2: 
   3:    This file is part of libgcj.
   4: 
   5: This software is copyrighted work licensed under the terms of the
   6: Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
   7: details.  */
   8: 
   9: package gnu.gcj.xlib;
  10: 
  11: /**
  12:  * An X11 Pixmap. A pixmap is an offscreen drawable that resides on
  13:  * the X server. A pixmap is bound to the screen it was created for.
  14:  *
  15:  * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
  16:  */
  17: public class Pixmap extends Drawable
  18: {
  19:   public Pixmap(XImage image, Screen screen)
  20:   {
  21:     this(screen.getRootWindow(),
  22:      image.getWidth(), image.getHeight(),
  23:      image.getDepth());
  24:     
  25:     /* FIXME: don't create a new GC all the time.  This might actually
  26:     not be as bad as initially believed.  The GC cache of Xlib makes
  27:     this operation less costly. */
  28:     GC gc = GC.create (this);
  29:     
  30:     gc.putImage(image, 0, 0, 0, 0, image.getWidth(), image.getHeight());
  31:   }
  32: 
  33:   public Pixmap(Drawable sameScreenAs, int width, int height, int depth)
  34:   {
  35:     super(sameScreenAs.getDisplay(), 
  36:       createXID(sameScreenAs, width, height, depth));
  37:   }
  38: 
  39:   protected static native int createXID(Drawable sameScreenAs,
  40:                     int width, int height, int depth);
  41: 
  42:   protected native void finalize();
  43: }