General advice: when you ask a question, it is useful to show what you have tried, and what went wrong, it avoid to loose time to give answers you already know...
You saw it was deprecated (didn't know...), but in general, when deprecating a method, JavaDoc often gives an alternative to use. From the source code:
- /**
- * Use the getNative() method instead, which allows library interfaces to be
- * written in a cross-platform fashion for desktop, Android, and others.
- */
- @Deprecated
- public Image getImage() { // ignore
- return (Image) getNative();
- }
- /**
- * Returns a native BufferedImage from this PImage.
- */
- public Object getNative() { // ignore
- loadPixels();
- int type = (format == RGB) ?
- BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
- BufferedImage image = new BufferedImage(width, height, type);
- WritableRaster wr = image.getRaster();
- wr.setDataElements(0, 0, width, height, pixels);
- return image;
- }