package NET.worlds.console; import java.awt.Canvas; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; import java.awt.Point; public class ScapePicCanvas extends Canvas { private static final long serialVersionUID = 927951584800056826L; private int hWnd; public void drawScapePicImage(ScapePicImage image, int xDst, int yDst, int xSrc, int ySrc, int width, int height) { if (this.hWnd == 0) { Point loc = this.locationInWindow(); Dimension size = this.getSize(); String title = this.getFrameTitle(); assert title != null; int hWndParent = Window.findWindow(title); assert hWndParent != 0; this.hWnd = Window.findChildWindow(hWndParent, loc.x, loc.y, size.width, size.height); assert this.hWnd != 0; } bitBlt(this.hWnd, image.getDIB(), xDst, yDst, xSrc, ySrc, width, height); } private String getFrameTitle() { for (Container c = this.getParent(); c != null; c = c.getParent()) { if (c instanceof Frame) { return ((Frame)c).getTitle(); } } return null; } private Point locationInWindow() { Point offset = this.location(); for (Container c = this.getParent(); c != null; c = c.getParent()) { Point move = c.location(); offset.translate(move.x, move.y); } return offset; } public static native void bitBlt(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7); }