Skip to content

Commit

Permalink
PlatformImage: Fix regression on getRGB()'s WritableRaster
Browse files Browse the repository at this point in the history
Same thing as drawPixels, scanlength has to be taken into account
here (still worlds faster than a standard getRGB call). Fixes
Dungeon Hunter 3's light spots on the ground, most notably at the
player's feet.
  • Loading branch information
AShiningRay committed Nov 16, 2024
1 parent de7ceb0 commit 8f71e52
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/org/recompile/mobile/PlatformImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,22 @@ public PlatformImage(Image image, int x, int y, int Width, int Height, int trans
platformImage = this;
}

public void getRGB(int[] rgbData, int offset, int scanlength, int x, int y, int width, int height)
{
public void getRGB(int[] rgbData, int offset, int scanlength, int x, int y, int width, int height)
{
// Temporary array to hold the raw pixel data
int[] tempData = new int[width * height];

raster = canvas.getRaster();
raster.getDataElements(x, y, width, height, rgbData);
//canvas.getRGB(x, y, width, height, rgbData, offset, scanlength);
raster.getDataElements(x, y, width, height, tempData);

// Copy the data into rgbData, taking scanlength into account
for (int row = 0; row < height; row++)
{
int sourceIndex = row * width;
int destIndex = offset + row * scanlength;

System.arraycopy(tempData, sourceIndex, rgbData, destIndex, width);
}
}

public int getARGB(int x, int y) { return canvas.getRGB(x, y); }
Expand Down

0 comments on commit 8f71e52

Please sign in to comment.