Class MutableImage

  • Direct Known Subclasses:
    ImmutableImage

    public class MutableImage
    extends AwtImage
    Extends [AwtImage] with methods that operate on a [BufferedImage] by mutating the buffer. All methods in this class should return void as they operate on the underlying image in place.

    This class cannot contain methods that result in a changed canvas size, as there is no way to mutate the size of a raster once created.

    • Constructor Detail

      • MutableImage

        public MutableImage​(java.awt.image.BufferedImage awt)
    • Method Detail

      • mapInPlace

        public void mapInPlace​(java.util.function.Function<Pixel,​java.awt.Color> mapper)
        Maps the pixels of this image into another image by applying the given function to each pixel.

        The function accepts three parameters: x,y,p where x and y are the coordinates of the pixel being transformed and p is the pixel at that location.

        Parameters:
        mapper - the function to transform pixel x,y with existing value p into new pixel value p' (p prime)
      • replaceTransparencyInPlace

        public void replaceTransparencyInPlace​(java.awt.Color color)
      • fillInPlace

        public void fillInPlace​(java.awt.Color color)
        Fills all pixels the given color on the existing image.
      • overlayInPlace

        public void overlayInPlace​(java.awt.image.BufferedImage overlay,
                                   int x,
                                   int y)
        Applies the given image over the current buffer.
      • setColor

        public void setColor​(int offset,
                             Color color)
      • setColor

        public void setColor​(int x,
                             int y,
                             Color color)
      • setPixel

        public void setPixel​(Pixel pixel)
      • rescaleInPlace

        public void rescaleInPlace​(double factor)
        Mutates this image by scaling all pixel values by the given factor (brightness in other words).
      • contrastInPlace

        public void contrastInPlace​(double factor)