Skip to content

Commit

Permalink
added writing tif and webp
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed May 27, 2024
1 parent e9f3042 commit a277fb9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.marginallyclever</groupId>
<artifactId>Makelangelo</artifactId>
<version>7.55.1</version>
<version>7.55.3</version>
<name>Makelangelo</name>
<description>Makelangelo Software is a Java program that prepares art for CNC plotters. It is especially designed for the Makelangelo Robot.
It pairs really well with Marlin-polargraph, the code in the brain of the robot that receives instructions and moves the motors.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.io.OutputStream;

/**
* Save Turtle to any supported bitmap format.
* Save {@link Turtle} to any bitmap format supported by {@link ImageIO}.
* @author Dan Royer
*/
public class SaveBitmap implements TurtleSaver {
Expand Down Expand Up @@ -78,6 +78,8 @@ public boolean save(OutputStream outputStream, Turtle myTurtle, PlotterSettings
}

ImageIO.write(img, extension, outputStream);
// webp requires a flush or there will be a zero-length file.
outputStream.flush();

logger.debug("done.");
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ public class TurtleFactory {
new SaveDXF(),
new SaveSVG(),
new SaveGCode(),
new SaveBitmap("BMP",false),
new SaveBitmap("GIF",false),
new SaveBitmap("JPG",false),
new SaveBitmap("PIO",false),
new SaveBitmap("PNG",true),
new SaveBitmap("bmp",false),
new SaveBitmap("gif",false),
new SaveBitmap("jpg",false),
new SaveBitmap("pio",false),
new SaveBitmap("png",true),
new SaveBitmap("tif",false),
new SaveBitmap("webp",true),
};

public static Turtle load(String filename) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
package com.marginallyclever.makelangelo.makeart.io;

import java.io.InputStream;
import com.marginallyclever.makelangelo.turtle.Turtle;

import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.InputStream;

import com.marginallyclever.makelangelo.turtle.Turtle;

/**
* A TurtleLoader is a plugin that can load a file into the system as a {@link Turtle}.
*/
public interface TurtleLoader {
/**
* @return returns a FileNameExtensionFilter with the extensions supported by this filter.
*/
public FileNameExtensionFilter getFileNameFilter();
FileNameExtensionFilter getFileNameFilter();

/**
* Checks a string's filename, which includes the file extension, (e.g. foo.jpg).
*
* @param filename absolute path of file to load.
* @return true if this plugin can load this file.
*/
public boolean canLoad(String filename);
boolean canLoad(String filename);

/**
* attempt to load a file into the system from a given stream
* @param inputStream source of image
* @return true if load successful.
*/
public Turtle load(InputStream inputStream) throws Exception;
Turtle load(InputStream inputStream) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.OutputStream;

/**
* Save a {@link Turtle} to a file.
*/
public interface TurtleSaver {
FileNameExtensionFilter getFileNameFilter();

Expand Down

0 comments on commit a277fb9

Please sign in to comment.