Package org.polyfrost.oneconfig.utils.v1
Class OneImage
java.lang.Object
org.polyfrost.oneconfig.utils.v1.OneImage
An Image wrapper class that is used by the OneConfig system.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOneImage(int width, int height) Create a new blank image with the specified width and height.OneImage(BufferedImage image) Create a new OneImage from the BufferedImage.OneImage(InputStream is) Create a new OneImage from the file.Create a new OneImage from the file. -
Method Summary
Modifier and TypeMethodDescriptionvoidCopy the image to the system clipboard and delete the graphics object.crop(int startX, int startY, int width, int height) Copy and crop the image to the specified width and height.voiddispose()Dispose of the graphics object.Return a copy of this OneImage flipped horizontally.Return a copy of this OneImage flipped vertically.intgetColorAtPos(int x, int y) Get the color of a pixel in the image.getG2D()voidvoidrotate(double degrees) Return a copy of this OneImage with the image rotated by the specified number of degrees.voidAttempt to save the image to the specified file.scale(double sx, double sy) Return a new OneImage, with the image scaled by the given factor (1.0 = no change).scaleToSize(int width, int height) Return a copy of this OneImage with the image scaled to the specified width and height.voidsetBrightness(float brightness) voidsetColorAtPos(int x, int y, int argb) Set the color of a pixel in the image.Attempt to upload the image to Imgur, returning the URL that the server replied with, or null if it failed for any reason.
-
Field Details
-
width
public final int width -
height
public final int height -
image
-
-
Constructor Details
-
OneImage
Create a new OneImage from the BufferedImage. -
OneImage
Create a new OneImage from the file.- Parameters:
is- InputStream to the image file.- Throws:
IOException
-
OneImage
Create a new OneImage from the file.- Parameters:
path- path to the image file.- Throws:
IOException
-
OneImage
public OneImage(int width, int height) Create a new blank image with the specified width and height.
-
-
Method Details
-
getG2D
- Returns:
- the graphics object associated with the image.
-
dispose
public void dispose()Dispose of the graphics object. -
crop
Copy and crop the image to the specified width and height.- Parameters:
startX- The x coordinate of the top-left corner of the crop.startY- The y coordinate of the top-left corner of the crop.width- The width of the crop.height- The height of the crop.
-
getColorAtPos
public int getColorAtPos(int x, int y) Get the color of a pixel in the image. -
setColorAtPos
public void setColorAtPos(int x, int y, int argb) Set the color of a pixel in the image. -
save
Attempt to save the image to the specified file.- Throws:
IOException
-
uploadToImgur
Attempt to upload the image to Imgur, returning the URL that the server replied with, or null if it failed for any reason. -
copyToClipboard
public void copyToClipboard()Copy the image to the system clipboard and delete the graphics object. -
setBrightness
public void setBrightness(float brightness) -
maskColor
-
maskPaint
-
scale
Return a new OneImage, with the image scaled by the given factor (1.0 = no change). -
scaleToSize
Return a copy of this OneImage with the image scaled to the specified width and height. -
rotate
Return a copy of this OneImage with the image rotated by the specified number of degrees. -
flipHorizontal
Return a copy of this OneImage flipped horizontally. -
flipVertical
Return a copy of this OneImage flipped vertically.
-