From dd60085a9d91b5368bd0e3bec47e7175b7930ffa Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 11 Oct 2024 23:42:55 -0400 Subject: [PATCH] Fixed pixmap crash --- arc-core/src/arc/graphics/Pixmap.java | 4 ++-- arc-core/test/PixmapTest.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arc-core/src/arc/graphics/Pixmap.java b/arc-core/src/arc/graphics/Pixmap.java index b8734ab6..5240e6ae 100644 --- a/arc-core/src/arc/graphics/Pixmap.java +++ b/arc-core/src/arc/graphics/Pixmap.java @@ -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; diff --git a/arc-core/test/PixmapTest.java b/arc-core/test/PixmapTest.java index 75e24928..9be58220 100644 --- a/arc-core/test/PixmapTest.java +++ b/arc-core/test/PixmapTest.java @@ -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();