private IColor ProcessXor(IColor source, IColor mask)
        {
            ColorByte retVal      = new ColorByte();
            Color     sourceColor = source.ToColor();
            Color     maskColor   = mask.ToColor();

            retVal.A = (IgnoreAlphaChannel) ? source.A : (byte)(sourceColor.A ^ maskColor.A);
            retVal.R = (byte)(sourceColor.R ^ maskColor.R);
            retVal.G = (byte)(sourceColor.G ^ maskColor.G);
            retVal.B = (byte)(sourceColor.B ^ maskColor.B);
            return(retVal);
        }
Example #2
0
        private AvalonTypographer()
        {
            //

            // another Dev Hack to avoid throwing by missing Dispatcher
//                Dispatcher uct = new Dispatcher();
//                uct.Enter();
//                Window win = new Window(uct);
            Window win = new Window();

            ForegroundColor = new ColorByte(255, 0, 0, 0);
            BackgroundColor = new ColorByte(255, 255, 255, 255);
        }
Example #3
0
 public static byte Min(ColorByte color)
 {
     if (color.Blue < color.Green && color.Blue < color.Red)
     {
         return(color.Blue);
     }
     else if (color.Green < color.Blue && color.Green < color.Red)
     {
         return(color.Green);
     }
     else
     {
         return(color.Red);
     }
 }
Example #4
0
        /// <summary>
        /// Gaussian Filter constructor
        /// </summary>
        public MorphologicalFilter()
        {
            IColor          white           = new ColorByte(255, 255, 255, 255);
            IColor          black           = new ColorByte(255, 0, 0, 0);
            FilterParameter iteration       = new FilterParameter(ITERATION, "Number of Iteration", (int)1);
            FilterParameter outward         = new FilterParameter(OUTWARD, "Direction of the morphological filter", true);
            FilterParameter foregroundColor = new FilterParameter(FOREGROUNDCOLOR, "ForeGround color", (IColor)white);
            FilterParameter backgroundColor = new FilterParameter(BACKGROUNDCOLOR, "BackGround color", (IColor)black);

            AddParameter(iteration);
            AddParameter(outward);
            AddParameter(foregroundColor);
            AddParameter(backgroundColor);

            ForegroundColor = white;
            BackgroundColor = black;
        }
Example #5
0
    public void SetScreenRect(Vector2Int start, Vector2Int end)
    {
        startScreen  = start;
        endScreen    = end;
        screenWidth  = endScreen.x - startScreen.x;
        screenHeight = endScreen.y - startScreen.y;

        oldMinPos = minPos;
        oldMaxPos = maxPos;

        minPos = new Vector2Int(startScreen.x - RaySize, startScreen.y - RaySize);
        maxPos = new Vector2Int(endScreen.x + RaySize, endScreen.y + RaySize);
        // Debug.LogError(screenWidth);
        // Debug.LogError(screenHeight);
        if (color == null)  //}|| screenWidth + 2*offScreenTiles + 10 != color.GetLength(0)) {
        {
            color = new ColorByte[screenWidth + 2 * RaySize + 10, screenHeight + 2 * RaySize + 10];
        }
    }
Example #6
0
        private void CreateLUT()
        {
            // Create curve for color transition (inner to outer color)
            double dist = 0.0;

            for (int i = 0; i < _gaussLUT.Length; i++)
            {
                _gaussLUT[i] = (float)Math.Pow(Math.E, -dist * dist);
                dist        += 0.01;
            }

            // Create Composition Lookup Table
            double scale1 = float.NaN;
            double scale2 = float.NaN;
            double premul = float.NaN;
            IColor color  = null;

            for (int i = 0; i < _blendLUT.Length; i++)
            {
                color        = new ColorByte();
                scale1       = i / color.NormalizedValue;
                scale2       = (color.NormalizedValue - i) / color.NormalizedValue;
                color.Alpha  = InnerColor.A / color.NormalizedValue * scale1 + OuterColor.A / color.NormalizedValue * scale2;
                premul       = color.Alpha;
                color.Red    = premul * InnerColor.R / color.NormalizedValue * scale1 + OuterColor.R / color.NormalizedValue * scale2;
                color.Green  = premul * InnerColor.G / color.NormalizedValue * scale1 + OuterColor.G / color.NormalizedValue * scale2;
                color.Blue   = premul * InnerColor.B / color.NormalizedValue * scale1 + OuterColor.B / color.NormalizedValue * scale2;
                _blendLUT[i] = color;
            }

/*
 * ImageAdapter test = new ImageAdapter(256,256);
 * for(int y=0;y<256;y++)
 * {
 * for(int x=0;x<256;x++)
 * {
 * test[x, y] = _blendLUT[x];
 * }
 * }
 * test.ToBitmap().Save("c:\\test.png");
 */
        }
Example #7
0
    public void Test()
    {
        ColorByte [,] colorTmp = new ColorByte[screenWidth + 2 * RaySize + 10, screenHeight + 2 * RaySize + 10];
        var sizeX = color.GetLength(0) - 1;
        var sizeY = color.GetLength(1) - 1;

        for (int x = 0; x < sizeX; x++)
        {
            for (int y = 0; y < sizeY; y++)
            {
                colorTmp[x, y] = new ColorByte(0, 0, 0, (int)color[x, y].A);
            }
        }

        for (int i = 0; i < 100; i++)
        {
            var xTest = UnityEngine.Random.Range(minPos.x, maxPos.x);
            var yTest = UnityEngine.Random.Range(minPos.y, maxPos.y);
            OutRectLightTiles(xTest, xTest, yTest, yTest, true);
            Test2(ref colorTmp, ref color);
        }
    }
Example #8
0
 static KnownColors()
 {
     TransparentBlack     = new ColorByte(0);
     Transparent          = new ColorByte(0);
     AliceBlue            = new ColorByte(0xfffff8f0);
     AntiqueWhite         = new ColorByte(0xffd7ebfa);
     Aqua                 = new ColorByte(0xffffff00);
     Aquamarine           = new ColorByte(0xffd4ff7f);
     Azure                = new ColorByte(0xfffffff0);
     Beige                = new ColorByte(0xffdcf5f5);
     Bisque               = new ColorByte(0xffc4e4ff);
     Black                = new ColorByte(0xff000000);
     BlanchedAlmond       = new ColorByte(0xffcdebff);
     Blue                 = new ColorByte(0xffff0000);
     BlueViolet           = new ColorByte(0xffe22b8a);
     Brown                = new ColorByte(0xff2a2aa5);
     BurlyWood            = new ColorByte(0xff87b8de);
     CadetBlue            = new ColorByte(0xffa09e5f);
     Chartreuse           = new ColorByte(0xff00ff7f);
     Chocolate            = new ColorByte(0xff1e69d2);
     Coral                = new ColorByte(0xff507fff);
     CornflowerBlue       = new ColorByte(0xffed9564);
     Cornsilk             = new ColorByte(0xffdcf8ff);
     Crimson              = new ColorByte(0xff3c14dc);
     Cyan                 = new ColorByte(0xffffff00);
     DarkBlue             = new ColorByte(0xff8b0000);
     DarkCyan             = new ColorByte(0xff8b8b00);
     DarkGoldenrod        = new ColorByte(0xff0b86b8);
     DarkGray             = new ColorByte(0xffa9a9a9);
     DarkGreen            = new ColorByte(0xff006400);
     DarkKhaki            = new ColorByte(0xff6bb7bd);
     DarkMagenta          = new ColorByte(0xff8b008b);
     DarkOliveGreen       = new ColorByte(0xff2f6b55);
     DarkOrange           = new ColorByte(0xff008cff);
     DarkOrchid           = new ColorByte(0xffcc3299);
     DarkRed              = new ColorByte(0xff00008b);
     DarkSalmon           = new ColorByte(0xff7a96e9);
     DarkSeaGreen         = new ColorByte(0xff8bbc8f);
     DarkSlateBlue        = new ColorByte(0xff8b3d48);
     DarkSlateGray        = new ColorByte(0xff4f4f2f);
     DarkTurquoise        = new ColorByte(0xffd1ce00);
     DarkViolet           = new ColorByte(0xffd30094);
     DeepPink             = new ColorByte(0xff9314ff);
     DeepSkyBlue          = new ColorByte(0xffffbf00);
     DimGray              = new ColorByte(0xff696969);
     DodgerBlue           = new ColorByte(0xffff901e);
     Firebrick            = new ColorByte(0xff2222b2);
     FloralWhite          = new ColorByte(0xfff0faff);
     ForestGreen          = new ColorByte(0xff228b22);
     Fuchsia              = new ColorByte(0xffff00ff);
     Gainsboro            = new ColorByte(0xffdcdcdc);
     GhostWhite           = new ColorByte(0xfffff8f8);
     Gold                 = new ColorByte(0xff00d7ff);
     Goldenrod            = new ColorByte(0xff20a5da);
     Gray                 = new ColorByte(0xff808080);
     Green                = new ColorByte(0xff008000);
     GreenYellow          = new ColorByte(0xff2fffad);
     Honeydew             = new ColorByte(0xfff0fff0);
     HotPink              = new ColorByte(0xffb469ff);
     IndianRed            = new ColorByte(0xff5c5ccd);
     Indigo               = new ColorByte(0xff82004b);
     Ivory                = new ColorByte(0xfff0ffff);
     Khaki                = new ColorByte(0xff8ce6f0);
     Lavender             = new ColorByte(0xfffae6e6);
     LavenderBlush        = new ColorByte(0xfff5f0ff);
     LawnGreen            = new ColorByte(0xff00fc7c);
     LemonChiffon         = new ColorByte(0xffcdfaff);
     LightBlue            = new ColorByte(0xffe6d8ad);
     LightCoral           = new ColorByte(0xff8080f0);
     LightCyan            = new ColorByte(0xffffffe0);
     LightGoldenrodYellow = new ColorByte(0xffd2fafa);
     LightGray            = new ColorByte(0xffd3d3d3);
     LightGreen           = new ColorByte(0xff90ee90);
     LightPink            = new ColorByte(0xffc1b6ff);
     LightSalmon          = new ColorByte(0xff7aa0ff);
     LightSeaGreen        = new ColorByte(0xffaab220);
     LightSkyBlue         = new ColorByte(0xffface87);
     LightSlateGray       = new ColorByte(0xff998877);
     LightSteelBlue       = new ColorByte(0xffdec4b0);
     LightYellow          = new ColorByte(0xffe0ffff);
     Lime                 = new ColorByte(0xff00ff00);
     LimeGreen            = new ColorByte(0xff32cd32);
     Linen                = new ColorByte(0xffe6f0fa);
     Magenta              = new ColorByte(0xffff00ff);
     Maroon               = new ColorByte(0xff000080);
     MediumAquamarine     = new ColorByte(0xffaacd66);
     MediumBlue           = new ColorByte(0xffcd0000);
     MediumOrchid         = new ColorByte(0xffd355ba);
     MediumPurple         = new ColorByte(0xffdb7093);
     MediumSeaGreen       = new ColorByte(0xff71b33c);
     MediumSlateBlue      = new ColorByte(0xffee687b);
     MediumSpringGreen    = new ColorByte(0xff9afa00);
     MediumTurquoise      = new ColorByte(0xffccd148);
     MediumVioletRed      = new ColorByte(0xff8515c7);
     MidnightBlue         = new ColorByte(0xff701919);
     MintCream            = new ColorByte(0xfffafff5);
     MistyRose            = new ColorByte(0xffe1e4ff);
     Moccasin             = new ColorByte(0xffb5e4ff);
     MonoGameOrange       = new ColorByte(0xff003ce7);
     NavajoWhite          = new ColorByte(0xffaddeff);
     Navy                 = new ColorByte(0xff800000);
     OldLace              = new ColorByte(0xffe6f5fd);
     Olive                = new ColorByte(0xff008080);
     OliveDrab            = new ColorByte(0xff238e6b);
     Orange               = new ColorByte(0xff00a5ff);
     OrangeRed            = new ColorByte(0xff0045ff);
     Orchid               = new ColorByte(0xffd670da);
     PaleGoldenrod        = new ColorByte(0xffaae8ee);
     PaleGreen            = new ColorByte(0xff98fb98);
     PaleTurquoise        = new ColorByte(0xffeeeeaf);
     PaleVioletRed        = new ColorByte(0xff9370db);
     PapayaWhip           = new ColorByte(0xffd5efff);
     PeachPuff            = new ColorByte(0xffb9daff);
     Peru                 = new ColorByte(0xff3f85cd);
     Pink                 = new ColorByte(0xffcbc0ff);
     Plum                 = new ColorByte(0xffdda0dd);
     PowderBlue           = new ColorByte(0xffe6e0b0);
     Purple               = new ColorByte(0xff800080);
     Red         = new ColorByte(0xff0000ff);
     RosyBrown   = new ColorByte(0xff8f8fbc);
     RoyalBlue   = new ColorByte(0xffe16941);
     SaddleBrown = new ColorByte(0xff13458b);
     Salmon      = new ColorByte(0xff7280fa);
     SandyBrown  = new ColorByte(0xff60a4f4);
     SeaGreen    = new ColorByte(0xff578b2e);
     SeaShell    = new ColorByte(0xffeef5ff);
     Sienna      = new ColorByte(0xff2d52a0);
     Silver      = new ColorByte(0xffc0c0c0);
     SkyBlue     = new ColorByte(0xffebce87);
     SlateBlue   = new ColorByte(0xffcd5a6a);
     SlateGray   = new ColorByte(0xff908070);
     Snow        = new ColorByte(0xfffafaff);
     SpringGreen = new ColorByte(0xff7fff00);
     SteelBlue   = new ColorByte(0xffb48246);
     Tan         = new ColorByte(0xff8cb4d2);
     Teal        = new ColorByte(0xff808000);
     Thistle     = new ColorByte(0xffd8bfd8);
     Tomato      = new ColorByte(0xff4763ff);
     Turquoise   = new ColorByte(0xffd0e040);
     Violet      = new ColorByte(0xffee82ee);
     Wheat       = new ColorByte(0xffb3def5);
     White       = new ColorByte(uint.MaxValue);
     WhiteSmoke  = new ColorByte(0xfff5f5f5);
     Yellow      = new ColorByte(0xff00ffff);
     YellowGreen = new ColorByte(0xff32cd9a);
 }
Example #9
0
        /// <summary>
        /// Compares this(Rendered img) to model created for masterFileName
        /// </summary>
        /// <param name="masterImg">Contains master img</param>
        /// <param name="vscanFileName">.vscan file name - cab which will package failures</param>
        /// <param name="silhouetteTolerance">Silhouette tolerance</param>
        /// <param name="xTolerance">x shift tolerance</param>
        /// <param name="yTolerance">y shift tolerance</param>
        /// <param name="imgTolerance">image tolerance</param>
        /// <param name="a">A part of ARGB tolerance</param>
        /// <param name="r">R part of ARGB tolerance</param>
        /// <param name="g">G part of ARGB tolerance</param>
        /// <param name="b">B part of ARGB tolerance</param>
        /// <param name="rcToCompareLeft">Rectangle-part of the image which will be compared. 0 if whole image will be compared</param>
        /// <param name="rcToCompareTop">Rectangle-part of the image which will be compared. 0 if whole image will be compared</param>
        /// <param name="rcToCompareRight">Rectangle-part of the image which will be compared. 0 if whole image will be compared</param>
        /// <param name="rcToCompareBottom">Rectangle-part of the image which will be compared. 0 if whole image will be compared</param>
        /// <returns>Returns true if every descriptor in the model was found (within tolerance), false otherwise</returns>
        bool IModelManager2Unmanaged.CompareModelsSavePackage(IImageAdapterUnmanaged masterImg,
                                                              string vscanFileName,
                                                              double silhouetteTolerance,
                                                              double xTolerance,
                                                              double yTolerance,
                                                              double imgTolerance,
                                                              byte a,
                                                              byte r,
                                                              byte g,
                                                              byte b,
                                                              int rcToCompareLeft,
                                                              int rcToCompareTop,
                                                              int rcToCompareRight,
                                                              int rcToCompareBottom
                                                              )
        {
            System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Started");
#if DEBUG
            ImageUtility.ToImageFile(masterImg, System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Before_CMSP_masterImage.png"));
            ImageUtility.ToImageFile(Image, System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Before_CMSP_thisImage.png"));
#endif // debug

//logging

            bool    comparisonResult = false;
            VScan   master           = null;
            VScan   rendered         = new VScan((IImageAdapter)Image.Clone());
            XmlNode xmlDiff          = null;
            if (!(rcToCompareLeft == 0 && rcToCompareTop == 0 && rcToCompareRight == 0 && rcToCompareBottom == 0))
            {
                Rectangle     rcToCompare = new Rectangle(rcToCompareLeft, rcToCompareTop, rcToCompareRight - rcToCompareLeft, rcToCompareBottom - rcToCompareTop);
                IImageAdapter imgAdapter  = ImageUtility.ClipImageAdapter(rendered.OriginalData.Image, rcToCompare);
                rendered.OriginalData.Image = imgAdapter;
                master = new VScan(ImageUtility.ClipImageAdapter((ImageAdapter)masterImg, rcToCompare));
            }
            else
            {
                master = new VScan((IImageAdapter)masterImg);
            }
#if DEBUG
            ImageUtility.ToImageFile(master.OriginalData.Image, System.IO.Path.Combine(System.IO.Path.GetTempPath(), "CMSP_master.png"));
            ImageUtility.ToImageFile(rendered.OriginalData.Image, System.IO.Path.Combine(System.IO.Path.GetTempPath(), "CMSP_rendered.png"));
#endif // debug
            System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage(): images created");

            System.Diagnostics.Debug.WriteLine(string.Format("color to be created a:{0} r:{1} g:{2} b:{3}", a, r, g, b));
            IColor color = new ColorByte(a, r, g, b);
            System.Diagnostics.Debug.WriteLine("color created");
            if (color.ARGB == 0)
            {
                color.IsEmpty = true;
            }
            System.Diagnostics.Debug.WriteLine("coor just reset to empty (if necessary)");

            System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage(): color created");

            ((IModelManager2Unmanaged)master.OriginalData).CreateModel(silhouetteTolerance,
                                                                       xTolerance,
                                                                       yTolerance,
                                                                       imgTolerance,
                                                                       color);

            System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage(): CreateModel() completed");

            System.Diagnostics.Debug.WriteLine("Comparing...");
            comparisonResult = rendered.OriginalData.CompareModels(master.OriginalData);
            System.Diagnostics.Debug.WriteLine("Compare model returned " + comparisonResult.ToString());

            // Workaround for the
            if (comparisonResult == false)
            {
                System.Diagnostics.Debug.WriteLine("\nChanging color threshlod...");
                master.OriginalData.Descriptors.ColorThreshold   = master.OriginalData.Descriptors.ColorThreshold + 1;
                rendered.OriginalData.Descriptors.ColorThreshold = rendered.OriginalData.Descriptors.ColorThreshold + 1;
                System.Diagnostics.Debug.WriteLine("Analyzing master...");
                master.OriginalData.Analyze();
                System.Diagnostics.Debug.WriteLine("Analyzing rendered...");
                rendered.OriginalData.Analyze();
                System.Diagnostics.Debug.WriteLine("Comparing again...");
                comparisonResult = rendered.OriginalData.CompareModels(master.OriginalData);
                System.Diagnostics.Debug.WriteLine("Getting xml diff...");
                xmlDiff = rendered.OriginalData.ModelDifferences;
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : CompareToModel() returned " + comparisonResult.ToString() +
                                                   "  ColorThreshold = " + master.OriginalData.Descriptors.ColorThreshold.ToString());
                if (comparisonResult == false)
                {
                    System.Diagnostics.Debug.WriteLine("\nFailed again...");

                    master.OriginalData.Descriptors.ColorThreshold   = master.OriginalData.Descriptors.ColorThreshold - 2;
                    rendered.OriginalData.Descriptors.ColorThreshold = this.Descriptors.ColorThreshold - 2;
                    master.OriginalData.Analyze();
                    rendered.OriginalData.Analyze();
                    comparisonResult = rendered.OriginalData.CompareModels(master.OriginalData);
                    xmlDiff          = rendered.OriginalData.ModelDifferences;
                    System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : CompareToModel() returned " + comparisonResult.ToString() +
                                                       "  ColorThreshold = " + master.OriginalData.Descriptors.ColorThreshold.ToString());
                    if (comparisonResult == false)
                    {
                        System.Diagnostics.Debug.WriteLine("\nFailed one more time ...");
                        master.OriginalData.Descriptors.ColorThreshold   = master.OriginalData.Descriptors.ColorThreshold + 1;
                        rendered.OriginalData.Descriptors.ColorThreshold = this.Descriptors.ColorThreshold + 1;         // return original to be saved
                        master.OriginalData.Analyze();
                        rendered.OriginalData.Analyze();
                        comparisonResult = rendered.OriginalData.CompareModels(master.OriginalData);
                        xmlDiff          = rendered.OriginalData.ModelDifferences;
                        System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : CompareToModel() returned " + comparisonResult.ToString() +
                                                           "  ColorThreshold = " + master.OriginalData.Descriptors.ColorThreshold.ToString());
                    }
                }
            }

            if (comparisonResult == false && vscanFileName != null && vscanFileName != string.Empty)
            {
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : before <new Package>. vscanFileName=" + vscanFileName);
                Package package = Package.Create(vscanFileName, true);
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 1");
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 2");
                package.MasterBitmap = ImageUtility.ToBitmap(master.OriginalData.Image);
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 3");
                package.CapturedBitmap = ImageUtility.ToBitmap(rendered.OriginalData.Image);
//System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 4");
//                        byte[] buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(xmlDoc.DocumentElement.OuterXml);
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 5");
                Stream memoryStream = master.OriginalData.Descriptors.Serialize();
                package.MasterModel = memoryStream;
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 6");
                package.CapturedBitmap = ImageUtility.ToBitmap(rendered.OriginalData.Image);
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 7");
                package.XmlDiff = xmlDiff;
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 8");
                package.PackageCompare = PackageCompareTypes.ImageCompare | PackageCompareTypes.ModelAnalytical;
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : Saving package 9");
                package.Save();
                System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : PackageModel() completed");
            }

            System.Diagnostics.Debug.WriteLine("CompareModelsSavePackage() : completed");
            return(comparisonResult);
        }
Example #10
0
    //  [MethodImpl(MethodImplOptions.Unmanaged)]
    private static ColorByte LightColor(int x, int y, ColorByte marker)
    {
        int offsetX = x - minPos.x;
        int offsetY = y - minPos.y;

        if (color[offsetX, offsetY].A > marker.A)
        {
            marker = color[offsetX, offsetY];
        }
        else
        {
            color[offsetX, offsetY] = marker;
        }
        int deltaA;

        var map = TileInfoStructure.Free;

        if (x > 0 && y > 0 && x <= countTileMapX && y <= countTileMapY /*IsValidPoint(x, y)*/)
        {
            map = Map[x, y];
        }
        bool isWater = map.count > 9;//map.IsWater2();
        bool isEmpty = (map.type == 0 ||
                        /*IsTree()*/ map.type == 6 || map.type == 7 || map.type == 16 || map.type == 15 ||
                        /*IsDecor()*/ map.type == (short)TileTypeEnum.Jungle || map.type == (short)TileTypeEnum.Grass1 || map.type == (short)TileTypeEnum.Grass2 ||
                        /*IsWater()*/ map.liquidType == 1) && !isWater;//map.IsEmpty2() && !isWater;

        if (isEmpty)
        {
            deltaA = 10;
        }
        else
        if (isWater)
        {
            deltaA = 5;      //20;
        }
        else
        {
            deltaA = 40;
        }

        //  if (map.ItemId == 1)
        //      deltaA = 10;

        int resultA = (int)marker.A - deltaA;

        if (resultA < 0)
        {
            resultA = 0;
        }
        if (resultA > 255)
        {
            resultA = 255;
        }
        marker.A = (byte)resultA;

        map.lightAlpha2 = marker.A;

        /*
         * if (isEmpty) {
         *  //if ((double) y > MapGenerator.surface[x].y - 50) {
         *  map.lighted = true;
         *  // }
         * } else {
         *  map.lighted = false;
         * } */

        return(marker);
    }
Example #11
0
        /// <summary>
        /// The scanner attemps to locate content assuming that:
        ///   contentOff is the imagaeadapter of the scene before content is shown
        ///   contentOn  is the imagaeadapter of the scene with the content shown
        /// Note: content may have a variable alpha map
        /// </summary>
        public Result Process(IImageAdapter content, IImageAdapter contentOff, IImageAdapter contentOn, double[] transformMatrix)
        {
            string paramEx = string.Empty;

            if (content == null)
            {
                paramEx = "<IImageAdapter content> ";
            }
            if (contentOff == null)
            {
                paramEx += "<IImageAdapter contentOff>";
            }
            if (contentOn == null)
            {
                paramEx += "<IImageAdapter contentOn>";
            }
            if (content == null)
            {
                paramEx += "<IImageAdapter content>";
            }
            if (transformMatrix == null)
            {
                paramEx += "<double []transformMatrix>";
            }

/*
 *                  if (transformMatrix.Length != Interpolator.TransformLength)
 *                  {
 *                      throw new Exception("Transform array length != " + Interpolator.TransformLength);
 *                  }
 */
            //sentinel
            bool         validResult = true;
            string       log         = string.Empty;
            ImageAdapter res         = GetTransformedContent(content, transformMatrix, contentOff.Width, contentOff.Height);

            // locate rec
            //  1) compute the diff image
            //  2) synthetise the transformed content
            //  3) compare with the sourceOn
            ImageComparator imageComparator = new ImageComparator();

            imageComparator.Compare(contentOn, contentOff);
            IImageAdapter imdiff = imageComparator.GetErrorDifference(ErrorDifferenceType.FilterEdge);

            // make sure there is only one descriptor and the background.
            //convert the diff image to a binary image (black-bg and white-fg)
            ImageAdapter imbinmap = new ImageAdapter(imdiff.Width, imdiff.Height);
            IColor       black    = new ColorByte(Color.Black);
            IColor       white    = new ColorByte(Color.White);

            for (int j = 0; j < imbinmap.Width; j++)
            {
                for (int i = 0; i < imbinmap.Height; i++)
                {
                    if (imdiff[j, i].Red + imdiff[j, i].Green + imdiff[j, i].Blue > 1e-6)
                    {
                        imdiff[j, i] = white;
                    }
                    else
                    {
                        imdiff[j, i] = black;
                    }
                }
            }
#if DEBUG
            ImageUtility.ToImageFile(imdiff, "bwmap.png", ImageFormat.Png);
#endif
            //Analyze the bin-diff-image
            VScan lvsc = new VScan(imdiff);
            lvsc.OriginalData.Analyze();

            //topological check
            //root nodes: either a pair of white and black descriptor
            //or a tree.
            // all further descendant must be children of the white cell

/*
 *                  int[] descriptorCounter = new int[2];
 *
 *                  //loop on the descriptors
 *                  foreach (IDescriptor desc in lvsc.OriginalData.Descriptors.ActiveDescriptors)
 *                  {
 *                      if (desc.Depth <= 1)
 *                      {
 *                          descriptorCounter[desc.Depth]++;
 *                      }
 *
 *                      Console.WriteLine("Descr " + desc.BoundingBox + "   " + desc.Depth);
 *                  }
 *
 *                  //check
 *                  int summ = descriptorCounter[0] + descriptorCounter[1];
 *                  if (summ != 2)
 *                  {
 *                      validResult = false;
 *                      if (summ == 0)
 *                      {
 *                          log = "<Fail> No top level descriptors found";
 *                      }
 *                      else
 *                      {
 *                          log = "<Fail> Too many top level descriptors found (should be two) :" + summ;
 *                      }
 *                  }
 */
            // topology is good to go, time to find the bounding box of the dynamic content
            int minx = int.MaxValue;
            int miny = int.MaxValue;
            int maxx = int.MinValue;
            int maxy = int.MinValue;
            if (validResult == true)
            {
                for (int j = 0; j < imdiff.Width; j++)
                {
                    for (int i = 0; i < imdiff.Height; i++)
                    {
                        double sum = imdiff[j, i].Blue + imdiff[j, i].Red + imdiff[j, i].Green;
                        if (sum > 1e-6)
                        {
                            if (j < minx)
                            {
                                minx = j;
                            }
                            if (i < miny)
                            {
                                miny = i;
                            }
                            if (j > maxx)
                            {
                                maxx = j;
                            }
                            if (i > maxy)
                            {
                                maxy = i;
                            }
                        }
                    }
                }

                // bounding box
                maxx -= minx;
                maxy -= miny;
                Console.WriteLine("<Target> found at " + minx + " " + miny + "  " + maxx + " " + maxy);
                ImageUtility.ToImageFile(imdiff, "Recpos.png");

                // synthetize content into contentOff
                IImageAdapter iafcomp = new ImageAdapter(contentOff.Width, contentOff.Height);
                double        dx      = minx - _imageAdapterXmin;
                double        dy      = miny - _imageAdapterYmin;

                // translate results
                for (int j = 0; j < 4; j++)
                {
                    _contentLocation[j, 0] += dx;
                    _contentLocation[j, 1] += dy;
                }

                // copy the background
                iafcomp = (IImageAdapter)contentOff.Clone();

                // add the transformed content
                for (int j = 0; j < res.Width; j++)
                {
                    for (int i = 0; i < res.Height; i++)
                    {
                        if (j + minx < iafcomp.Width && i + miny < iafcomp.Height)
                        {
                            if (res[j, i].Alpha > 0)
                            {
                                double lalp = res[j, i].Alpha;
                                int    jid  = j + minx;
                                int    iid  = i + miny;
                                IColor lvc  = iafcomp[jid, iid];
                                lvc.Red           = lalp * res[j, i].Red + (1 - lalp) * iafcomp[jid, iid].Red;
                                lvc.Green         = lalp * res[j, i].Green + (1 - lalp) * iafcomp[jid, iid].Green;
                                lvc.Blue          = lalp * res[j, i].Blue + (1 - lalp) * iafcomp[jid, iid].Blue;
                                iafcomp[jid, iid] = lvc;
                            }
                        }
                    }
                }
#if DEBUG
                ImageUtility.ToImageFile(iafcomp, "SynthGlyph.png", ImageFormat.Png);
#endif

/*
 *                      if (Tolerance != null)
 *                      {
 *                          imageComparator.Tolerance.Clear();
 *                          double x = double.NaN;
 *                          double y = double.NaN;
 *                          for(int t=0;t<Tolerance.Count;t++)
 *                          {
 *                              x = (double)Tolerance.GetKey(t);
 *                              y = (double)Tolerance[x];
 *                              imageComparator.Tolerance.Add(x,y);
 *                          }
 *                      }
 */
                validResult = imageComparator.Compare(iafcomp, contentOn);
                string toluse = "No Tolerance used - strict comparison";
                if (_tolerance != null)
                {
                    toluse = "with the given Tolerance";
                }
                if (validResult == false)
                {
                    log = "<Fail> Computed Content does not match actual content -- " + toluse;
                }
                else
                {
                    log = "<Pass>";
                }

                Console.WriteLine("Final comp pass " + validResult);
                ImageUtility.ToImageFile(imageComparator.GetErrorDifference(ErrorDifferenceType.FilterEdge), "SynthError.png");
#if DEBUG
                using (Bitmap fbmp = ImageUtility.ToBitmap(contentOn))
                {
                    using (Graphics graphics = Graphics.FromImage(fbmp))
                    {
                        using (Brush brush = new SolidBrush(Color.FromArgb(40, 255, 0, 0)))
                        {
                            graphics.FillRectangle(brush, minx, miny, maxx, maxy);
                        }
                        using (Pen pen = new Pen(Color.Red, 2))
                        {
                            graphics.DrawRectangle(pen, minx, miny, maxx, maxy);
                        }
                        using (Font fnt = new Font("Arial", 10))
                        {
                            SizeF sz = graphics.MeasureString("TL", fnt);
                            graphics.FillRectangle(Brushes.Yellow, (float)_contentLocation[0, 0], (float)_contentLocation[0, 1], sz.Width, sz.Height);
                            graphics.FillRectangle(Brushes.Yellow, (float)_contentLocation[1, 0], (float)_contentLocation[1, 1], sz.Width, sz.Height);
                            graphics.FillRectangle(Brushes.Yellow, (float)_contentLocation[2, 0], (float)_contentLocation[2, 1], sz.Width, sz.Height);
                            graphics.FillRectangle(Brushes.Yellow, (float)_contentLocation[3, 0], (float)_contentLocation[3, 1], sz.Width, sz.Height);
                            graphics.DrawString("TL", fnt, Brushes.Red, (float)_contentLocation[0, 0], (float)_contentLocation[0, 1]);
                            graphics.DrawString("TR", fnt, Brushes.Red, (float)_contentLocation[1, 0], (float)_contentLocation[1, 1]);
                            graphics.DrawString("BL", fnt, Brushes.Red, (float)_contentLocation[2, 0], (float)_contentLocation[2, 1]);
                            graphics.DrawString("BR", fnt, Brushes.Red, (float)_contentLocation[3, 0], (float)_contentLocation[3, 1]);
                        }
                        fbmp.Save("TrackMatch.png");
                    }
                }
#endif
            }
            Result dcres = new Result(validResult, log, _contentLocation);

            return(dcres);
        }
Example #12
0
        protected override void OnRenderButton(UIButton control, CanvasRenderer renderer)
        {
            //!!!!context menu

            //if( control.Parent as UIContextMenu != null )
            //{
            //	//context menu button
            //}
            //else
            //{
            //	//usual button
            //}

            //!!!!
            //RenderButtonTextImage( control, renderer, new ColorValue( 1, 1, 1 ), new ColorValue( 1, 1, 1 ) );

            control.GetScreenRectangle(out var rect);

            //back
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(60, 60, 60) : new ColorByte(253, 253, 253); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(80, 80, 80) : new ColorByte(205, 230, 247); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(204, 228, 247); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(204, 228, 247); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(50, 50, 50) : new ColorByte(250, 250, 250); break;
                }

                renderer.AddQuad(rect, color.ToColorValue());
            }

            //text
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(59, 59, 59); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(167, 167, 167); break;
                }

                var center = rect.GetCenter() + new Vector2(0, renderer.DefaultFontSize / 10);
                renderer.AddText(control.Text, center, EHorizontalAlignment.Center, EVerticalAlignment.Center, color.ToColorValue());
            }

            //border
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(170, 170, 170); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(130, 130, 130) : new ColorByte(95, 168, 226); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(150, 150, 150) : new ColorByte(0, 120, 215); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(150, 150, 150) : new ColorByte(0, 120, 215); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(60, 60, 60) : new ColorByte(180, 180, 180); break;
                }

                renderer.AddRectangle(rect, color.ToColorValue());
            }
        }
Example #13
0
		public bool BuildNavMesh( out string error )
		{
			DestroyNavMesh();

			if( !EnabledInHierarchy )
			{
				error = "Is not enabled.";
				return false;
			}

			//get geometry data
			var collector = GetAllGeometriesForNavigationMesh();
			Vector3[] vertices = collector.resultVertices;
			int[] indices = collector.resultIndices;
			int vertexCount = collector.resultVertexCount;
			int indexCount = collector.resultIndexCount;

			if( vertexCount == 0 )
			{
				error = "No vertices were gathered from collision objects.";
				return false;
			}

			//get settings
			var settings = new NavMeshGenerationSettings();
			settings.CellSize = (float)CellSize;
			settings.CellHeight = (float)CellHeight;
			settings.MaxClimb = (float)AgentMaxClimb;
			settings.AgentHeight = (float)AgentHeight;
			settings.AgentRadius = (float)AgentRadius;
			settings.MinRegionSize = MinRegionSize;
			settings.MergedRegionSize = MergedRegionSize;
			settings.MaxEdgeLength = MaxEdgeLength;
			settings.MaxEdgeError = (float)MaxEdgeError;
			settings.VertsPerPoly = MaxVerticesPerPolygon;
			settings.SampleDistance = DetailSampleDistance;
			settings.MaxSampleError = DetailMaxSampleError;
			settings.BuildBoundingVolumeTree = true;

			TiledNavMesh newTiledNavMesh;

			try
			{
				//level.SetBoundingBoxOffset(new SVector3(settings.CellSize * 0.5f, settings.CellHeight * 0.5f, settings.CellSize * 0.5f));

				var bounds = Bounds.Cleared;
				bounds.Add( vertices );
				var heightfield = new Heightfield( ToSharpNav( bounds ), settings );

				var vertices2 = new SharpNav.Geometry.Vector3[ indexCount ];
				for( int index = 0; index < indexCount; index++ )
					vertices2[ index ] = ToSharpNav( vertices[ indices[ index ] ] );

				//Area[] areas = AreaGenerator.From( vertices2, Area.Default )
				//	.MarkBelowSlope( (float)AgentMaxSlope.Value.InRadians(), Area.Null )
				//	.ToArray();
				//Area[] areas = AreaGenerator.From(triEnumerable, Area.Default)
				//	.MarkAboveHeight(areaSettings.MaxLevelHeight, Area.Null)
				//	.MarkBelowHeight(areaSettings.MinLevelHeight, Area.Null)
				//	.MarkBelowSlope(areaSettings.MaxTriSlope, Area.Null)
				//	.ToArray();
				//heightfield.RasterizeTrianglesWithAreas( vertices2, areas );
				heightfield.RasterizeTriangles( vertices2, Area.Default );

				heightfield.FilterLedgeSpans( settings.VoxelAgentHeight, settings.VoxelMaxClimb );
				heightfield.FilterLowHangingWalkableObstacles( settings.VoxelMaxClimb );
				heightfield.FilterWalkableLowHeightSpans( settings.VoxelAgentHeight );

				var compactHeightfield = new CompactHeightfield( heightfield, settings );
				compactHeightfield.Erode( settings.VoxelAgentRadius );
				compactHeightfield.BuildDistanceField();
				compactHeightfield.BuildRegions( 0, settings.MinRegionSize, settings.MergedRegionSize );

				//!!!!
				System.Random r = new System.Random();
				var regionColors = new ColorByte[ compactHeightfield.MaxRegions ];
				regionColors[ 0 ] = new ColorByte( 0, 0, 0 );
				for( int i = 1; i < regionColors.Length; i++ )
					regionColors[ i ] = new ColorByte( (byte)r.Next( 0, 255 ), (byte)r.Next( 0, 255 ), (byte)r.Next( 0, 255 ), (byte)255 );

				var contourSet = compactHeightfield.BuildContourSet( settings );
				var polyMesh = new PolyMesh( contourSet, settings );
				var polyMeshDetail = new PolyMeshDetail( polyMesh, compactHeightfield, settings );

				var buildData = new NavMeshBuilder( polyMesh, polyMeshDetail, new OffMeshConnection[ 0 ], settings );
				newTiledNavMesh = new TiledNavMesh( buildData );

				//!!!!
				////Pathfinding with multiple units
				//GenerateCrowd();
			}
			catch( Exception e )
			{
				DestroyNavMesh();
				error = e.Message;
				return false;
			}

			int dataLength;
			byte[] data;

			using( var memoryStream = new MemoryStream() )
			{
				var serializer = new NavMeshBinarySerializer();
				serializer.Serialize( memoryStream, newTiledNavMesh );

				dataLength = (int)memoryStream.Length;
				data = memoryStream.GetBuffer();
			}

			//generate nav mesh data
			var writer = new ArrayDataWriter();
			writer.Write( navMeshDataVersion );
			writer.Write( dataLength );
			writer.Write( data, 0, dataLength );

			//set NavMeshData and init
			var newNavMeshData = new byte[ writer.BitLength / 8 ];
			Buffer.BlockCopy( writer.Data, 0, newNavMeshData, 0, newNavMeshData.Length );
			NavMeshData = newNavMeshData;

			error = "";
			return true;
		}
Example #14
0
        /// <summary>
        /// Perform a Bilinear interpolation
        /// </summary>
        /// <param name="x">position on the x Axis</param>
        /// <param name="y">position on the y Axis</param>
        /// <param name="imageSource">The image to perform interpolation on</param>
        /// <param name="unassignedColor">The color to use for pixel that are unassigned\nCan be set to null (Empty color will be used)</param>
        /// <returns>The interpolated color</returns>
        public static IColor ProcessPoint(double x, double y, IImageAdapter imageSource, IColor unassignedColor)
        {
            IColor retVal = null;

            if (imageSource == null)
            {
                throw new ArgumentNullException("imageSource", "The IImageAdapter passed in cannot be null");
            }

            if (x >= 0.0 && y >= 0.0 && x <= imageSource.Width - 1 && y <= imageSource.Height - 1)
            {
                int ix   = (int)x;
                int iy   = (int)y;
                int incx = (ix >= imageSource.Width - 1) ? 0 : 1;
                int incy = (iy >= imageSource.Height - 1) ? 0 : 1;

                retVal         = (IColor)imageSource[ix, iy].Clone();
                retVal.IsEmpty = true;

                IColor c00 = imageSource[ix, iy];
                IColor c01 = imageSource[ix, iy + incy];
                IColor c10 = imageSource[ix + incx, iy];
                IColor c11 = imageSource[ix + incx, iy + incy];

                if (c00.IsEmpty)
                {
                    return((IColor)unassignedColor.Clone());
                }


                if (c01.IsEmpty || c10.IsEmpty || c11.IsEmpty)
                {
                    // do this only if one of the color is "Empty" because this is time consumming (lots of computation)
                    ColorByte tempColor = new ColorByte();
                    int       indexC00  = (int)(Math.Sqrt(((x - ix) * (x - ix) + (y - iy) * (y - iy)) * SZAR_SQR) + 0.5);
                    int       indexC01  = (int)(Math.Sqrt(((x - ix) * (x - ix) + (y - (iy + incy)) * (y - (iy + incy))) * SZAR_SQR) + 0.5);
                    int       indexC10  = (int)(Math.Sqrt(((x - (ix + incx)) * (x - (ix + incx)) + (y - iy) * (y - iy)) * SZAR_SQR) + 0.5);
                    int       indexC11  = (int)(Math.Sqrt(((x - (ix + incx)) * (x - (ix + incx)) + (y - (iy + incy)) * (y - (iy + incy))) * SZAR_SQR) + 0.5);
                    double    weigth    = 0;
                    if (c00.IsEmpty == false && indexC00 < 1024)
                    {
                        weigth = _bilinearArray[indexC00];
                        tempColor.ExtendedAlpha = c00.ExtendedAlpha * _bilinearArray[indexC00];
                        tempColor.ExtendedRed   = c00.ExtendedRed * _bilinearArray[indexC00];
                        tempColor.ExtendedGreen = c00.ExtendedGreen * _bilinearArray[indexC00];
                        tempColor.ExtendedBlue  = c00.ExtendedBlue * _bilinearArray[indexC00];
                    }
                    if (c01.IsEmpty == false && indexC01 < 1024)
                    {
                        weigth = _bilinearArray[indexC01];
                        tempColor.ExtendedAlpha += c01.ExtendedAlpha * _bilinearArray[indexC01];
                        tempColor.ExtendedRed   += c01.ExtendedRed * _bilinearArray[indexC01];
                        tempColor.ExtendedGreen += c01.ExtendedGreen * _bilinearArray[indexC01];
                        tempColor.ExtendedBlue  += c01.ExtendedBlue * _bilinearArray[indexC01];
                    }
                    if (c10.IsEmpty == false && indexC10 < 1024)
                    {
                        weigth = _bilinearArray[indexC10];
                        tempColor.ExtendedAlpha += c10.ExtendedAlpha * _bilinearArray[indexC10];
                        tempColor.ExtendedRed   += c10.ExtendedRed * _bilinearArray[indexC10];
                        tempColor.ExtendedGreen += c10.ExtendedGreen * _bilinearArray[indexC10];
                        tempColor.ExtendedBlue  += c10.ExtendedBlue * _bilinearArray[indexC10];
                    }
                    if (c11.IsEmpty == false && indexC11 < 1024)
                    {
                        weigth = _bilinearArray[indexC11];
                        tempColor.ExtendedAlpha += c11.ExtendedAlpha * _bilinearArray[indexC11];
                        tempColor.ExtendedRed   += c11.ExtendedRed * _bilinearArray[indexC11];
                        tempColor.ExtendedGreen += c11.ExtendedGreen * _bilinearArray[indexC11];
                        tempColor.ExtendedBlue  += c11.ExtendedBlue * _bilinearArray[indexC11];
                    }

                    if (tempColor.IsEmpty == false)
                    {
                        tempColor.ExtendedAlpha /= weigth;
                        tempColor.ExtendedRed   /= weigth;
                        tempColor.ExtendedGreen /= weigth;
                        tempColor.ExtendedBlue  /= weigth;
                        retVal = tempColor;
                    }
                }
                else
                {
                    int indexX = (int)((x - ix) * SZAR);
                    int indexY = (int)((y - iy) * SZAR);

                    double v0 = c00.ExtendedAlpha * _bilinearArray[indexX] + c10.ExtendedAlpha * (1.0 - _bilinearArray[indexX]);
                    double v1 = c01.ExtendedAlpha * _bilinearArray[indexX] + c11.ExtendedAlpha * (1.0 - _bilinearArray[indexX]);
                    retVal.ExtendedAlpha = (v0 * _bilinearArray[indexY] + v1 * (1.0 - _bilinearArray[indexY]));

                    v0 = c00.ExtendedRed * _bilinearArray[indexX] + c10.ExtendedRed * (1.0 - _bilinearArray[indexX]);
                    v1 = c01.ExtendedRed * _bilinearArray[indexX] + c11.ExtendedRed * (1.0 - _bilinearArray[indexX]);
                    retVal.ExtendedRed = (v0 * _bilinearArray[indexY] + v1 * (1.0 - _bilinearArray[indexY]));

                    v0 = c00.ExtendedGreen * _bilinearArray[indexX] + c10.ExtendedGreen * (1.0 - _bilinearArray[indexX]);
                    v1 = c01.ExtendedGreen * _bilinearArray[indexX] + c11.ExtendedGreen * (1.0 - _bilinearArray[indexX]);
                    retVal.ExtendedGreen = (v0 * _bilinearArray[indexY] + v1 * (1.0 - _bilinearArray[indexY]));

                    v0 = c00.ExtendedBlue * _bilinearArray[indexX] + c10.ExtendedBlue * (1.0 - _bilinearArray[indexX]);
                    v1 = c01.ExtendedBlue * _bilinearArray[indexX] + c11.ExtendedBlue * (1.0 - _bilinearArray[indexX]);
                    retVal.ExtendedBlue = (v0 * _bilinearArray[indexY] + v1 * (1.0 - _bilinearArray[indexY]));
                }
            }
            else
            {
                // Out of bound of the original image, fill with IColor.Empty or the unassignedColor passed in
                if (unassignedColor == null)
                {
                    retVal         = (IColor)imageSource[0, 0].Clone();
                    retVal.IsEmpty = true;
                }
                else
                {
                    retVal = (IColor)unassignedColor.Clone();
                }
            }

            return(retVal);
        }