-        buffer.alpha_composite(
-            image, (round(x), round(y)), source=(round(source_x), round(source_y))
-        )
+        x = round(x)
+        y = round(y)
+
+        if (
+            x <= buffer.width
+            and y <= buffer.height
+            and source_x <= image.width
+            and source_y <= image.height
+        ):
+            buffer.alpha_composite(image, (x, y), source=(source_x, source_y))