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 heightOneImage(BufferedImage image) Create a new OneImage from the BufferedImageOneImage(InputStream is) Create a new OneImage from the fileCreate a new OneImage from the file -
Method Summary
Modifier and TypeMethodDescriptionvoidCopy the image to the system clipboard and delete the graphics objectcrop(int startX, int startY, int width, int height) Copy and crop the image to the specified width and heightvoiddispose()Dispose of the graphics objectReturn a copy of this OneImage flipped horizontallyReturn a copy of this OneImage flipped verticallyintgetColorAtPos(int x, int y) Get the color of a pixel in the imagegetG2D()voidvoidrotate(double degrees) Return a copy of this OneImage with the image rotated by the specified number of degreesvoidAttempt to save the image to the specified filescale(double sx, double sy) Return a new OneImage with the image scaled by the given factorscaleToSize(int width, int height) Return a copy of this OneImage with the image scaled to the specified width and heightvoidsetBrightness(float brightness) voidsetColorAtPos(int x, int y, int argb) Set the color of a pixel in the imageAttempt to upload the image to Imgur
-
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 cropstartY- The y coordinate of the top-left corner of the cropwidth- The width of the cropheight- 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 ImgurReturns 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 factorA factor of
1.0means 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
-