JBR-9043: Return null from getPlatformImageBytesForFormat for images with unknown extents on macOS

This commit is contained in:
Nikita Tsarev
2025-06-30 14:46:46 +02:00
parent 224651121f
commit 01a88fa82d

View File

@@ -186,13 +186,18 @@ public class CImage extends CFRetainedResource {
return getPlatformImageBytes(image);
}
int width = image.getWidth(null);
int height = image.getHeight(null);
BufferedImage bufferedImage;
if (image instanceof BufferedImage) {
bufferedImage = (BufferedImage) image;
} else {
int width = image.getWidth(null);
int height = image.getHeight(null);
if (width <= 0 || height <= 0) {
return null;
}
bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bufferedImage.createGraphics();
g2d.drawImage(image, 0, 0, null);