コード例 #1
0
            public Bitmap Draw(double[] samples)
            {
                int width  = samples.Length / _nfft;
                int height = _nfft / 2;
                var bmp    = new FastBitmap(new Bitmap(width, height));

                bmp.LockImage();
                for (int x = 0; x < width; x++)
                {
                    // read a segment of the recorded signal
                    for (int i = 0; i < _nfft; i++)
                    {
                        _segment[i] = samples[x * _nfft + i] * _window[i];
                    }

                    // transform to the frequency domain
                    _fft.ComputeForward(_segment);

                    // compute the magnitude of the spectrum
                    MagnitudeSpectrum(_segment, _magnitude);

                    // draw
                    for (int y = 0; y < height; y++)
                    {
                        int colorIndex = _mapper.Map(_magnitude[y]);
                        bmp.SetPixel(x, height - y - 1, _palette[colorIndex]);
                    }
                }
                bmp.UnlockImage();
                return(bmp.GetBitmap());
            }
コード例 #2
0
ファイル: XSub.cs プロジェクト: segator/PgsToSrt
        public Bitmap GetImage(Color background, Color pattern, Color emphasis1, Color emphasis2)
        {
            var fourColors = new List <Color> {
                background, pattern, emphasis1, emphasis2
            };
            var bmp = new Bitmap(Width, Height);

            if (fourColors[0] != Color.Transparent)
            {
                using (var gr = Graphics.FromImage(bmp))
                {
                    gr.FillRectangle(new SolidBrush(fourColors[0]), new Rectangle(0, 0, bmp.Width, bmp.Height));
                }
            }
            var fastBmp = new FastBitmap(bmp);

            fastBmp.LockImage();
            GenerateBitmap(fastBmp, _rleBuffer, fourColors);
            fastBmp.UnlockImage();
            return(bmp);
        }
コード例 #3
0
            public Bitmap Draw(double[] samples)
            {
                int width  = samples.Length / _nfft;
                int height = _nfft / 2;
                var bmp    = new FastBitmap(new Bitmap(width, height));

                bmp.LockImage();
                for (int x = 0; x < width; x++)
                {
                    // process 2 segments offset by -1/4 and 1/4 fft size, resulting in 1/2 fft size
                    // window spacing (the minimum overlap to avoid discarding parts of the signal)
                    ProcessSegment(samples, (x * _nfft) - (x > 0 ? _nfft / 4 : 0), _magnitude1);
                    ProcessSegment(samples, (x * _nfft) + (x < width - 1 ? _nfft / 4 : 0), _magnitude2);

                    // draw
                    for (int y = 0; y < height; y++)
                    {
                        int colorIndex = _mapper.Map((_magnitude1[y] + _magnitude2[y]) / 2.0);
                        bmp.SetPixel(x, height - y - 1, _palette[colorIndex]);
                    }
                }
                bmp.UnlockImage();
                return(bmp.GetBitmap());
            }
コード例 #4
0
            public Bitmap Draw(double[] samples)
            {
                int width = samples.Length / _nfft;
                int height = _nfft / 2;
                var bmp = new FastBitmap(new Bitmap(width, height));
                bmp.LockImage();
                for (int x = 0; x < width; x++)
                {
                    // process 2 segments offset by -1/4 and 1/4 fft size, resulting in 1/2 fft size
                    // window spacing (the minimum overlap to avoid discarding parts of the signal)
                    ProcessSegment(samples, (x * _nfft) - (x > 0 ? _nfft / 4 : 0), _magnitude1);
                    ProcessSegment(samples, (x * _nfft) + (x < width - 1 ? _nfft / 4 : 0), _magnitude2);

                    // draw
                    for (int y = 0; y < height; y++)
                    {
                        int colorIndex = _mapper.Map((_magnitude1[y] + _magnitude2[y]) / 2.0);
                        bmp.SetPixel(x, height - y - 1, _palette[colorIndex]);
                    }
                }
                bmp.UnlockImage();
                return bmp.GetBitmap();
            }
コード例 #5
0
ファイル: XSub.cs プロジェクト: ItsJustSean/subtitleedit
 public Bitmap GetImage(Color background, Color pattern, Color emphasis1, Color emphasis2)
 {
     var fourColors = new List<Color> { background, pattern, emphasis1, emphasis2 };
     var bmp = new Bitmap(Width, Height);
     if (fourColors[0] != Color.Transparent)
     {
         using (var gr = Graphics.FromImage(bmp))
         {
             gr.FillRectangle(new SolidBrush(fourColors[0]), new Rectangle(0, 0, bmp.Width, bmp.Height));
         }
     }
     var fastBmp = new FastBitmap(bmp);
     fastBmp.LockImage();
     GenerateBitmap(fastBmp, rleBuffer, fourColors);
     fastBmp.UnlockImage();
     return bmp;
 }
コード例 #6
0
            public Bitmap Draw(double[] samples)
            {
                int width = samples.Length / _nfft;
                int height = _nfft / 2;
                var bmp = new FastBitmap(new Bitmap(width, height));
                bmp.LockImage();
                for (int x = 0; x < width; x++)
                {
                    // read a segment of the recorded signal
                    for (int i = 0; i < _nfft; i++)
                    {
                        _segment[i] = samples[x * _nfft + i] * _window[i];
                    }

                    // transform to the frequency domain
                    _fft.ComputeForward(_segment);

                    // compute the magnitude of the spectrum
                    MagnitudeSpectrum(_segment, _magnitude);

                    // draw
                    for (int y = 0; y < height; y++)
                    {
                        int colorIndex = _mapper.Map(_magnitude[y]);
                        bmp.SetPixel(x, height - y - 1, _palette[colorIndex]);
                    }
                }
                bmp.UnlockImage();
                return bmp.GetBitmap();
            }