Browse files

fixed export not being sized correctly (issue 36, since quak did not …

…do it)
  • Loading branch information...
1 parent 8b206b2 commit 0f758f3d7d077f5f2e11ce93c4225de49cf85bb3 @unixtam unixtam committed Apr 20, 2010
Showing with 41 additions and 1 deletion.
  1. +2 −1 src/evopaint/gui/ExportDialog.java
  2. +39 −0 src/evopaint/gui/util/WrappingScalableCanvas.java
View
3 src/evopaint/gui/ExportDialog.java
@@ -11,6 +11,7 @@
import javax.swing.filechooser.FileNameExtensionFilter;
import evopaint.EvoPaint;
+import evopaint.Perception;
public class ExportDialog implements ActionListener {
private Configuration configuration;
@@ -29,7 +30,7 @@ public ExportDialog(Configuration configuration, EvoPaint evopaint){
public void actionPerformed(java.awt.event.ActionEvent e) {
configuration.runLevel = Configuration.RUNLEVEL_STOP;
- BufferedImage img = evopaint.getPerception().getImage();
+ BufferedImage img = evopaint.getFrame().getShowcase().scaleAndTranslate(evopaint.getPerception().getImage());
try{
View
39 src/evopaint/gui/util/WrappingScalableCanvas.java
@@ -418,4 +418,43 @@ public void paintComponent(Graphics g) {
transform.translate(imageWidth, 0);
g2.drawRenderedImage(image, transform);
}
+
+ public BufferedImage scaleAndTranslate(BufferedImage image) {
+ BufferedImage ret = new BufferedImage((int)(imageWidth * scale), (int)(imageHeight * scale), BufferedImage.TYPE_INT_RGB);
+
+ Graphics2D g2 = ret.createGraphics();
+
+ g2.clip(scaleToUserSpace(new Rectangle(imageWidth, imageHeight)));
+
+ // paint NW
+ transform.translate((-1) * imageWidth, (-1) * imageHeight);
+ g2.drawRenderedImage(image, transform);
+ // paint N
+ transform.translate(imageWidth, 0);
+ g2.drawRenderedImage(image, transform);
+ // paint NE
+ transform.translate(imageWidth, 0);
+ g2.drawRenderedImage(image, transform);
+ // paint E
+ transform.translate(0, imageHeight);
+ g2.drawRenderedImage(image, transform);
+ // paint SE
+ transform.translate(0, imageHeight);
+ g2.drawRenderedImage(image, transform);
+ // paint S
+ transform.translate((-1) * imageWidth, 0);
+ g2.drawRenderedImage(image, transform);
+ // paint SW
+ transform.translate((-1) * imageWidth, 0);
+ g2.drawRenderedImage(image, transform);
+ // paint W
+ transform.translate(0, (-1) * imageHeight);
+ g2.drawRenderedImage(image, transform);
+ // back to normal
+ transform.translate(imageWidth, 0);
+ g2.drawRenderedImage(image, transform);
+
+ return ret;
+ }
+
}

0 comments on commit 0f758f3

Please sign in to comment.