Return to Snippet

Revision: 23354
at February 4, 2010 16:25 by jimfred


Initial Code
string filename = @"C:\0\test.bmp";
int width = 640;
int height = 480;
Bitmap b = new Bitmap(width, height);

for (int i = 0; i < width; i++)
{
    int y = (int)((Math.Sin((double)i*2.0*Math.PI/width )+1.0)*(height-1)/2.0);
    b.SetPixel(i, y, Color.Black); 
}
b.Save(filename);

Initial URL

                                

Initial Description
For MFC, see: http://snipplr.com/view/24917/mfc-cimage-cmitmap-draw-a-sine-wave-and-save-to-a-bmp-file/

Initial Title
C#, draw sine wave on Bitmap and save to a file

Initial Tags

                                

Initial Language
C#