public FastBitmap DrawGraph(string StatName) { Bitmap bitmap = new Bitmap(200, 200, PixelFormat.Format24bppRgb); FastBitmap bmp = new FastBitmap(bitmap); bmp.LockBitmap(); ProfilerValueManager statManager = GetStat(StatName); double MaxVal = 0; if (statManager != null) { MaxVal = statManager.GetMaxValue(); } double ScaleFactor = 1 / (MaxVal / 200); //We multiply by this so that the graph uses the full space double[] Stats2 = new double[0]; if (statManager != null) { Stats2 = statManager.GetInfos(); } for (int i = 0; i < Stats2.Length; i++) { //Update the scales Stats2[i] = Stats2[i] * ScaleFactor; } for (int x = 200; x > 0; x--) { for (int y = 200; y > 0; y--) { //Note: we do 200-y to flip the graph on the Y axis if (IsInGraphBar(x, y, Stats2, ScaleFactor)) { bmp.SetPixel(x, 200 - y, BarColor); } else { //Check whether the line needs drawn bmp.SetPixel(x, 200 - y, DrawLine(y, ScaleFactor) ? LineColor : BackgroundColor); } } } bmp.UnlockBitmap(); return(bmp); }
public FastBitmap DrawGraph(string StatName, double MaxVal) { Bitmap bitmap = new Bitmap(200, 200, System.Drawing.Imaging.PixelFormat.Format24bppRgb); FastBitmap bmp = new FastBitmap(bitmap); bmp.LockBitmap(); ProfilerValueManager statManager = GetStat(StatName); double ScaleFactor = 1 / (MaxVal / 200); //We multiply by this so that the graph uses the full space double[] Stats = statManager.GetInfos(); for (int x = 200; x > 0; x--) { for (int y = 200; y > 0; y--) { //Note: we do 200-y to flip the graph on the Y axis if (IsInGraphBar(x, y, Stats, ScaleFactor)) { bmp.SetPixel(x, 200 - y, BarColor); } else { //Check whether the line needs drawn if (DrawLine(y, ScaleFactor)) { bmp.SetPixel(x, 200 - y, LineColor); } else { bmp.SetPixel(x, 200 - y, BackgroundColor); } } } } bmp.UnlockBitmap(); return(bmp); }