Skip to content

Commit

Permalink
Fixed pixmap crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Oct 12, 2024
1 parent a39155a commit dd60085
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arc-core/src/arc/graphics/Pixmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ public void draw(Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight,
ByteBuffer pixels = this.pixels, otherPixels = pixmap.pixels;
int
startY = Math.max(dsty, 0),
endY = Math.min(dsty + Math.min(dstHeight, oheight), height),
endY = Math.min(Math.min(dsty + Math.min(dstHeight, oheight), height), dsty - srcy + oheight),
startX = Math.max(dstx, 0),
endX = Math.min(dstx + Math.min(dstWidth, owidth), width),
endX = Math.min(Math.min(dstx + Math.min(dstWidth, owidth), width), dstx - srcx + owidth),
offsetY = dsty - srcy,
scanX = Math.max(Math.max(srcx, -dstx), 0),
scanWidth = (endX - startX) * 4;
Expand Down
10 changes: 10 additions & 0 deletions arc-core/test/PixmapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ public void pixmapCreate(){
assertEquals(0, pix.get(0, 0));
}

@Test
public void pixmapBounds(){
int x = 176;

Pixmap base = new Pixmap(176, 269);
Pixmap crop = new Pixmap(176, 176);

crop.draw(base, 0, 176, x, x, 0, 0, x, x, true);
}

static Rect rect = new Rect();
static Vec2 v1 = new Vec2(), v2 = new Vec2();

Expand Down

0 comments on commit dd60085

Please sign in to comment.