Package seamfinding
Class Picture
- java.lang.Object
-
- seamfinding.Picture
-
public class Picture extends Object
A digital picture represented as red-green-blue colorintpixels.
-
-
Field Summary
Fields Modifier and Type Field Description private BufferedImageimage
-
Constructor Summary
Constructors Constructor Description Picture()Constructs a null picture for subclassing purposes.Picture(int width, int height)Constructs an empty picture with the given width and height dimensions.Picture(BufferedImage image)Constructs a picture from the given image.Picture(File file)Constructs a picture from the given file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intget(int x, int y)Returns the 24-bit red-green-blue (RGB) color for the pixel (x, y).intheight()Returns the height of the picture.voidsave(File file)Writes the picture to the given file path.voidset(int x, int y, int rgb)Reassigns the 24-bit red-green-blue (RGB) color for the pixel (x, y).Picturetransposed()Returns a transposed view of this image where x and y accesses are reversed.intwidth()Returns the width of the picture.
-
-
-
Field Detail
-
image
private final BufferedImage image
-
-
Constructor Detail
-
Picture
Picture()
Constructs a null picture for subclassing purposes.
-
Picture
public Picture(BufferedImage image)
Constructs a picture from the given image.- Parameters:
image- the input image.
-
Picture
public Picture(int width, int height)Constructs an empty picture with the given width and height dimensions.- Parameters:
width- the horizontal dimension for the picture.height- the vertical dimension for the picture.
-
Picture
public Picture(File file) throws IOException
Constructs a picture from the given file.- Parameters:
file- the input file.- Throws:
IOException- if an error occurs during reading.
-
-
Method Detail
-
get
public int get(int x, int y)Returns the 24-bit red-green-blue (RGB) color for the pixel (x, y).- Parameters:
x- the x-index into the picture.y- the y-index into the picture.- Returns:
- the 24-bit red-green-blue (RGB) color for the pixel (x, y).
-
set
public void set(int x, int y, int rgb)Reassigns the 24-bit red-green-blue (RGB) color for the pixel (x, y).- Parameters:
x- the x-index into the picture.y- the y-index into the picture.rgb- the 24-bit red-green-blue (RGB) color for the pixel (x, y).
-
width
public int width()
Returns the width of the picture.- Returns:
- the width of the picture.
-
height
public int height()
Returns the height of the picture.- Returns:
- the height of the picture.
-
save
public void save(File file) throws IOException
Writes the picture to the given file path.- Parameters:
file- the file path.- Throws:
IOException- if an error occurs during writing.
-
transposed
public Picture transposed()
Returns a transposed view of this image where x and y accesses are reversed.- Returns:
- a transposed view of this image where x and y accesses are reversed.
-
-