Class ImageUtils
java.lang.Object
dev.lukebemish.dynamicassetgenerator.api.client.image.ImageUtils
A series of utilities for working with images and colors.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidapplyParallelScaledOperation(PointwiseOperation<T> pointwiseOperation, ImageUtils.OperationResultConsumer<T> consumer, List<com.mojang.blaze3d.platform.NativeImage> images) Applies a pointwise operation to a list of images, scaled so that their widths are all equal, and feeds the results and their positions to a consumer.static <T> voidapplyScaledOperation(PointwiseOperation<T> pointwiseOperation, ImageUtils.OperationResultConsumer<T> consumer, List<com.mojang.blaze3d.platform.NativeImage> images) Applies a pointwise operation to a list of images, scaled so that their widths are all equal, and feeds the results and their positions to a consumer.calculateScaledSize(List<com.mojang.blaze3d.platform.NativeImage> images) Calculates the dimensions of an image that can contain all the supplied images, scaled so that their widths are all equal.static com.mojang.blaze3d.platform.NativeImagegenerateScaledImage(PointwiseOperation<Integer> pointwiseOperation, List<com.mojang.blaze3d.platform.NativeImage> images) Generates an image by applying a pointwise operation to a list of images, scaled so that their widths are all equal.static PalettegetPalette(com.mojang.blaze3d.platform.NativeImage image) static PalettegetPalette(com.mojang.blaze3d.platform.NativeImage image, double cutoff) static intsafeGetPixelABGR(com.mojang.blaze3d.platform.NativeImage image, int x, int y) static intsafeGetPixelABGR(com.mojang.blaze3d.platform.NativeImage image, int x, int y, int def) static intsafeGetPixelARGB(com.mojang.blaze3d.platform.NativeImage image, int x, int y) static intsafeGetPixelARGB(com.mojang.blaze3d.platform.NativeImage image, int x, int y, int def) static booleansafeSetPixelABGR(com.mojang.blaze3d.platform.NativeImage image, int x, int y, int color) Sets the color at a given position in an image, if the position is in bounds.static booleansafeSetPixelARGB(com.mojang.blaze3d.platform.NativeImage image, int x, int y, int color) Sets the color at a given position in an image, if the position is in bounds.
-
Method Details
-
getPalette
- Returns:
- a palette with a given cutoff of colors from an image
-
getPalette
-
safeGetPixelABGR
public static int safeGetPixelABGR(com.mojang.blaze3d.platform.NativeImage image, int x, int y, int def) - Returns:
- the color at a given position in an image, or a default value if the position is out of bounds
-
safeGetPixelABGR
public static int safeGetPixelABGR(com.mojang.blaze3d.platform.NativeImage image, int x, int y) - Returns:
- the color at a given position in an image, or 0x00000000 if the position is out of bounds
-
safeSetPixelABGR
public static boolean safeSetPixelABGR(com.mojang.blaze3d.platform.NativeImage image, int x, int y, int color) Sets the color at a given position in an image, if the position is in bounds.- Returns:
- whether the position was in bounds
-
safeGetPixelARGB
public static int safeGetPixelARGB(com.mojang.blaze3d.platform.NativeImage image, int x, int y, int def) - Returns:
- the color at a given position in an image, or a default value if the position is out of bounds, in ARGB32 encoding
-
safeGetPixelARGB
public static int safeGetPixelARGB(com.mojang.blaze3d.platform.NativeImage image, int x, int y) - Returns:
- the color at a given position in an image, or 0x00000000 if the position is out of bounds, in ARGB32 encoding
-
safeSetPixelARGB
public static boolean safeSetPixelARGB(com.mojang.blaze3d.platform.NativeImage image, int x, int y, int color) Sets the color at a given position in an image, if the position is in bounds.- Returns:
- whether the position was in bounds, in ARGB32 encoding
-
calculateScaledSize
public static com.mojang.datafixers.util.Pair<Integer,Integer> calculateScaledSize(List<com.mojang.blaze3d.platform.NativeImage> images) Calculates the dimensions of an image that can contain all the supplied images, scaled so that their widths are all equal. -
applyScaledOperation
public static <T> void applyScaledOperation(PointwiseOperation<T> pointwiseOperation, ImageUtils.OperationResultConsumer<T> consumer, List<com.mojang.blaze3d.platform.NativeImage> images) Applies a pointwise operation to a list of images, scaled so that their widths are all equal, and feeds the results and their positions to a consumer.- Type Parameters:
T- the type of data generated by the operation- Parameters:
pointwiseOperation- the operation to applyconsumer- the consumer to feed the results to - accepts the x and y coordinates of the pixel, and the data generated by the operationimages- the images to apply the operation to. The number of images must match the number expected by the operation, or the operation must expect any number of images
-
applyParallelScaledOperation
public static <T> void applyParallelScaledOperation(PointwiseOperation<T> pointwiseOperation, ImageUtils.OperationResultConsumer<T> consumer, List<com.mojang.blaze3d.platform.NativeImage> images) Applies a pointwise operation to a list of images, scaled so that their widths are all equal, and feeds the results and their positions to a consumer. The operation is applied in parallel, and the provided operation and consumer must be thread-safe.- Type Parameters:
T- the type of data generated by the operation- Parameters:
pointwiseOperation- the operation to applyconsumer- the consumer to feed the results to - accepts the x and y coordinates of the pixel, and the data generated by the operationimages- the images to apply the operation to. The number of images must match the number expected by the operation, or the operation must expect any number of images
-
generateScaledImage
public static com.mojang.blaze3d.platform.NativeImage generateScaledImage(PointwiseOperation<Integer> pointwiseOperation, List<com.mojang.blaze3d.platform.NativeImage> images) Generates an image by applying a pointwise operation to a list of images, scaled so that their widths are all equal.- Parameters:
pointwiseOperation- the operation to apply. Is applied in parallel and must be threadsafeimages- the images to apply the operation to. The number of images must match the number expected by the operation, or the operation must expect any number of images- Returns:
- the generated image
-