1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);
}
|