[Pixelle-commit] SF.net SVN: pixelle: [123] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-29 05:17:36
|
Revision: 123
http://pixelle.svn.sourceforge.net/pixelle/?rev=123&view=rev
Author: dbrosius
Date: 2008-06-28 22:17:24 -0700 (Sat, 28 Jun 2008)
Log Message:
-----------
implement color oob options
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java
trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval4ByteABGR.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-29 04:49:45 UTC (rev 122)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java 2008-06-29 05:17:24 UTC (rev 123)
@@ -31,21 +31,24 @@
protected DataBuffer buffer;
protected int width;
protected int height;
- protected IndexOutOfBoundsOption oobOption;
+ protected IndexOutOfBoundsOption ioobOption;
+ protected ColorOutOfBoundsOption coobOption;
private int selectionByte;
/**
* create an evaluator for a specific image and options
*
* @param image the image to evaluate
- * @param option the out of bounds pixels option to use
+ * @param iOption the out of bounds pixels option to use
+ * @param cOption TODO
*/
- public PixelleEval(PixelleImage image, IndexOutOfBoundsOption option) {
+ public PixelleEval(PixelleImage image, IndexOutOfBoundsOption iOption, ColorOutOfBoundsOption cOption) {
srcImage = image;
buffer = image.getBuffer();
width = image.getWidth();
height = image.getHeight();
- oobOption = option;
+ ioobOption = iOption;
+ coobOption = cOption;
}
/**
@@ -95,9 +98,9 @@
/* in the future, allow customization of out of bounds indices */
if (((x < 0) || (x >= width)) || ((y < 0) || (y >= height))) {
- switch (oobOption) {
+ switch (ioobOption) {
case SpecifiedColor:
- Color c = oobOption.getColor();
+ Color c = ioobOption.getColor();
switch (pixelSpec) {
case 'r':
return c.getRed();
@@ -206,4 +209,48 @@
if (((x & 0x07) == 7) || (x == imageWidth))
srcImage.setSelectionByte(x >> 3, y, selectionByte);
}
+
+ /**
+ * adjust out of bounds colors by applying rules of ColorOutOfBoundsOption
+ * @param value the input color value
+ * @return the output color value
+ */
+ protected double adjustColor(double value) {
+ if ((value >= 0.0) && (value <= 255.0))
+ return value;
+
+ switch (coobOption) {
+
+ case Roll: {
+ int ival = (int)(value + 0.49) % 256;
+ return (double)ival;
+ }
+
+ case Wave: {
+ int ival = (int)(value + 0.49);
+ int period = ival / 256;
+ if ((period & 0x01) != 0) {
+ if (ival > 0)
+ ival = 255 - (ival+1) & 0x00FF;
+ else
+ ival = ival & 0x00FF;
+ }
+ else {
+ if (ival > 0)
+ ival = ival & 0x00FF;
+ else
+ ival = 256 - ival & 0x00FF;
+ }
+ return (double)ival;
+ }
+
+ case Clip:
+ default: {
+ if (value < 0.0)
+ return 0.0;
+ else
+ return 255.0;
+ }
+ }
+ }
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java 2008-06-29 04:49:45 UTC (rev 122)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEvalFactory.java 2008-06-29 05:17:24 UTC (rev 123)
@@ -52,10 +52,10 @@
switch (image.getType()) {
case BufferedImage.TYPE_3BYTE_BGR:
- return new PixelleEval3ByteBGR(image, ioobOption);
+ return new PixelleEval3ByteBGR(image, ioobOption, coobOption);
case BufferedImage.TYPE_4BYTE_ABGR:
- return new PixelleEval4ByteABGR(image, ioobOption);
+ return new PixelleEval4ByteABGR(image, ioobOption, coobOption);
case BufferedImage.TYPE_BYTE_BINARY:
break;
@@ -64,7 +64,7 @@
break;
case BufferedImage.TYPE_BYTE_GRAY:
- return new PixelleEvalByteGray(image, ioobOption);
+ return new PixelleEvalByteGray(image, ioobOption, coobOption);
case BufferedImage.TYPE_INT_ARGB:
break;
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-29 04:49:45 UTC (rev 122)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-29 05:17:24 UTC (rev 123)
@@ -86,7 +86,7 @@
PixelleImage destImage = new PixelleImage(new BufferedImage(srcImage.getWidth(), srcImage.getHeight(), BufferedImage.TYPE_4BYTE_ABGR));
PixelleEval srcPE = PixelleEvalFactory.create(srcImage);
- PixelleEval4ByteABGR destPE = new PixelleEval4ByteABGR(destImage, IndexOutOfBoundsOption.BorderColor);
+ PixelleEval4ByteABGR destPE = new PixelleEval4ByteABGR(destImage, PixelleEvalFactory.getIndexOutOfBoundsOption(), PixelleEvalFactory.getColorOutOfBoundsOption());
PixelleClassLoader pcl = AccessController.doPrivileged(new PrivilegedAction<PixelleClassLoader>() {
public PixelleClassLoader run() {
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java 2008-06-29 04:49:45 UTC (rev 122)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval3ByteBGR.java 2008-06-29 05:17:24 UTC (rev 123)
@@ -18,14 +18,15 @@
*/
package com.mebigfatguy.pixelle.eval;
+import com.mebigfatguy.pixelle.ColorOutOfBoundsOption;
import com.mebigfatguy.pixelle.IndexOutOfBoundsOption;
import com.mebigfatguy.pixelle.PixelleEval;
import com.mebigfatguy.pixelle.PixelleImage;
public class PixelleEval3ByteBGR extends PixelleEval {
- public PixelleEval3ByteBGR(PixelleImage srcImage, IndexOutOfBoundsOption option) {
- super(srcImage, option);
+ public PixelleEval3ByteBGR(PixelleImage srcImage, IndexOutOfBoundsOption iOption, ColorOutOfBoundsOption cOption) {
+ super(srcImage, iOption, cOption);
}
@Override
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval4ByteABGR.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval4ByteABGR.java 2008-06-29 04:49:45 UTC (rev 122)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEval4ByteABGR.java 2008-06-29 05:17:24 UTC (rev 123)
@@ -18,14 +18,15 @@
*/
package com.mebigfatguy.pixelle.eval;
+import com.mebigfatguy.pixelle.ColorOutOfBoundsOption;
import com.mebigfatguy.pixelle.IndexOutOfBoundsOption;
import com.mebigfatguy.pixelle.PixelleEval;
import com.mebigfatguy.pixelle.PixelleImage;
public class PixelleEval4ByteABGR extends PixelleEval {
- public PixelleEval4ByteABGR(PixelleImage srcImage, IndexOutOfBoundsOption option) {
- super(srcImage, option);
+ public PixelleEval4ByteABGR(PixelleImage srcImage, IndexOutOfBoundsOption iOption, ColorOutOfBoundsOption cOption) {
+ super(srcImage, iOption, cOption);
}
@Override
@@ -50,10 +51,7 @@
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;
+ value = adjustColor(value);
switch (pixelSpec) {
case 't':
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEvalByteGray.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEvalByteGray.java 2008-06-29 04:49:45 UTC (rev 122)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/eval/PixelleEvalByteGray.java 2008-06-29 05:17:24 UTC (rev 123)
@@ -18,14 +18,15 @@
*/
package com.mebigfatguy.pixelle.eval;
+import com.mebigfatguy.pixelle.ColorOutOfBoundsOption;
import com.mebigfatguy.pixelle.IndexOutOfBoundsOption;
import com.mebigfatguy.pixelle.PixelleEval;
import com.mebigfatguy.pixelle.PixelleImage;
public class PixelleEvalByteGray extends PixelleEval {
- public PixelleEvalByteGray(PixelleImage srcImage, IndexOutOfBoundsOption option) {
- super(srcImage, option);
+ public PixelleEvalByteGray(PixelleImage srcImage, IndexOutOfBoundsOption iOption, ColorOutOfBoundsOption cOption) {
+ super(srcImage, iOption, cOption);
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|