Class OneImage

java.lang.Object
org.polyfrost.oneconfig.utils.v1.OneImage

@Experimental public final class OneImage extends Object
An Image wrapper class that is used by the OneConfig system.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
     
     
    final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    OneImage(int width, int height)
    Create a new blank image with the specified width and height.
    Create a new OneImage from the BufferedImage.
    Create a new OneImage from the file.
    OneImage(Path path)
    Create a new OneImage from the file.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Copy 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.
    void
    Dispose of the graphics object.
    Return a copy of this OneImage flipped horizontally.
    Return a copy of this OneImage flipped vertically.
    int
    getColorAtPos(int x, int y)
    Get the color of a pixel in the image.
     
    void
     
    void
     
    rotate(double degrees)
    Return a copy of this OneImage with the image rotated by the specified number of degrees.
    void
    save(Path path)
    Attempt 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.
    void
    setBrightness(float brightness)
     
    void
    setColorAtPos(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • width

      public final int width
    • height

      public final int height
    • image

      public final BufferedImage image
  • Constructor Details

    • OneImage

      public OneImage(BufferedImage image)
      Create a new OneImage from the BufferedImage.
    • OneImage

      public OneImage(InputStream is) throws IOException
      Create a new OneImage from the file.
      Parameters:
      is - InputStream to the image file.
      Throws:
      IOException
    • OneImage

      public OneImage(Path path) throws IOException
      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

      public Graphics2D getG2D()
      Returns:
      the graphics object associated with the image.
    • dispose

      public void dispose()
      Dispose of the graphics object.
    • crop

      public OneImage crop(int startX, int startY, int width, int height)
      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

      public void save(Path path) throws IOException
      Attempt to save the image to the specified file.
      Throws:
      IOException
    • uploadToImgur

      public String 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

      public void maskColor(Color color)
    • maskPaint

      public void maskPaint(Paint paint)
    • scale

      public OneImage scale(double sx, double sy)
      Return a new OneImage, with the image scaled by the given factor (1.0 = no change).
    • scaleToSize

      public OneImage scaleToSize(int width, int height)
      Return a copy of this OneImage with the image scaled to the specified width and height.
    • rotate

      public OneImage rotate(double degrees)
      Return a copy of this OneImage with the image rotated by the specified number of degrees.
    • flipHorizontal

      public OneImage flipHorizontal()
      Return a copy of this OneImage flipped horizontally.
    • flipVertical

      public OneImage flipVertical()
      Return a copy of this OneImage flipped vertically.