[Pixelle-commit] SF.net SVN: pixelle:[294] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-07-22 05:43:18
|
Revision: 294
http://pixelle.svn.sourceforge.net/pixelle/?rev=294&view=rev
Author: dbrosius
Date: 2009-07-22 05:43:15 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
start building selection outline
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java
trunk/pixelle/src/com/mebigfatguy/pixelle/SelectionOutliner.java
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java 2009-07-22 03:49:52 UTC (rev 293)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java 2009-07-22 05:43:15 UTC (rev 294)
@@ -48,7 +48,7 @@
byte[] alpha = new byte[] {0, -1};
IndexColorModel model = new IndexColorModel(1, 2, wb, wb, wb, alpha);
selection = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_BINARY, model);
- composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f);
+ composite = AlphaComposite.getInstance(AlphaComposite.XOR, 0.5f);
Graphics g = selection.getGraphics();
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(), getHeight());
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/SelectionOutliner.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/SelectionOutliner.java 2009-07-22 03:49:52 UTC (rev 293)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/SelectionOutliner.java 2009-07-22 05:43:15 UTC (rev 294)
@@ -18,20 +18,49 @@
*/
package com.mebigfatguy.pixelle;
-import java.awt.Color;
-import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.IndexColorModel;
+import java.awt.image.WritableRaster;
public class SelectionOutliner {
public BufferedImage createOutline(BufferedImage selectionImage) {
BufferedImage outlineSelection = new BufferedImage(selectionImage.getWidth(), selectionImage.getHeight(), BufferedImage.TYPE_BYTE_BINARY, (IndexColorModel)selectionImage.getColorModel());
- Graphics g = selectionImage.getGraphics();
- g.setColor(Color.WHITE);
- g.fillRect(0, 0, selectionImage.getWidth(), selectionImage.getHeight());
+ int width = selectionImage.getWidth();
+ int height = selectionImage.getHeight();
+ WritableRaster outRaster = outlineSelection.getRaster();
+ WritableRaster inRaster = selectionImage.getRaster();
+
+ double[] pixel = new double[9];
+
+ for (int row = 0; row < height; row++) {
+ boolean yedge = (row == 0) || (row == (height - 1));
+
+ for (int col = 0; col < width; col++) {
+ pixel = inRaster.getPixel(col, row, pixel);
+
+ // If the current pixel is selected, look to see if it's got a non selected pixel next to it
+ if (pixel[0] != 0) {
+ boolean xedge = false;
+ if (!yedge) {
+ xedge = (col == 0) || (col == (width - 1));
+ }
+
+ if (!xedge && !yedge) {
+ pixel = inRaster.getPixels(col - 1, row - 1, 3, 3, pixel);
+ for (int p = 0; p < 9; p++) {
+ if (pixel[p] == 0) {
+ break;
+ }
+ }
+ pixel[0] = 0.0;
+ }
+ outRaster.setPixel(col, row, pixel);
+ }
+ }
+ }
return outlineSelection;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|