1:
37:
38: package ;
39:
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47:
48: public class GtkVolatileImage extends VolatileImage
49: {
50: int width, height;
51: private ImageCapabilities caps;
52:
53: final GtkComponentPeer component;
54:
55:
58: long nativePointer;
59:
60: native long init(GtkComponentPeer component, int width, int height);
61:
62: native void destroy(long pointer);
63:
64: native int[] nativeGetPixels(long pointer);
65: public int[] getPixels()
66: {
67: return nativeGetPixels(nativePointer);
68: }
69:
70: native void nativeCopyArea(long pointer, int x, int y, int w, int h, int dx,
71: int dy );
72: public void copyArea(int x, int y, int w, int h, int dx, int dy)
73: {
74: nativeCopyArea(nativePointer, x, y, w, h, dx, dy);
75: }
76:
77: native void nativeDrawVolatile(long pointer, long srcPtr, int x, int y,
78: int w, int h );
79: public void drawVolatile(long srcPtr, int x, int y, int w, int h )
80: {
81: nativeDrawVolatile(nativePointer, srcPtr, x, y, w, h);
82: }
83:
84: public GtkVolatileImage(GtkComponentPeer component,
85: int width, int height, ImageCapabilities caps)
86: {
87: this.width = width;
88: this.height = height;
89: this.caps = caps;
90: this.component = component;
91: nativePointer = init( component, width, height );
92: }
93:
94: public GtkVolatileImage(int width, int height, ImageCapabilities caps)
95: {
96: this(null, width, height, caps);
97: }
98:
99: public GtkVolatileImage(int width, int height)
100: {
101: this(null, width, height, null);
102: }
103:
104: public void finalize()
105: {
106: dispose();
107: }
108:
109: public void dispose()
110: {
111: destroy(nativePointer);
112: }
113:
114: public BufferedImage getSnapshot()
115: {
116: CairoSurface cs = new CairoSurface( width, height );
117: cs.setPixels( getPixels() );
118: return CairoSurface.getBufferedImage( cs );
119: }
120:
121: public Graphics getGraphics()
122: {
123: return createGraphics();
124: }
125:
126: public Graphics2D createGraphics()
127: {
128: return new VolatileImageGraphics( this );
129: }
130:
131: public int validate(GraphicsConfiguration gc)
132: {
133: return VolatileImage.IMAGE_OK;
134: }
135:
136: public boolean contentsLost()
137: {
138: return false;
139: }
140:
141: public ImageCapabilities getCapabilities()
142: {
143: return caps;
144: }
145:
146: public int getWidth()
147: {
148: return width;
149: }
150:
151: public int getHeight()
152: {
153: return height;
154: }
155:
156: public int getWidth(java.awt.image.ImageObserver observer)
157: {
158: return width;
159: }
160:
161: public int getHeight(java.awt.image.ImageObserver observer)
162: {
163: return height;
164: }
165:
166: public Object getProperty(String name, ImageObserver observer)
167: {
168: return null;
169: }
170: }