public AWTPicture(int[] b, int w, int h) {
data = b;
- Image img = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, cmodel, b, 0, w));
+ i = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, cmodel, b, 0, w));
MediaTracker mediatracker = new MediaTracker(new Canvas());
- mediatracker.addImage(img, 1);
+ mediatracker.addImage(i, 1);
try { mediatracker.waitForAll(); } catch (InterruptedException e) { }
- mediatracker.removeImage(img);
- this.i = img;
+ mediatracker.removeImage(i);
+ synchronized(AWTPixelBuffer.class) {
+ if (AWTPixelBuffer.component == null) {
+ AWTPixelBuffer.component = new Frame();
+ AWTPixelBuffer.component.setVisible(false);
+ AWTPixelBuffer.component.addNotify();
+ }
+ }
}
}
public int getHeight() { return i == null ? 0 : i.getHeight(null); }
public int getWidth() { return i == null ? 0 : i.getWidth(null); }
- public void setClip(int x, int y, int x2, int y2) { g.setClip(x, y, x2 - x, y2 - y); }
- public void drawPicture(Picture source, int x, int y) {
- drawPicture(source, x, y, x + source.getWidth(), y + source.getHeight(), 0, 0, source.getWidth(), source.getHeight());
+ public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
+ g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
+ g.drawImage(((AWTPicture)source).i, dx, dy, null);
+ g.setClip(0, 0, i.getWidth(null), i.getHeight(null));
}
- public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
- g.drawImage(((AWTPicture)source).i, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
- }
-
- public void fillRect(int x, int y, int x2, int y2, int argb) {
- // FEATURE: use an LRU cache for Color objects
+ /** implemented with java.awt 1.1's setXORMode() */
+ public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
+
+ // XOR the target region
+ g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
+ g.setColor(new Color(0x0, 0x0, 0x0));
+ g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
+
+ // blacken the area we want the glyph to cover
+ g.setPaintMode();
+ drawPicture(source, dx, dy, cx1, cy1, cx2, cy2);
+
+ // XOR back, turning black into the chosen rgb color
+ g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
+ g.setColor(new Color(0x0, 0x0, 0x0));
+ g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
+
+ // restore the graphics context
+ g.setPaintMode();
}
// FIXME: try to use os acceleration
public void setLocation() { window.setLocation(root.x, root.y); }
public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); }
public void setIcon(Picture i) { if (frame != null) frame.setIconImage(((AWTPicture)i).i); }
- public void setSize(int width, int height) { window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
+ public void _setSize(int width, int height) { window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
public void setInvisible(boolean b) { window.setVisible(!b); }
protected void _setMinimized(boolean b) { if (Log.on) Log.log(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); }
protected void _setMaximized(boolean b) {