示例#1
0
        public FastBitmap DrawGraph(string StatName, double MaxVal)
        {
            Bitmap     bitmap = new Bitmap(200, 200, 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[] Stats2 = new double[0];
            if (statManager != null)
            {
                Stats2 = 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, 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);
        }