diff options
| author | bjculkin <bjculkin@WIT-9B6XG42.wvu-ad.wvu.edu> | 2018-04-26 09:14:19 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@WIT-9B6XG42.wvu-ad.wvu.edu> | 2018-04-26 09:14:19 -0400 |
| commit | a390222aeb0c5bf6982108e6fc0b492e97e43b39 (patch) | |
| tree | c2334a2e81f08952a1c79f0356a1a7459b2f5e9c | |
| parent | 8dbfbb5c87a2fa74c5e3bf829a33fc6180430e5c (diff) | |
Fix stupid pipeline bug
| -rw-r--r-- | bin/bjc/imgchain/ImgChain$LoadImageListener.class | bin | 1657 -> 1657 bytes | |||
| -rw-r--r-- | bin/bjc/imgchain/ImgChain.class | bin | 5346 -> 5803 bytes | |||
| -rw-r--r-- | bin/bjc/imgchain/ImgViewer$ChangeImageListener.class | bin | 2590 -> 2582 bytes | |||
| -rw-r--r-- | bin/bjc/imgchain/ImgViewer.class | bin | 8212 -> 8361 bytes | |||
| -rw-r--r-- | src/bjc/imgchain/ImgChain.java | 13 | ||||
| -rw-r--r-- | src/bjc/imgchain/ImgPipeline.java | 3 | ||||
| -rw-r--r-- | src/bjc/imgchain/ImgViewer.java | 21 | ||||
| -rw-r--r-- | src/bjc/imgchain/pipeline/MutablePipeline.java | 25 | ||||
| -rw-r--r-- | src/bjc/imgchain/pipeline/stages/AbstractPixelStage.java | 7 | ||||
| -rw-r--r-- | src/bjc/imgchain/utils/Utils.java | 24 |
10 files changed, 75 insertions, 18 deletions
diff --git a/bin/bjc/imgchain/ImgChain$LoadImageListener.class b/bin/bjc/imgchain/ImgChain$LoadImageListener.class Binary files differindex dff51e8..aaf6295 100644 --- a/bin/bjc/imgchain/ImgChain$LoadImageListener.class +++ b/bin/bjc/imgchain/ImgChain$LoadImageListener.class diff --git a/bin/bjc/imgchain/ImgChain.class b/bin/bjc/imgchain/ImgChain.class Binary files differindex 5eb912c..b5094a6 100644 --- a/bin/bjc/imgchain/ImgChain.class +++ b/bin/bjc/imgchain/ImgChain.class diff --git a/bin/bjc/imgchain/ImgViewer$ChangeImageListener.class b/bin/bjc/imgchain/ImgViewer$ChangeImageListener.class Binary files differindex bb25d35..4603526 100644 --- a/bin/bjc/imgchain/ImgViewer$ChangeImageListener.class +++ b/bin/bjc/imgchain/ImgViewer$ChangeImageListener.class diff --git a/bin/bjc/imgchain/ImgViewer.class b/bin/bjc/imgchain/ImgViewer.class Binary files differindex 480383d..7f4294f 100644 --- a/bin/bjc/imgchain/ImgViewer.class +++ b/bin/bjc/imgchain/ImgViewer.class diff --git a/src/bjc/imgchain/ImgChain.java b/src/bjc/imgchain/ImgChain.java index e4e32cc..b743a34 100644 --- a/src/bjc/imgchain/ImgChain.java +++ b/src/bjc/imgchain/ImgChain.java @@ -15,6 +15,8 @@ import javax.swing.JMenu; import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
import bjc.imgchain.pipeline.Pipeline;
@@ -71,6 +73,8 @@ public class ImgChain { */
public static ImgChain chan;
+ public JFrame frame;
+
/**
* Main method
*
@@ -80,6 +84,13 @@ public class ImgChain { public static void main(String[] args) {
System.out.println("ImgChain Loading...");
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
+ | UnsupportedLookAndFeelException e) {
+ e.printStackTrace();
+ }
+
chan = new ImgChain();
chan.setupGUI();
@@ -97,7 +108,7 @@ public class ImgChain { * Setup the GUI
*/
private void setupGUI() {
- JFrame frame = new JFrame("ImgChain v1");
+ frame = new JFrame("ImgChain v1");
frame.setLayout(new GridLayout(1, 1));
desktop = new JDesktopPane();
diff --git a/src/bjc/imgchain/ImgPipeline.java b/src/bjc/imgchain/ImgPipeline.java index a53df0f..0e4a7d9 100644 --- a/src/bjc/imgchain/ImgPipeline.java +++ b/src/bjc/imgchain/ImgPipeline.java @@ -96,8 +96,9 @@ public class ImgPipeline extends JInternalFrame { stageEditor.add(stag.getEditor(), BorderLayout.CENTER);
border.setTitle(stag.name());
- // stageEditor.repaint();
+ stageEditor.repaint();
});
+
JScrollPane stageScroll = new JScrollPane(stageList);
JPanel listPanel = new JPanel();
diff --git a/src/bjc/imgchain/ImgViewer.java b/src/bjc/imgchain/ImgViewer.java index 6876514..d632ef8 100644 --- a/src/bjc/imgchain/ImgViewer.java +++ b/src/bjc/imgchain/ImgViewer.java @@ -72,8 +72,7 @@ public class ImgViewer extends JInternalFrame { e.printStackTrace();
- JOptionPane.showInternalMessageDialog(null, msg, "Error loading image",
- JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showInternalMessageDialog(null, msg, "Error loading image", JOptionPane.ERROR_MESSAGE);
}
}
}
@@ -91,7 +90,7 @@ public class ImgViewer extends JInternalFrame { private JLabel lab;
public ImgViewer(ImgChain desk, File img) {
- super("Image Viewer - " + img.getName(), true, true, true, true);
+ super("Image Viewer - " + img.getName(), false, true, true, true);
initted = false;
this.img = img;
@@ -155,11 +154,10 @@ public class ImgViewer extends JInternalFrame { e.printStackTrace();
- JOptionPane.showInternalMessageDialog(null, msg, "Error saving image",
- JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showInternalMessageDialog(null, msg, "Error saving image", JOptionPane.ERROR_MESSAGE);
}
});
-
+
JMenuItem storeImage = new JMenuItem("Stash Image to Memory");
storeImage.setMnemonic('T');
storeImage.addActionListener((ev) -> {
@@ -219,8 +217,12 @@ public class ImgViewer extends JInternalFrame { Pipeline pipeline = ImgChain.chan.pipelineRepo.get(pick.pipeName);
- icon.setImage(pipeline.process(Utils.toBuffered(icon.getImage())));
- lab.repaint();
+ BufferedImage bufimg = Utils.toBuffered(icon.getImage());
+
+ Image processed = pipeline.process(bufimg);
+
+ Utils.displayImage(processed, "Pipeline Results");
+
});
editMenu.addSeparator();
@@ -250,8 +252,7 @@ public class ImgViewer extends JInternalFrame { e.printStackTrace();
- JOptionPane.showInternalMessageDialog(this, msg, "Error loading image",
- JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showInternalMessageDialog(this, msg, "Error loading image", JOptionPane.ERROR_MESSAGE);
}
return lab;
diff --git a/src/bjc/imgchain/pipeline/MutablePipeline.java b/src/bjc/imgchain/pipeline/MutablePipeline.java index 6272b30..d1d228d 100644 --- a/src/bjc/imgchain/pipeline/MutablePipeline.java +++ b/src/bjc/imgchain/pipeline/MutablePipeline.java @@ -1,9 +1,18 @@ package bjc.imgchain.pipeline;
+import java.awt.GridLayout;
import java.awt.Image;
+import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
+import javax.swing.ImageIcon;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+
+import bjc.imgchain.ImgChain;
+import bjc.imgchain.utils.Utils;
+
/**
* An editable {@link Pipeline}
*
@@ -28,7 +37,7 @@ public class MutablePipeline implements Pipeline { * Create a new named mutable pipeline.
*
* @param name
- * The name of the pipeline.
+ * The name of the pipeline.
*/
public MutablePipeline(String name) {
stages = new ArrayList<>();
@@ -40,9 +49,15 @@ public class MutablePipeline implements Pipeline { public Image process(Image input) {
Image proc = input;
+ int i = 1;
+
for (PipelineStage stage : stages) {
System.out.println("Applying stage " + stage.name());
+
proc = stage.process(proc);
+
+ Utils.displayImage(proc, "Pipeline Results - " + stage.name() + " - #" + i);
+
System.out.println("Applied stage " + stage.name());
}
@@ -63,7 +78,7 @@ public class MutablePipeline implements Pipeline { * Set the name of the pipeline.
*
* @param nam
- * The name of the pipeline.
+ * The name of the pipeline.
*/
public void name(String nam) {
name = nam;
@@ -73,7 +88,7 @@ public class MutablePipeline implements Pipeline { * Append a pipeline stage to the end of this pipeline.
*
* @param stag
- * The stage to add.
+ * The stage to add.
*/
public void addStage(PipelineStage stag) {
stages.add(stag);
@@ -83,7 +98,7 @@ public class MutablePipeline implements Pipeline { * Remove a pipeline stage.
*
* @param stag
- * The stage to remove.
+ * The stage to remove.
*/
public void removeStage(PipelineStage stag) {
stages.remove(stag);
@@ -93,7 +108,7 @@ public class MutablePipeline implements Pipeline { * Remove a pipeline stage by index.
*
* @param idx
- * The index of the stage to remove.
+ * The index of the stage to remove.
*/
public void removeStage(int idx) {
stages.remove(idx);
diff --git a/src/bjc/imgchain/pipeline/stages/AbstractPixelStage.java b/src/bjc/imgchain/pipeline/stages/AbstractPixelStage.java index 44e3c60..1317c12 100644 --- a/src/bjc/imgchain/pipeline/stages/AbstractPixelStage.java +++ b/src/bjc/imgchain/pipeline/stages/AbstractPixelStage.java @@ -16,10 +16,15 @@ public abstract class AbstractPixelStage extends AbstractPipelineStage { public Image process(Image inp) {
BufferedImage buf = (BufferedImage) inp;
+ //BufferedImage res = new BufferedImage(buf.getWidth(), buf.getHeight(), BufferedImage.TYPE_INT_ARGB);
+
for (int y = 0; y < buf.getHeight(); y++) {
for (int x = 0; x < buf.getWidth(); x++) {
int[] pix = Utils.toARGBQuad(buf.getRGB(x, y));
- buf.setRGB(x, y, Utils.fromARGBQuad(pix));
+
+ int[] processedPixel = processPixel(pix);
+
+ buf.setRGB(x, y, Utils.fromARGBQuad(processedPixel));
}
}
diff --git a/src/bjc/imgchain/utils/Utils.java b/src/bjc/imgchain/utils/Utils.java index 38e2ec2..a4df9de 100644 --- a/src/bjc/imgchain/utils/Utils.java +++ b/src/bjc/imgchain/utils/Utils.java @@ -1,9 +1,16 @@ package bjc.imgchain.utils;
import java.awt.Graphics2D;
+import java.awt.GridLayout;
import java.awt.Image;
import java.awt.image.BufferedImage;
+import javax.swing.ImageIcon;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+
+import bjc.imgchain.ImgChain;
+
public class Utils {
public static BufferedImage toBuffered(Image img) {
if (img instanceof BufferedImage) {
@@ -51,4 +58,21 @@ public class Utils { }
return temp;
}
+
+ public static void displayImage(Image processed, String title) {
+ {
+ BufferedImage resimg = toBuffered(processed);
+
+ JInternalFrame displayFrame = new JInternalFrame(title, false, true, true);
+ displayFrame.setSize(resimg.getWidth(), resimg.getHeight());
+ displayFrame.setLayout(new GridLayout(1, 1));
+
+ JLabel displayLabel = new JLabel(new ImageIcon(resimg));
+
+ displayFrame.add(displayLabel);
+
+ ImgChain.chan.desktop.add(displayFrame);
+ displayFrame.setVisible(true);
+ }
+ }
}
|
