Skip to content

Commit

Permalink
Merge pull request #17 from Rockdtben/fixImageFileExtensionIssue
Browse files Browse the repository at this point in the history
Fixes issue #15
  • Loading branch information
Rockdtben authored Jan 30, 2018
2 parents cee33ba + c80b810 commit 12dd20d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/github/monster860/fastdmm/FastDMM.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ public void actionPerformed(ActionEvent e) {
}
} else if("mapimage".equals(e.getActionCommand())) {
JFileChooser fc = new JFileChooser();

if (fc.getChoosableFileFilters().length > 0)
fc.removeChoosableFileFilter(fc.getChoosableFileFilters()[0]);
fc.addChoosableFileFilter(new FileNameExtensionFilter("Image (*.png)", "png"));
Expand All @@ -512,6 +513,9 @@ public void actionPerformed(ActionEvent e) {
mapImage = createMapImage(1);
}
try {
if (!fc.getSelectedFile().getPath().endsWith(".png"))
fc.setSelectedFile(new File(fc.getSelectedFile().getPath() + ".png"));

ImageIO.write(mapImage, "png", fc.getSelectedFile());
} catch (IOException e1) {
e1.printStackTrace();
Expand Down

0 comments on commit 12dd20d

Please sign in to comment.