Package com.sksamuel.scrimage
Class MutableImage
- java.lang.Object
-
- com.sksamuel.scrimage.AwtImage
-
- com.sksamuel.scrimage.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 Summary
Constructors Constructor Description MutableImage(java.awt.image.BufferedImage awt)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contrastInPlace(double factor)
void
fillInPlace(java.awt.Color color)
Fills all pixels the given color on the existing image.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.void
overlayInPlace(java.awt.image.BufferedImage overlay, int x, int y)
Applies the given image over the current buffer.void
replaceTransparencyInPlace(java.awt.Color color)
void
rescaleInPlace(double factor)
Mutates this image by scaling all pixel values by the given factor (brightness in other words).void
setColor(int x, int y, Color color)
void
setColor(int offset, Color color)
void
setPixel(Pixel pixel)
-
Methods inherited from class com.sksamuel.scrimage.AwtImage
argb, argb, argbints, average, awt, bottomLeftPixel, bottomRightPixel, bytes, center, centreX, centreY, clone, col, color, colors, colours, contains, count, count, count, dimensions, empty, equals, exists, fastScaleAwt, fastScaleScrimage, forAll, forEach, forWriter, getType, hasAlpha, hashCode, hasTransparency, isFilled, iterator, offset, output, output, output, patch, patches, pixel, pixel, pixels, pixels, points, radius, ratio, rgb, rgb, rotateByRadians, row, rows, scale, stream, subpixel, toImmutableImage, toNewBufferedImage, topLeftPixel, topRightPixel, toString
-
-
-
-
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)
-
-