# HG changeset patch # User Jason Maltzen # Date 2016-03-04 06:23:05 # Node ID eee2a6a0c86bc739853b61d05cb349f359d537bb # Parent 41086220d0812061e7c682a83449f1c5cdd69a52 Loosen checks on testing for papyrus texture some more. Allow for a bit of error there, as long as everything else checks out. diff --git a/MainWindow.cs b/MainWindow.cs --- a/MainWindow.cs +++ b/MainWindow.cs @@ -29,7 +29,7 @@ using DesertPaintLab; public partial class MainWindow : Gtk.Window { - const string APP_VERSION = "1.7.13"; + const string APP_VERSION = "1.7.14"; bool unsavedData = false; bool shouldShutDown = false; diff --git a/ReactionRecorder.cs b/ReactionRecorder.cs --- a/ReactionRecorder.cs +++ b/ReactionRecorder.cs @@ -96,22 +96,23 @@ namespace DesertPaintLab byte b = pixBytes[testPixelStart+2]; bool isDarkPixel = false; - bool isPapyAbove = false; - bool isPapyBelow = false; + //bool isPapyAbove = false; + //bool isPapyBelow = false; // 1.) Check if the top pixel is a dark pixel. isDarkPixel = IsDarkPixel(r, g, b); // ((r < 0x46) && (g < 0x46) && (b < 0x46)); - // 2.) Check the pixel above it to see if it's from the papy texture. - int otherPixelStart = testPixelStart - stride; - isPapyAbove = ((otherPixelStart >= 0) && - IsPapyTexture(pixBytes[otherPixelStart++], pixBytes[otherPixelStart++], pixBytes[otherPixelStart])); + //// 2.) Check the pixel above it to see if it's from the papy texture. + //int otherPixelStart = testPixelStart - stride; + //isPapyAbove = ((otherPixelStart >= 0) && + // IsPapyTexture(pixBytes[otherPixelStart++], pixBytes[otherPixelStart++], pixBytes[otherPixelStart])); - // 3.) Check the pixel below where the swatch should be to see if it's also from the papy texture. - otherPixelStart = testPixelStart + (stride * swatchHeight); - isPapyBelow = (IsPapyTexture(pixBytes[otherPixelStart++], pixBytes[otherPixelStart++], pixBytes[otherPixelStart])); + //// 3.) Check the pixel below where the swatch should be to see if it's also from the papy texture. + //otherPixelStart = testPixelStart + (stride * swatchHeight); + //isPapyBelow = (IsPapyTexture(pixBytes[otherPixelStart++], pixBytes[otherPixelStart++], pixBytes[otherPixelStart])); - bool result = isDarkPixel && isPapyAbove && isPapyBelow; + //bool result = isDarkPixel && isPapyAbove && isPapyBelow; + bool result = isDarkPixel; // grab the swatch color int swatchColorStart = testPixelStart + (2 * pixelMultiplier * stride); // 2 rows below the test pixel, skipping the faded color @@ -122,7 +123,7 @@ namespace DesertPaintLab // scan the column from 2 below the top to 2 above the bottom to ensure the color matches for (int i = (2*pixelMultiplier); result && (i < swatchHeight-(2*pixelMultiplier)); ++i) { - otherPixelStart = testPixelStart + (stride * i); + int otherPixelStart = testPixelStart + (stride * i); result &= IsColorMatch(pixBytes[otherPixelStart], pixBytes[otherPixelStart+1], pixBytes[otherPixelStart+2], r, g, b); } @@ -141,15 +142,17 @@ namespace DesertPaintLab result &= IsDarkPixel(pixBytes[otherPixelStart], pixBytes[otherPixelStart+1], pixBytes[otherPixelStart+2]); } - // test the dark top border and for papyrus below the swatch + // test the dark top border and for papyrus above and below the swatch + int papyErrorCount = 0; for (int i = 0; result && (i < swatchWidth); ++i) { int otherPixelStart = testPixelStart + (3 * i); result &= IsDarkPixel(pixBytes[otherPixelStart], pixBytes[otherPixelStart+1], pixBytes[otherPixelStart+2]); otherPixelStart = otherPixelStart - stride; - result &= IsPapyTexture(pixBytes[otherPixelStart], pixBytes[otherPixelStart+1], pixBytes[otherPixelStart+2]); + papyErrorCount += (IsPapyTexture(pixBytes[otherPixelStart], pixBytes[otherPixelStart+1], pixBytes[otherPixelStart+2]) ? 1 : 0); otherPixelStart = testPixelStart + (stride * swatchHeight) + (3 * i); - result &= IsPapyTexture(pixBytes[otherPixelStart], pixBytes[otherPixelStart+1], pixBytes[otherPixelStart+2]); + papyErrorCount += (IsPapyTexture(pixBytes[otherPixelStart], pixBytes[otherPixelStart+1], pixBytes[otherPixelStart+2]) ? 1 : 0); + result &= (papyErrorCount < (swatchWidth / 20)); // allow up to 5% error rate checking for papy texture, because this seems to be inconsistent } return result; @@ -187,7 +190,7 @@ namespace DesertPaintLab // 4.) Scan the left border of the potential swatch // location. colorMatch = true; - for (int i = 1; i < swatchHeight - 2; ++i) + for (int i = 2; i < swatchHeight - (2 * pixelMultiplier); ++i) { otherPixelStart = pixelStart + (stride * i); if (!IsColorMatch(pixel_r, pixel_g, pixel_b, pixBytes[otherPixelStart], pixBytes[otherPixelStart+1], pixBytes[otherPixelStart+2])) diff --git a/gtk-gui/MainWindow.cs b/gtk-gui/MainWindow.cs --- a/gtk-gui/MainWindow.cs +++ b/gtk-gui/MainWindow.cs @@ -92,7 +92,7 @@ public partial class MainWindow this.SimulatorAction.ShortLabel = "Simulator"; w1.Add (this.SimulatorAction, null); this.RecipeGeneratorAction = new global::Gtk.RadioAction ("RecipeGeneratorAction", "Recipe Generator", null, null, 0); - this.RecipeGeneratorAction.Group = this.SimulatorAction.Group; + this.RecipeGeneratorAction.Group = this.CaptureAction.Group; this.RecipeGeneratorAction.ShortLabel = "Recipe Generator"; w1.Add (this.RecipeGeneratorAction, null); this.RecipesAction = new global::Gtk.Action ("RecipesAction", "Recipes...", null, null);