Merge pull request #1107 from pnngocdoan/fix-mask

Add error check for pixelDensity in mask()
This commit is contained in:
Raphaël de Courville
2025-07-11 12:33:16 +02:00
committed by GitHub
+8
View File
@@ -866,6 +866,14 @@ public class PImage implements PConstants, Cloneable {
*/
public void mask(PImage img) {
img.loadPixels();
if (this.pixelWidth != img.pixelWidth || this.pixelHeight != img.pixelHeight) {
if (this.pixelDensity != img.pixelDensity) {
throw new IllegalArgumentException("mask() requires the mask image to have the same pixel size after adjusting for pixelDensity.");
}
else if (this.width != img.width || this.height != img.height) {
throw new IllegalArgumentException("mask() requires the mask image to have the same width and height.");
}
}
mask(img.pixels);
}