diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/ScapePicCanvas.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/console/ScapePicCanvas.java')
| -rw-r--r-- | NET/worlds/console/ScapePicCanvas.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/NET/worlds/console/ScapePicCanvas.java b/NET/worlds/console/ScapePicCanvas.java new file mode 100644 index 0000000..44c8d7a --- /dev/null +++ b/NET/worlds/console/ScapePicCanvas.java @@ -0,0 +1,55 @@ +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); +} |