private void Draw(FractalTask t)
        {
            System.Diagnostics.Debug.WriteLine(Thread.CurrentThread.Name + ": Drawing");

            var colorBuffer = new byte[3];


            for (var y = 0; y < t.Height; y++)
            {
                for (var x = 0; x < t.Width; x++)
                {
                    var currentPos = 4 * ((int)t.UpperLeftCorner.X + x +
                                          ((int)t.UpperLeftCorner.Y + y) * _pixelWidth);

                    if (_colorMapper != null)
                    {
                        _colorMapper.MapColor(Convert.ToInt32(t.GetIterations(x, y)), _maxIterations,
                                              Math.Abs(Convert.ToDouble(t.GetImaginaryPart(y))),
                                              Math.Abs(Convert.ToDouble(t.GetRealPart(x))), ref colorBuffer);
                    }
                    else
                    {
                        _defaultColorMapper.MapColor(Convert.ToInt32(t.GetIterations(x, y)), _maxIterations,
                                                     Math.Abs(Convert.ToDouble(t.GetImaginaryPart(y))),
                                                     Math.Abs(Convert.ToDouble(t.GetRealPart(x))), ref colorBuffer);
                    }
                    _pixelValues[currentPos]     = colorBuffer[2];
                    _pixelValues[currentPos + 1] = colorBuffer[1];
                    _pixelValues[currentPos + 2] = colorBuffer[0];
                    _pixelValues[currentPos + 3] = 255;
                }
            }
            if (_stopRendering)
            {
                return;
            }

            _previousDrawnTasks.Enqueue(t);
            OnTileAvailable(new EventArgs());
        }
        //  public double[][,] calculate(int resultX = 1920, int resultY = 1080, int maxIterations = 1000, Image img = null)

        private void InternalCalculate(FractalTask t)
        {
            System.Diagnostics.Debug.WriteLine(Thread.CurrentThread.Name + ": Calculating");
            for (var y = 0; y < t.Height; y++)
            {
                var cIm = t.GetImaginaryPart(y);

                for (var x = 0; x < t.Width; x++)
                {
                    var     cReal = t.GetRealPart(x);
                    decimal zReal = 0;
                    decimal zIm   = 0;
                    decimal zAbs  = 0;
                    var     n     = 0;

                    while (zAbs <= 4 && n <= t.MaxIterations)
                    {
                        var tmp = zReal;
                        zReal = zReal * zReal - zIm * zIm + cReal;
                        zIm   = 2 * tmp * zIm + cIm;
                        zAbs  = zReal * zReal + zIm * zIm;
                        n++;
                    }
                    if (_stopRendering)
                    {
                        return;
                    }

                    t.SetIterations(x, y, n);
                }
            }

            t.Type = TaskType.Draw;
            if (!_stopRendering)
            {
                _drawingTasks.Enqueue(t);
            }
        }