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

      Returns 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

      A factor of 1.0 means 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