Skip to content

Commit

Permalink
PlatformGraphics: copyArea should actually copy the requested area
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
AShiningRay committed Dec 19, 2024
1 parent b339a0e commit cd68c5f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/org/recompile/mobile/PlatformGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit cd68c5f

Please sign in to comment.