[Pixelle-commit] SF.net SVN: pixelle: [31] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-20 04:30:29
|
Revision: 31
http://pixelle.svn.sourceforge.net/pixelle/?rev=31&view=rev
Author: dbrosius
Date: 2008-06-19 21:30:38 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
Move towards a Pixel Eval factory for different types of images
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
Added Paths:
-----------
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java
trunk/pixelle/src/com/mebigfatguy/pixelle/eval/
trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java 2008-06-20 03:55:36 UTC (rev 30)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java 2008-06-20 04:30:38 UTC (rev 31)
@@ -18,53 +18,54 @@
*/
package com.mebigfatguy.pixelle;
-import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
-public class PixelleEval {
+public abstract class PixelleEval {
- private DataBuffer buffer;
- private int width;
- private int height;
+ protected PixelleImage srcImage;
+ protected DataBuffer buffer;
+ protected int width;
+ protected int height;
public PixelleEval(PixelleImage image) {
+ srcImage = image;
buffer = image.getBuffer();
width = image.getWidth();
height = image.getHeight();
}
+ public abstract double getRedValue(int x, int y);
+ public abstract double getGreenValue(int x, int y);
+ public abstract double getBlueValue(int x, int y);
+ public abstract double getTransparencyValue(int x, int y);
+
public double getValue(int x, int y, char pixelSpec) {
+
+ /* in the future, allow customization of out of bounds indices */
if ((x < 0) || (x >= width))
return 1.0;
if ((y < 0) || (y >= height))
return 1.0;
- int offset;
switch (pixelSpec) {
case 'r':
- offset = 0;
- break;
+ return getRedValue(x, y);
case 'g':
- offset = 1;
- break;
+ return getGreenValue(x, y);
case 'b':
- offset = 2;
- break;
+ return getBlueValue(x, y);
case 't':
- offset = 3;
- break;
+ return getTransparencyValue(x, y);
case 's':
- return 0.0;
+ return getSelectionValue(x, y);
default:
return 0.0;
}
-
- return (double)buffer.getElem(y * width * 3 + x * 3 + offset);
}
public int getWidth() {
@@ -74,4 +75,8 @@
public int getHeight() {
return height;
}
+
+ private double getSelectionValue(int x, int y) {
+ return 0.0;
+ }
}
Added: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java (rev 0)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java 2008-06-20 04:30:38 UTC (rev 31)
@@ -0,0 +1,57 @@
+/*
+ * pixelle - Graphics algorithmic editor
+ * Copyright (C) 2008 Dave Brosius
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.mebigfatguy.pixelle;
+
+import java.awt.image.BufferedImage;
+
+import com.mebigfatguy.pixelle.eval.PixelleEval3ByteBGR;
+
+public class PixelleEvalFactory {
+
+ private PixelleEvalFactory() {
+ }
+
+ public static PixelleEval create(PixelleImage image) throws IllegalArgumentException {
+
+ switch (image.getType()) {
+ case BufferedImage.TYPE_3BYTE_BGR:
+ return new PixelleEval3ByteBGR(image);
+
+ case BufferedImage.TYPE_4BYTE_ABGR:
+ break;
+
+ case BufferedImage.TYPE_BYTE_BINARY:
+ break;
+
+ case BufferedImage.TYPE_BYTE_GRAY:
+ break;
+
+ case BufferedImage.TYPE_INT_ARGB:
+ break;
+
+ case BufferedImage.TYPE_INT_BGR:
+ break;
+
+ case BufferedImage.TYPE_INT_RGB:
+ break;
+ }
+
+ throw new IllegalArgumentException("Unknown image type: " + image.getType());
+ }
+}
Property changes on: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java 2008-06-20 03:55:36 UTC (rev 30)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java 2008-06-20 04:30:38 UTC (rev 31)
@@ -23,6 +23,7 @@
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
+import java.awt.image.SampleModel;
public class PixelleImage {
@@ -37,6 +38,10 @@
selection = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_BINARY, bw);
}
+ public int getType() {
+ return image.getType();
+ }
+
public int getWidth() {
return image.getWidth();
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-20 03:55:36 UTC (rev 30)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-20 04:30:38 UTC (rev 31)
@@ -44,7 +44,7 @@
public PixelleImage transform() {
try {
- PixelleEval pe = new PixelleEval(srcImage);
+ PixelleEval pe = PixelleEvalFactory.create(srcImage);
PixelleClassLoader pcl = AccessController.doPrivileged(new PrivilegedAction<PixelleClassLoader>() {
public PixelleClassLoader run() {
return new PixelleClassLoader(Thread.currentThread().getContextClassLoader());
Added: trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java (rev 0)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java 2008-06-20 04:30:38 UTC (rev 31)
@@ -0,0 +1,32 @@
+package com.mebigfatguy.pixelle.eval;
+
+import com.mebigfatguy.pixelle.PixelleEval;
+import com.mebigfatguy.pixelle.PixelleImage;
+
+public class PixelleEval3ByteBGR extends PixelleEval {
+
+ public PixelleEval3ByteBGR(PixelleImage srcImage) {
+ super(srcImage);
+ }
+
+ @Override
+ public double getBlueValue(int x, int y) {
+ return (double)buffer.getElem(y * width * 3 + x * 3);
+ }
+
+ @Override
+ public double getGreenValue(int x, int y) {
+ return (double)buffer.getElem(y * width * 3 + x * 3 + 1);
+ }
+
+ @Override
+ public double getRedValue(int x, int y) {
+ return (double)buffer.getElem(y * width * 3 + x * 3 + 2);
+ }
+
+ @Override
+ public double getTransparencyValue(int x, int y) {
+ return 0;
+ }
+
+}
Property changes on: trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|