Exemplo n.º 1
0
        public override void RenderToBuffer(MandelbrotSet set, PixelBuffer buffer)
        {
            var renderer = new ContourRenderer(this.tracer);
            Palette palette = new DefaultPalette();
            int maxCount = set.EstimateMaxCount();
            var bandMap = new LogarithmicBandMap(maxCount, 30.0);

            renderer.Render(buffer, set, bandMap, maxCount);
            buffer.ApplyPalette(palette);
        }
Exemplo n.º 2
0
        public override void Render(PixelBuffer buffer, MandelbrotSet set, BandMap bandMap, int maxCount)
        {
            this.sizex = buffer.SizeX;
            this.sizey = buffer.SizeY;
            this.maxCount = maxCount;
            this.bandMap = bandMap;
            this.buffer = buffer;
            this.InitializeCoordinateMap(sizex, sizey, set);
            this.NumberOfContours = 0;

            for (int i = 0; i < sizex; i++)
            {
                // Keep track of the last band and how many pixels into that band we are
                // Start crawling after we see a few pixels of the same band
                int lastBand = 0;
                int numberOfPointsFoundInBand = 0;
                int startOfBand = 0;
                bool calculated = false;
                for (int j = 0; j < sizey; j++)
                {
                    int band = GetOrCalculateBand(i, j, out calculated);
                    System.Diagnostics.Debug.Assert(band != 0); // This should only be returned for points out of range, which should be none
                    if (calculated && (band == lastBand))
                    {
                        numberOfPointsFoundInBand++;
                    }
                    else
                    {
                        if (band != lastBand)
                        {
                            startOfBand = j;
                            lastBand = band;
                        }
                        numberOfPointsFoundInBand = 1;
                    }
                    // If we are 8 or more pixels into the band, start crawling
                    if (numberOfPointsFoundInBand > 8)
                    {
                        if (this.Crawl(i, startOfBand, band))
                        {
                            this.NumberOfContours = this.NumberOfContours + 1;
                            this.FillCrawl(i, startOfBand, band);
                            this.DumpBits();
                        }
                        this.ClearSavedBits();

                        numberOfPointsFoundInBand = 0;
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void Evaluate(PixelBuffer buffer)
 {
     for (int i = 0; i < buffer.SizeX; i++)
     {
         for (int j = 0; j < buffer.SizeY; j++)
         {
             int val = buffer.GetValue(i, j);
             int count = 0;
             this.values.TryGetValue(val, out count);
             count++;
             this.values[val] = count;
         }
     }
 }
Exemplo n.º 4
0
        public override void Render(PixelBuffer buffer, MandelbrotSet set, BandMap bandMap, int maxCount)
        {
            this.InitializeCoordinateMap(buffer.SizeX, buffer.SizeY, set);

            DoubleComplexNumber temp = new DoubleComplexNumber(0.0, 0.0);
            for (int i = 0; i < buffer.SizeX; i++)
            {
                temp.X = this.XCoordinates[i];
                for (int j = 0; j < buffer.SizeY; j++)
                {
                    temp.Y = this.YCoordinates[j];
                    int count = temp.CalculateCount(maxCount);
                    this.SetBand(buffer, bandMap, i, j, count);
                }
            }
        }
Exemplo n.º 5
0
 public abstract void RenderToBuffer(MandelbrotSet set, PixelBuffer buffer);
Exemplo n.º 6
0
 public void SaveBits(string message, PixelBuffer buffer)
 {
     if (this.tracer != null)
     {
         this.tracer.AddBits(message, buffer);
     }
 }
Exemplo n.º 7
0
 public abstract void Render(PixelBuffer buffer, MandelbrotSet set, BandMap bandMap, int maxCount);
Exemplo n.º 8
0
 protected virtual void SetBand(PixelBuffer buffer, BandMap bandMap, int x, int y, int count)
 {
     int band = bandMap.Map(count);
     buffer.SetValue(x, y, band);
 }
Exemplo n.º 9
0
 public PixelBuffer Clone()
 {
     var newBuffer = new PixelBuffer(this.SizeX, this.SizeY);
     for (int i = 0; i < pixels.Length; i++)
         newBuffer.pixels[i] = this.pixels[i];
     return newBuffer;
 }
Exemplo n.º 10
0
 public PixelBuffer(PixelBuffer backing, int offsetX, int offsetY, int sizeX, int sizeY, int stride)
     : this(backing.pixels, offsetX, offsetY, sizeX, sizeY, stride)
 {
 }