Class DeImage
java.lang.Object
com.jackmeng.halcyoninae.halcyon.utils.DeImage
This is a class that modifies images that are fed to it.
It is primarily used to handle resources that are in image form.
This is a general utility class and is licensed under GPL-3.0.
- Since:
- 2.0
- Author:
- Jack Meng
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHolds enum constants for the different aspects of the image. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImageapplyMask(BufferedImage sourceImage, BufferedImage maskImage, int method) Combines a mask between a source image and a mask image.static BufferedImagecreateGradient(BufferedImage img, int startOpacity, int endOpacity, DeImage.Directional opacityStartDirection) Creates a gradient from a certain side.static BufferedImagecreateGradientVertical(BufferedImage img, int startOpacity, int endOpacity) Makes a gradient from top to bottom.static BufferedImagecreateRoundedBorder(BufferedImage r, int arc, Color someColor) Generates a rounded image with bordersstatic BufferedImageimageIconToBI(ImageIcon icon) Converts an ImageIcon to a BufferedImagestatic BufferedImageTurns an Image read raw from a stream to be enwrapped by a BufferedImage object.static BufferedImageresize(BufferedImage img, int newW, int newH) Resizes a BufferedImagestatic ImageIconresizeImage(ImageIcon image, int width, int height) static BufferedImageresizeNoDistort(BufferedImage img, int newW, int newH) Resizes a BufferedImage by preserving the aspect ratio.static voidwrite(BufferedImage r, String path) Writes a BufferedImage to a file.static BufferedImagezoomToCenter(BufferedImage img, double scaleFactor) Scales up an image to it's center
-
Constructor Details
-
DeImage
private DeImage()
-
-
Method Details
-
imagetoBI
Turns an Image read raw from a stream to be enwrapped by a BufferedImage object.- Parameters:
image- An Image from a stream.- Returns:
- BufferedImage A modified image that has been converted and held in a BufferedImage object.
-
applyMask
public static BufferedImage applyMask(BufferedImage sourceImage, BufferedImage maskImage, int method) Combines a mask between a source image and a mask image.- Parameters:
sourceImage- The image to be masked.maskImage- The image to be used as a mask.method- The method to be used to combine the images.- Returns:
- BufferedImage The combined image.
-
write
Writes a BufferedImage to a file.- Parameters:
r- The BufferedImage to be written.path- The path to the file to be written.
-
resizeNoDistort
Resizes a BufferedImage by preserving the aspect ratio.- Parameters:
img- The BufferedImage to be resized.newW- The new width of the image.newH- The new height of the image.- Returns:
- BufferedImage The resized image.
-
zoomToCenter
Scales up an image to it's center- Parameters:
img- The image to be scaled up.scaleFactor- The scale factor.- Returns:
- BufferedImage The scaled up image.
-
createRoundedBorder
Generates a rounded image with borders- Parameters:
r- The image to be roundedarc- The arc radius of the rounded cornerssomeColor- The Color of the border- Returns:
- BufferedImage The rounded image
-
imageIconToBI
Converts an ImageIcon to a BufferedImage- Parameters:
icon- The ImageIcon to be converted- Returns:
- BufferedImage The converted BufferedImage
-
resize
Resizes a BufferedImage- Parameters:
img- The BufferedImage to be resizednewW- The new widthnewH- The new height- Returns:
- BufferedImage The resized BufferedImage
-
createGradientVertical
public static BufferedImage createGradientVertical(BufferedImage img, int startOpacity, int endOpacity) Makes a gradient from top to bottom.- Parameters:
img- The source imagestartOpacity- The begin opacity of the gradient.endOpacity- The end opacity of the gradient.- Returns:
- BufferedImage The gradient image.
-
createGradient
public static BufferedImage createGradient(BufferedImage img, int startOpacity, int endOpacity, DeImage.Directional opacityStartDirection) Creates a gradient from a certain side.- Parameters:
img- The source imagestartOpacity- The begin opacity of the gradient.endOpacity- The end opacity of the gradient.opacityStartDirection- The direction of the gradient.- Returns:
- BufferedImage The gradient image.
-
resizeImage
- Parameters:
image- An ImageIcon from a stream.width- The width to scale down toheight- The height to scale down to- Returns:
- ImageIcon A modified image that has been scaled to width and height.
-