Class PImageAWT

java.lang.Object
processing.core.PImage
processing.awt.PImageAWT
All Implemented Interfaces:
Cloneable, PConstants

public class PImageAWT extends PImage
  • Constructor Details

    • PImageAWT

      public PImageAWT(Image img)
      Construct a new PImage from a java.awt.Image. This constructor assumes that you've done the work of making sure a MediaTracker has been used to fully download the data and that the img is valid.
      Parameters:
      img - assumes a MediaTracker has been used to fully download the data and the img is valid
  • Method Details

    • getImage

      public Image getImage()
      Use the getNative() method instead, which allows library interfaces to be written in a cross-platform fashion for desktop, Android, and others. This is still included for PGraphics objects, which may need the image.
      Overrides:
      getImage in class PImage
    • getNative

      public Object getNative()
      Returns a native BufferedImage from this PImage.
      Overrides:
      getNative in class PImage
    • resize

      public void resize(int w, int h)
      Description copied from class: PImage
      Resize the image to a new width and height. To make the image scale proportionally, use 0 as the value for the wide or high parameter. For instance, to make the width of an image 150 pixels, and change the height using the same proportion, use resize(150, 0).

      Even though a PGraphics is technically a PImage, it is not possible to rescale the image data found in a PGraphics. (It's simply not possible to do this consistently across renderers: technically infeasible with P3D, or what would it even do with PDF?) If you want to resize PGraphics content, first get a copy of its image data using the get() method, and call resize() on the PImage that is returned.
      Overrides:
      resize in class PImage
      Parameters:
      w - the resized image width
      h - the resized image height
      See Also: