content: package com.hacklympics.api.utility;
  
  import java.awt.AWTException;
  import java.awt.Rectangle;
  import java.awt.Robot;
  import java.awt.Toolkit;
  import java.awt.image.BufferedImage;
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import javafx.embed.swing.SwingFXUtils;
  import javafx.scene.image.Image;
  import javax.imageio.ImageIO;
  import net.coobird.thumbnailator.Thumbnails;
  
  public class ImageUtils {
      
      private ImageUtils() {
          
      }
      
      
      public static BufferedImage takeSnapshot(double scale) throws AWTException, IOException {
          BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
          BufferedImage thumbnail = Thumbnails.of(image).scale(scale).asBufferedImage();
          
          return thumbnail;
      }
      
      public static byte[] bufferedImage2ByteArray(BufferedImage image) throws IOException {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ImageIO.write(image, "jpg", baos);
          return baos.toByteArray();
      }
      
      public static BufferedImage byteArray2BufferedImage(byte[] bytes) throws IOException {
          return ImageIO.read(new ByteArrayInputStream(bytes));
      }
      
      public static Image bufferedImage2FXImage(BufferedImage bufferedImage) {
          return SwingFXUtils.toFXImage(bufferedImage, null);
      }
      
  }