Class SwingImage

java.lang.Object
ch.epfl.cs107.play.window.swing.SwingImage
All Implemented Interfaces:
Image

public final class SwingImage extends Object implements Image
Swing implementation of an image.
  • Constructor Details

    • SwingImage

      public SwingImage(Image image, RegionOfInterest roi, boolean removeBackground)
      Creates an image from specified image.
      Parameters:
      image - (java.awt.Image): valid image to be copied, not null
      roi - (RegionOfInterest): rectangle of interest in the image, may be null
      removeBackground - (boolean): which indicate if need to remove an uniform background
    • SwingImage

      public SwingImage(InputStream stream, RegionOfInterest roi, boolean removeBackground) throws IOException
      Creates an image from specified image input stream.
      Parameters:
      stream - (InputStream): valid image input stream, not null
      roi - (RegionOfInterest): rectangle of interest in the image, may be null
      removeBackground - (boolean): which indicate if need to remove an uniform background
      Throws:
      IOException - if an error occurs during reading
  • Method Details

    • getWidth

      public int getWidth()
      Specified by:
      getWidth in interface Image
      Returns:
      (int): width, in pixels
    • getHeight

      public int getHeight()
      Specified by:
      getHeight in interface Image
      Returns:
      (int): height, in pixels
    • getRGB

      public int getRGB(int r, int c)
      Description copied from interface: Image
      Color getter of the pixel at the given row and column
      Specified by:
      getRGB in interface Image
      Parameters:
      r - (int): given row
      c - (int): given column
      Returns:
      (int): RGB color of the pixel at row r and column c as a int value