Wednesday, July 08, 2009

draw sine wave on Bitmap

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);

Sunday, March 15, 2009

Conditional("DEBUG")

#if defined( DEBUG) in C# - use [Conditional("DEBUG")]


System.Diagnostics.Debug uses [Conditional("DEBUG")].

ILDASM.EXE shows that no code is generated.

Copy this code and paste it in your HTML

[Conditional("DEBUG")]
private static void debugtest()
{
...
}

Tuesday, February 10, 2009

Cache

Cache.Insert("KeyValue", someValue, null, DateTime.Now.AddMinutes(15), System.Web.Caching.Cache.NoSlidingExpiration);