Skip to content

Commit

Permalink
Fixed saving images
Browse files Browse the repository at this point in the history
  • Loading branch information
cr5315 committed Feb 14, 2017
1 parent fbe15fc commit 71eb350
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/me/butzow/pixelbreak/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ public Application() {
imageForm.show();
}

@Override
public void saveImage(File file, double a, int b, double x, double y) {
if (file == null) return;

try {
imageForm.saveImage(Breaker.breakImage(ImageIO.read(file), a, b, x, y));
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void updateImage(File file, double a, int b, double x, double y) {
if (file == null) return;
Expand Down
3 changes: 2 additions & 1 deletion src/me/butzow/pixelbreak/ImageForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ImageForm implements ActionListener, ChangeListener {
private final File picturesDir = new File(System.getProperty("user.home") + System.getProperty("file.separator") + "Pictures");

public interface Callback {
void saveImage(File file, double a, int b, double x, double y);
void updateImage(File file, double a, int b, double x, double y);
}

Expand Down Expand Up @@ -113,7 +114,7 @@ public void actionPerformed(ActionEvent e) {
if (e.getSource() == loadImageButton) {
showFileChooser();
} else if (e.getSource() == saveImageButton) {
callback.updateImage(fileChooser.getSelectedFile(), (double) spinner1.getValue(), (int) spinner2.getValue(), (double) spinner3.getValue(), (double) spinner4.getValue());
callback.saveImage(fileChooser.getSelectedFile(), (double) spinner1.getValue(), (int) spinner2.getValue(), (double) spinner3.getValue(), (double) spinner4.getValue());
} else if (e.getSource() == aboutButton) {
if (Desktop.isDesktopSupported()) {
try {
Expand Down

0 comments on commit 71eb350

Please sign in to comment.