I have a function that accepts an image and rounds it, like so:
public static Image roundImage(Image img) {
int width = img.getWidth();
Image roundMask = Image.createImage(img.getWidth(), img.getHeight(), 0xff000000);
Graphics gr = roundMask.getGraphics();
gr.setColor(0xffffff);
gr.fillArc(0, 0, width, width, 0, 360);
Object mask = roundMask.createMask();
img = img.applyMask(mask);
return img;
}
This works great for images, but if I pass FontImage to it, the function throws an exception: java.lang.RuntimeException: Unsupported Operation. How can I check whether masking is a supported operation? I want to avoid changing the application logic.
FontImage is a requiresDrawImage which is unique. You can convert it to a regular image or even to an encoded image using toImage() or toEncodedImage() respectively.
For this use case a regular image will be better/faster so toImage() should work best.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With