[Pixelle-commit] SF.net SVN: pixelle: [27] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-19 05:51:59
|
Revision: 27
http://pixelle.svn.sourceforge.net/pixelle/?rev=27&view=rev
Author: dbrosius
Date: 2008-06-18 22:52:07 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
start using PixelleImage
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelEval.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelEval.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelEval.java 2008-06-19 05:41:03 UTC (rev 26)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelEval.java 2008-06-19 05:52:07 UTC (rev 27)
@@ -27,10 +27,10 @@
private int width;
private int height;
- public PixelEval(BufferedImage bufferedImage) {
- buffer = bufferedImage.getRaster().getDataBuffer();
- width = bufferedImage.getWidth();
- height = bufferedImage.getHeight();
+ public PixelEval(PixelleImage image) {
+ buffer = image.getBuffer();
+ width = image.getWidth();
+ height = image.getHeight();
}
public double getValue(int x, int y, char pixelSpec) {
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2008-06-19 05:41:03 UTC (rev 26)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2008-06-19 05:52:07 UTC (rev 27)
@@ -81,7 +81,7 @@
ResourceBundle rb = ResourceBundle.getBundle("com.mebigfatguy.pixelle.pixelle");
JScrollPane scroll;
ImagePanel panel = new ImagePanel();
- BufferedImage image;
+ PixelleImage image;
public PixelleFrame() {
initComponents();
@@ -162,14 +162,14 @@
cp.setLayout(new BorderLayout());
}
- public BufferedImage getImage() {
+ public PixelleImage getImage() {
return image;
}
public void openFile(File f) {
setTitle(f.getName());
try {
- image = ImageIO.read(f);
+ image = new PixelleImage(ImageIO.read(f));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Container cp = getContentPane();
@@ -228,7 +228,7 @@
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
- g.drawImage(image, 0, 0, dim.width, dim.height, Color.WHITE, null);
+ image.draw(g, 0, 0, dim.width, dim.height);
}
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java 2008-06-19 05:41:03 UTC (rev 26)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java 2008-06-19 05:52:07 UTC (rev 27)
@@ -18,7 +18,10 @@
*/
package com.mebigfatguy.pixelle;
+import java.awt.Color;
+import java.awt.Graphics;
import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
public class PixelleImage {
@@ -33,12 +36,20 @@
IndexColorModel bw = new IndexColorModel(1, 2, color, color, color);
selection = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_BINARY, bw);
}
-
- public BufferedImage getImage() {
- return image;
+
+ public int getWidth() {
+ return image.getWidth();
}
+
+ public int getHeight() {
+ return image.getHeight();
+ }
+
+ public DataBuffer getBuffer() {
+ return image.getRaster().getDataBuffer();
+ }
+ public void draw(Graphics g, int left, int top, int width, int height) {
+ g.drawImage(image, left, top, width, height, Color.WHITE, null);
+ }
- public BufferedImage getSelection() {
- return selection;
- }
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-19 05:41:03 UTC (rev 26)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-19 05:52:07 UTC (rev 27)
@@ -18,7 +18,6 @@
*/
package com.mebigfatguy.pixelle;
-import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -35,15 +34,15 @@
public class PixelleTransformer {
- private BufferedImage srcImage;
+ private PixelleImage srcImage;
private Map<PixelComponent, String> algorithms = null;
- public PixelleTransformer(BufferedImage image, Map<PixelComponent, String> algos) {
+ public PixelleTransformer(PixelleImage image, Map<PixelComponent, String> algos) {
srcImage = image;
algorithms = algos;
}
- public BufferedImage transform() {
+ public PixelleImage transform() {
try {
PixelEval pe = new PixelEval(srcImage);
PixelleClassLoader pcl = AccessController.doPrivileged(new PrivilegedAction<PixelleClassLoader>() {
@@ -69,17 +68,17 @@
Class<?> cl = pcl.loadClass(clsName);
PixelleExpr expr = (PixelleExpr)cl.newInstance();
- DataBuffer buffer = srcImage.getRaster().getDataBuffer();
+ DataBuffer buffer = srcImage.getBuffer();
int width = srcImage.getWidth();
int height = srcImage.getHeight();
int offset = entry.getKey().getComponentOffset();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
double value = expr.eval(pe, x, y);
- if (value < 0.0)
+ /*if (value < 0.0)
value = 0.0;
else if (value > 1.0)
- value = 1.0;
+ value = 1.0;*/
buffer.setElemDouble(y * width * 3 + x * 3 + offset, value);
}
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java 2008-06-19 05:41:03 UTC (rev 26)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java 2008-06-19 05:52:07 UTC (rev 27)
@@ -19,13 +19,13 @@
package com.mebigfatguy.pixelle.actions;
import java.awt.event.ActionEvent;
-import java.awt.image.BufferedImage;
import javax.swing.AbstractAction;
import com.mebigfatguy.pixelle.PixelleBundle;
import com.mebigfatguy.pixelle.PixelleExpressionDialog;
import com.mebigfatguy.pixelle.PixelleFrame;
+import com.mebigfatguy.pixelle.PixelleImage;
import com.mebigfatguy.pixelle.PixelleTransformer;
public class TransformAction extends AbstractAction {
@@ -45,7 +45,7 @@
d.setVisible(true);
if (d.isOK()) {
PixelleTransformer transformer = new PixelleTransformer(frame.getImage(), d.getAlgorithms());
- BufferedImage dstImage = transformer.transform();
+ PixelleImage dstImage = transformer.transform();
frame.repaint();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|