1 package gnu
.java
.awt
.peer
.x
;
3 import gnu
.x11
.Display
;
4 import gnu
.x11
.image
.ZPixmap
;
6 import java
.awt
.GraphicsEnvironment
;
7 import java
.awt
.image
.DataBuffer
;
10 * A DataBuffer implementation that is based on a ZPixmap. This is used
11 * as backing store for BufferedImages.
13 class ZPixmapDataBuffer
18 * The backing ZPixmap.
20 private ZPixmap zpixmap
;
23 * Creates a new ZPixmapDataBuffer with a specified width and height.
25 * @param d the X display
29 ZPixmapDataBuffer(int w
, int h
)
31 super(TYPE_BYTE
, w
* h
* 3); // TODO: Support non-24-bit-resolutions.
32 GraphicsEnvironment env
=
33 GraphicsEnvironment
.getLocalGraphicsEnvironment();
34 XGraphicsDevice dev
= (XGraphicsDevice
) env
.getDefaultScreenDevice();
35 Display d
= dev
.getDisplay();
36 zpixmap
= new ZPixmap(d
, w
, h
, d
.default_pixmap_format
);
40 * Creates a ZPixmapDataBuffer from an existing ZPixmap.
42 * @param zpixmap the ZPixmap to wrap
44 ZPixmapDataBuffer(ZPixmap zpixmap
)
46 super(TYPE_BYTE
, zpixmap
.get_data_length());
47 this.zpixmap
= zpixmap
;
51 public int getElem(int bank
, int i
)
53 return 0xff & zpixmap
.get_data_element(i
);
57 public void setElem(int bank
, int i
, int val
)
59 zpixmap
.set_data_element(i
, (byte) val
);