Exemplo n.º 1
0
 public void Unlock()
 {
     if (isLocked)
     {
         Bmp.UnlockBits(bmpData);
     }
     isLocked = false;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Liberate the Bitmap from memory
 /// </summary>
 public void UnlockBits()
 {
     Bmp.UnlockBits(BData);
 }
Exemplo n.º 3
0
        public void Render(Graphics g, Rectangle area, long start, long count, long step)
        {
            if (Bmp == null)
            {
                return;
            }

            var spectrums = Data.Iterate(start, area.Width, step);

            var       x         = 0;
            const int pixelSize = 3;

            var bmd = Bmp.LockBits(new Rectangle(0, 0, Bmp.Width, Bmp.Height), ImageLockMode.ReadWrite, Bmp.PixelFormat);

            unsafe
            {
                foreach (var spectrum in spectrums)
                {
                    var skip = spectrum.Length / (double)area.Height / 2;

                    if (spectrum.Length > 0)
                    {
                        var row = (byte *)bmd.Scan0;

                        var yy = area.Height - 1;
                        for (var y = 0; y < bmd.Height - 1; y++)
                        {
                            var idx = (int)(yy-- *skip);
                            if (idx < 0)
                            {
                                idx = 0;
                            }
                            if (idx >= spectrum.Length)
                            {
                                idx = spectrum.Length - 1;
                            }

                            var value = (int)(255 * spectrum[idx]);
                            if (value > 255)
                            {
                                value = 255;
                            }
                            if (value < 0)
                            {
                                value = 0;
                            }

                            var pixelColor = Palette[value];
                            row[x + 0] = pixelColor.B;
                            row[x + 1] = pixelColor.G;
                            row[x + 2] = pixelColor.R;

                            row += bmd.Stride;
                        }
                    }
                    x += pixelSize;
                }
            }

            Bmp.UnlockBits(bmd);

            g.DrawImage(Bmp, area.Location);
        }
Exemplo n.º 4
0
 public void Dispose()
 {
     Bmp.UnlockBits(Lock);
 }