[Pixelle-commit] SF.net SVN: pixelle: [36] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-20 05:38:32
|
Revision: 36
http://pixelle.svn.sourceforge.net/pixelle/?rev=36&view=rev
Author: dbrosius
Date: 2008-06-19 22:38:41 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
no transparency is 255, and also create a new image, and put it in a new frame when a transform occurs.
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java
trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteABGR.java
trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java
trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEvalByteGray.java
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java 2008-06-20 04:46:24 UTC (rev 35)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java 2008-06-20 05:38:41 UTC (rev 36)
@@ -67,7 +67,7 @@
return 0.0;
}
}
-
+
public int getWidth() {
return width;
}
@@ -79,4 +79,7 @@
private double getSelectionValue(int x, int y) {
return 0.0;
}
+
+ private void setSelectionValue(int x, int y, double value) {
+ }
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java 2008-06-20 04:46:24 UTC (rev 35)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java 2008-06-20 05:38:41 UTC (rev 36)
@@ -21,6 +21,7 @@
import java.awt.image.BufferedImage;
import com.mebigfatguy.pixelle.eval.PixelleEval3ByteBGR;
+import com.mebigfatguy.pixelle.eval.PixelleEvalByteGray;
public class PixelleEvalFactory {
@@ -40,7 +41,7 @@
break;
case BufferedImage.TYPE_BYTE_GRAY:
- break;
+ return new PixelleEvalByteGray(image);
case BufferedImage.TYPE_INT_ARGB:
break;
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2008-06-20 04:46:24 UTC (rev 35)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2008-06-20 05:38:41 UTC (rev 36)
@@ -19,11 +19,9 @@
package com.mebigfatguy.pixelle;
import java.awt.BorderLayout;
-import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
-import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ResourceBundle;
@@ -50,6 +48,7 @@
import com.mebigfatguy.pixelle.actions.SaveFileAsAction;
import com.mebigfatguy.pixelle.actions.TransformAction;
import com.mebigfatguy.pixelle.actions.ZoomAction;
+import com.mebigfatguy.pixelle.utils.GuiUtils;
import com.mebigfatguy.pixelle.utils.ZoomLevel;
public class PixelleFrame extends JFrame {
@@ -88,6 +87,18 @@
setTitle(rb.getString("pixelle.title"));
}
+ public PixelleFrame(PixelleImage srcImage) {
+ this();
+ image = srcImage;
+ Container cp = getContentPane();
+ cp.removeAll();
+ setZoom(ZoomLevel.FitToWindow);
+ scroll = new JScrollPane(panel);
+ cp.add(scroll, BorderLayout.CENTER);
+ setBounds(GuiUtils.getScreenBounds());
+ FrameMgr.getInstance().add(this);
+ }
+
private void initComponents() {
JMenuBar mb = new JMenuBar();
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-20 04:46:24 UTC (rev 35)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-20 05:38:41 UTC (rev 36)
@@ -18,7 +18,7 @@
*/
package com.mebigfatguy.pixelle;
-import java.awt.image.DataBuffer;
+import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.AccessController;
@@ -31,6 +31,7 @@
import com.mebigfatguy.pixelle.antlr.PixelleLexer;
import com.mebigfatguy.pixelle.antlr.PixelleParser;
+import com.mebigfatguy.pixelle.eval.PixelleEval3ByteABGR;
public class PixelleTransformer {
@@ -44,7 +45,12 @@
public PixelleImage transform() {
try {
- PixelleEval pe = PixelleEvalFactory.create(srcImage);
+ /** eventually allow for gui to set width/height */
+ PixelleImage destImage = new PixelleImage(new BufferedImage(srcImage.getWidth(), srcImage.getHeight(), BufferedImage.TYPE_4BYTE_ABGR));
+
+ PixelleEval srcPE = PixelleEvalFactory.create(srcImage);
+ PixelleEval3ByteABGR destPE = new PixelleEval3ByteABGR(destImage);
+
PixelleClassLoader pcl = AccessController.doPrivileged(new PrivilegedAction<PixelleClassLoader>() {
public PixelleClassLoader run() {
return new PixelleClassLoader(Thread.currentThread().getContextClassLoader());
@@ -68,22 +74,21 @@
Class<?> cl = pcl.loadClass(clsName);
PixelleExpr expr = (PixelleExpr)cl.newInstance();
- DataBuffer buffer = srcImage.getBuffer();
- int width = srcImage.getWidth();
- int height = srcImage.getHeight();
- int offset = entry.getKey().getComponentOffset();
+
+ int width = destImage.getWidth();
+ int height = destImage.getHeight();
+ char pixelSpec = entry.getKey().getPixelSpec();
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)
- value = 0.0;
- else if (value > 255.0)
- value = 255.0;
- buffer.setElem(y * width * 3 + x * 3 + offset, (int)(value + 0.49));
+ double value = expr.eval(srcPE, x, y);
+
+ destPE.setValue(x, y, pixelSpec, value);
}
}
}
- return null;
+
+ return destImage;
+
} catch (Exception e) {
return null;
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java 2008-06-20 04:46:24 UTC (rev 35)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java 2008-06-20 05:38:41 UTC (rev 36)
@@ -22,6 +22,7 @@
import javax.swing.AbstractAction;
+import com.mebigfatguy.pixelle.FrameMgr;
import com.mebigfatguy.pixelle.PixelleBundle;
import com.mebigfatguy.pixelle.PixelleExpressionDialog;
import com.mebigfatguy.pixelle.PixelleFrame;
@@ -46,7 +47,10 @@
if (d.isOK()) {
PixelleTransformer transformer = new PixelleTransformer(frame.getImage(), d.getAlgorithms());
PixelleImage dstImage = transformer.transform();
- frame.repaint();
+ if (dstImage != null) {
+ PixelleFrame f = new PixelleFrame(dstImage);
+ f.setVisible(true);
+ }
}
}
}
\ No newline at end of file
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteABGR.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteABGR.java 2008-06-20 04:46:24 UTC (rev 35)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteABGR.java 2008-06-20 05:38:41 UTC (rev 36)
@@ -46,4 +46,34 @@
public double getRedValue(int x, int y) {
return (double)buffer.getElem(y * width * 4 + x * 4 + 3);
}
+
+ public void setValue(int x, int y, char pixelSpec, double value) {
+
+ if (value < 0.0)
+ value = 0.0;
+ else if (value > 255.0)
+ value = 255.0;
+
+ switch (pixelSpec) {
+ case 't':
+ buffer.setElem(y * width * 4 + x * 4, (int)(value + 0.49));
+ break;
+
+ case 'b':
+ buffer.setElem(y * width * 4 + x * 4 + 1, (int)(value + 0.49));
+ break;
+
+ case 'g':
+ buffer.setElem(y * width * 4 + x * 4 + 2, (int)(value + 0.49));
+ break;
+
+ case 'r':
+ buffer.setElem(y * width * 4 + x * 4 + 3, (int)(value + 0.49));
+ break;
+
+ case 's':
+ break;
+ }
+ }
+
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java 2008-06-20 04:46:24 UTC (rev 35)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java 2008-06-20 05:38:41 UTC (rev 36)
@@ -44,7 +44,7 @@
@Override
public double getTransparencyValue(int x, int y) {
- return 0;
+ return 255.0;
}
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEvalByteGray.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEvalByteGray.java 2008-06-20 04:46:24 UTC (rev 35)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEvalByteGray.java 2008-06-20 05:38:41 UTC (rev 36)
@@ -44,7 +44,7 @@
@Override
public double getTransparencyValue(int x, int y) {
- return 0.0;
+ return 255.0;
}
private double getValue(int x, int y) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|