The best way to do this is using the background image of a 2D Scattergraph. Each pixel in the bitmap is a data point. It is really fast. I can do a 3200X1024 bitmap each second without any noticable flicker. Here's some C# code on how to do it.
Note I'm using a gray scale bitmap which is a byte array and a certain PixelFormat. Just use an int array for the bitmap and specify a PixelFormat of color (32bit RGB).
There you have it.
Scott
private void ShowBlockOfData()
{
int width = _EqualizedData[0].Length;
int height = _EqualizedData.Length;
scatterGraph1.PlotAreaImageAlignment = ImageAlignment.Center;
PrepareBitmap(width, height );
//
// Now create a dummy bitmap. Use the LockBits method to lock the data in
// memory. This is much faster than SetPixel (I'm not sure you
// can use SetPixel with an Indexed type image. )
Rectangle rec = new Rectangle(0, 0, _Plot.Width, _Plot.Height);
BitmapData bmd = _Plot.LockBits( rec, System.Drawing.Imaging.ImageLockMode.ReadWrite, _Plot.PixelFormat);
unsafe
{
for(int y=0; y < bmd.Height; y++)
{
byte* row= (byte*)bmd.Scan0.ToPointer()+(y*bmd.Stride);
for(int x=0; x < bmd.Width; x++ )
{
row[x] = _EqualizedData[y][x];
}
}
}
_Plot.UnlockBits(bmd);
scatterGraph1.PlotAreaImage = _Plot;
}
private void PrepareBitmap(int width, int height )
{
// Create a new bitmap the first time, otherwise use the old one
// to create a new one. Hopefully, this will save us resources.
if ( _Plot == null )
_Plot = new Bitmap(width, height, PixelFormat.Format8bppIndexed );
AssignPalette( );
}
///
/// If the palette is null, create it and preserve it internally
/// Set the images palette to our ColorPalette member.
///
private void AssignPalette()
{
if ( _palette == null )
{
// Get the color palette from the image. You can't
// create one from scratch.
_palette = _Plot.Palette;
// Create a grayscale palette by changing this one.
for ( int i = 0; i < _palette.Entries.Length; i++ )
{
int c = 255-i;
_palette.Entries[i] = Color.FromArgb( c,c,c );
}
}
_Plot.Palette = _palette;
}