Package com.microej.painter
Class TransformedImagePainter
- java.lang.Object
-
- com.microej.painter.TransformedImagePainter
-
public class TransformedImagePainter extends Object
TheTransformedImagePainterclass provides static methods to draw an image with a transformation defined by aMatrix.In all the provided drawing APIs, the image pixels color is multiplied with the graphics context's color.
The drawings can be performed either using the bilinear algorithm or the nearest neighbor algorithm. The bilinear algorithm produces a prettier rendering but takes more time.
-
-
Constructor Summary
Constructors Constructor Description TransformedImagePainter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddrawImage(GraphicsContext gc, Image image, Matrix matrix, boolean bilinear)Draws the given image with a transformation defined by the given matrix.static voiddrawImage(GraphicsContext gc, Image image, Matrix matrix, boolean bilinear, int alpha, BlendMode blendMode)Draws the given image with a transformation defined by the given matrix.static voiddrawImageRegion(GraphicsContext gc, Image image, int regionX, int regionY, int regionWidth, int regionHeight, Matrix matrix, boolean bilinear, int alpha, BlendMode blendMode)Draws a region of the given image with a transformation defined by the given matrix.
-
-
-
Method Detail
-
drawImage
public static void drawImage(GraphicsContext gc, Image image, Matrix matrix, boolean bilinear)
Draws the given image with a transformation defined by the given matrix.Equivalent to calling
drawImage(GraphicsContext, Image, Matrix, boolean, int, BlendMode)withGraphicsContext.OPAQUEas alpha andBlendMode.SRC_OVERas blend mode.- Parameters:
gc- the graphics context to use.image- the image to render.matrix- the transformation matrix to apply.bilinear- whether to use the bilinear algorithm or the nearest neighbor algorithm.
-
drawImage
public static void drawImage(GraphicsContext gc, Image image, Matrix matrix, boolean bilinear, int alpha, BlendMode blendMode)
Draws the given image with a transformation defined by the given matrix.In addition with
drawImage(GraphicsContext, Image, Matrix, boolean), this method allows to specify the global opacity value to apply during the image rendering. The blend mode specifies the algorithm to use when blending the pixels of the source and destination.- Parameters:
gc- the graphics context to use.image- the image to render.matrix- the transformation matrix to apply.bilinear- whether to use the bilinear algorithm or the nearest neighbor algorithm.alpha- the global opacity rendering value.blendMode- the blend mode.- Throws:
IllegalArgumentException- if the given alpha is not a value betweenGraphicsContext.TRANSPARENTandGraphicsContext.OPAQUE.
-
drawImageRegion
public static void drawImageRegion(GraphicsContext gc, Image image, int regionX, int regionY, int regionWidth, int regionHeight, Matrix matrix, boolean bilinear, int alpha, BlendMode blendMode)
Draws a region of the given image with a transformation defined by the given matrix.- Parameters:
gc- the graphics context to use.image- the image to render.regionX- the x coordinate of the region in the image.regionY- the y coordinate of the region in the image.regionWidth- the width of the region.regionHeight- the height of the region.matrix- the transformation matrix to apply.bilinear- whether to use the bilinear algorithm or the nearest neighbor algorithm.alpha- the global opacity rendering value.blendMode- the blend mode.- Throws:
IllegalArgumentException- if the given alpha is not a value betweenGraphicsContext.TRANSPARENTandGraphicsContext.OPAQUE.
-
-