src/main/java/chalmers/pimp/service/ImageExportService.java
public static void exportImage(int width, int height, Iterable<? extends IReadOnlyLayer> layers) {
    if ((width < 1) || (height < 1)) {
      throw new IllegalArgumentException("Invalid width or height!");
    }
    Objects.requireNonNull(layers);

    FileChooser fileChooser = createFileChooser();
    File file = fileChooser.showSaveDialog(null);
    if (file == null) {
      return; // simply return if the user doesn't want to save the content
    }

    var img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    renderToImage(img, layers);

    try {
      ImageIO.write(img, "png", file);
    } catch (Exception e) {
      System.err.println("Failed to export image! Exception: " + e);
    }
  }
/**
   * Attempts to export the supplied layers into an image. This method has no effect if the
   * operation is unsuccessful.
   *
   * @param width  the width of the created image.
   * @param height the height of the created image.
   * @param layers the layers that will be used when creating the image.
   * @throws IllegalArgumentException if the supplied width/height aren't greater than zero.
   * @throws NullPointerException     if any references are {@code null}.
   */
Attempts to export the supplied layers into an image. This method has no effect if the
operation is unsuccessful.

@param width  the width of the created image.
@param height the height of the created image.
@param layers the layers that will be used when creating the image.
@throws IllegalArgumentException if the supplied width/height aren't greater than zero.
@throws NullPointerException     if any references are  null.
Attempts to export the supplied layers into an image . This method has no effect if the operation is unsuccessful . @param width the width of the created image . @param height the height of the created image . @param layers the layers that will be used when creating the image . @throws IllegalArgumentException if the supplied width / height aren ' t greater than zero . @throws NullPointerException if any references are null .
public static void exportImage(int width, int height, Iterable<? extends IReadOnlyLayer> layers) {
    if ((width < 1) || (height < 1)) {
      throw new IllegalArgumentException("Invalid width or height!");
    }
    Objects.requireNonNull(layers);
    FileChooser fileChooser = createFileChooser();
    File file = fileChooser.showSaveDialog(null);
    if (file == null) {
      return; 
    }
    var img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    renderToImage(img, layers);
    try {
      ImageIO.write(img, "png", file);
    } catch (Exception e) {
      System.err.println("Failed to export image! Exception: " + e);
    }
  }
public static void exportImage ( int width , int height , Iterable < ? extends IReadOnlyLayer > layers ) { if ( ( width < 1 ) || ( height < 1 ) ) { throw new IllegalArgumentException ( "Invalid width or height!" ) ; } Objects . requireNonNull ( layers ) ; FileChooser fileChooser = createFileChooser ( ) ; File file = fileChooser . showSaveDialog ( null ) ; if ( file == null ) { return ; } var img = new BufferedImage ( width , height , BufferedImage . TYPE_INT_ARGB ) ; renderToImage ( img , layers ) ; try { ImageIO . write ( img , "png" , file ) ; } catch ( Exception e ) { System . err . println ( "Failed to export image! Exception: " + e ) ; } }
Attempts to export the supplied layers into an image.
Attempts to export the supplied layers into an image .
// simply return if the user doesn't want to save the content