BASS.NET API for the Un4seen BASS Audio Library

WaveFormCreateBitmap Method (Int32, Int32, Int32, Int32, Boolean)

BASS.NET API for the Un4seen BASS Audio Library
Creates a bitmap from a rendered wave form.

Namespace:  Un4seen.Bass.Misc
Assembly:  Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax

public Bitmap CreateBitmap(
	int width,
	int height,
	int frameStart,
	int frameEnd,
	bool highQuality
)

Parameters

width
Type: SystemInt32
The width (in pixel) of the image to create.
height
Type: SystemInt32
The height (in pixel) of the image to create.
frameStart
Type: SystemInt32
The rendered frame from where to start creating the image (specify 0 or -1 to start from the beginning).
frameEnd
Type: SystemInt32
The rendered frame til where to creating the image (specify -1 to create til the end). This value must be greater than frameStart.
highQuality
Type: SystemBoolean
, if anti alias should be used when drawing. will draw in high speed mode.

Return Value

Type: Bitmap
The created bitmap image representing the wave form.
Examples

private Un4seen.Bass.Misc.WaveForm WF = null;

private void GetWaveForm()
{
  // render a wave form
  WF = new Un4seen.Bass.Misc.WaveForm("test.mp3", 
                        new Un4seen.Bass.Misc.WAVEFORMPROC(MyWaveFormCallback), this);
  WF.CallbackFrequency = 500; // every 10 seconds rendered
  WF.ColorBackground = Color.Black;
  WF.ColorBase = Color.Lime;
  WF.ColorPeak = Color.Red;
  // it is important to use the same resolution flags as for the playing stream
  // e.g. if an already playing stream is 32-bit float, so this should also be
  // or use 'SyncPlayback' as shown below
  WF.RenderStart(true, BASSFlag.BASS_DEFAULT);
}

private void MyWaveFormCallback(int framesDone, int framesTotal, TimeSpan elapsedTime, bool finished)
{
  // will be called during rendering...
  DrawWave();
  if (finished)
  {
    Console.WriteLine("Finished rendering in {0}sec.", elapsedTime);
    Console.WriteLine("FramesRendered={0} of {1}", WF.FramesRendered, WF.FramesToRender);
    // if your playback stream uses a different resolution than the WF
    // use this to sync them
    WF.SyncPlayback(_stream);
  }
}

private void DrawWave()
{
  if (WF != null)
    this.pictureBox1.BackgroundImage = WF.CreateBitmap(this.pictureBox1.Width, 
                                                       this.pictureBox1.Height, 
                                                       -1, -1, false);
  else
    this.pictureBox1.BackgroundImage = null;
}
See Also

Reference