From cd68c5fa6aac65b4de1f1eb5033c86f2edd577f0 Mon Sep 17 00:00:00 2001 From: AShiningRay Date: Thu, 19 Dec 2024 12:46:56 -0300 Subject: [PATCH] PlatformGraphics: copyArea should actually copy the requested area Using getSubImage here causes issues, as the returned image will be referencing the original image's data. Hence, not actually a copy. Fixes #4 (Ninja Prophecy and scrolling on Clickteam Fusion games) --- src/org/recompile/mobile/PlatformGraphics.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/org/recompile/mobile/PlatformGraphics.java b/src/org/recompile/mobile/PlatformGraphics.java index d6abca33..d88514bc 100644 --- a/src/org/recompile/mobile/PlatformGraphics.java +++ b/src/org/recompile/mobile/PlatformGraphics.java @@ -109,7 +109,16 @@ public void copyArea(int subx, int suby, int subw, int subh, int x, int y, int a x = AnchorX(x, subw, anchor); y = AnchorY(y, subh, anchor); - BufferedImage sub = canvas.getSubimage(subx, suby, subw, subh); + BufferedImage sub = new BufferedImage(subw, subh, BufferedImage.TYPE_INT_ARGB); + + // Copy the pixels from the source area to the new image. getSubImage() makes both images contain the same data reference + for (int i = 0; i < subw; i++) + { + for (int j = 0; j < subh; j++) + { + sub.setRGB(i, j, canvas.getRGB(subx + i, suby + j)); + } + } gc.drawImage(sub, x, y, null); }