public ShowPix(Pix Pix, string Text = "") { Load += ShowPix_Load; InitializeComponent(); this.Text = Text; if (Pix == null) { return; } PicBox.LoadImage(Pix.ToBitmap()); this.ShowDialog(); }
public Pix DisplayNumaHeatmap(Numa NumaH = null, Pix BgPix = null, bool Swap = false) { var NumaW = this; if (Swap == true) { var TMpH = NumaH; var TmpW = NumaW; NumaH = TmpW; NumaW = TMpH; } int NumaHCnt = 1; if (NumaH != null) { NumaHCnt = NumaH.n; } int NumaWCnt = 1; if (NumaW != null) { NumaWCnt = NumaW.n; } double NumaHMax = 1; if (NumaH != null) { NumaHMax = (int)NumaH.array.Max(); } double NumaWMax = 1; if (NumaW != null) { NumaWMax = (int)NumaW.array.Max(); } int VMaxH = (int)(Math.Max(NumaHMax, NumaWCnt)); if (VMaxH > 2000) { VMaxH = 2000; } int VMaxW = (int)(Math.Max(NumaWMax, NumaHCnt)); if (VMaxW > 2000) { VMaxW = 2000; } int xres = 96, yres = 96; if (BgPix != null) { VMaxH = (int)BgPix.h; VMaxW = (int)BgPix.w; xres = BgPix.xres; yres = BgPix.yres; } double VDiffH = VMaxH / NumaHMax; double VDiffW = VMaxW / NumaWMax; using (var n = new Bitmap(VMaxW, VMaxH, PixelFormat.Format32bppArgb)) { n.SetResolution(xres, yres); using (var g = Graphics.FromImage(n)) { if (BgPix == null) { g.FillRectangle(Brushes.WhiteSmoke, new Rectangle(0, 0, VMaxW, VMaxH)); } if (BgPix != null) { g.DrawImage(BgPix.ToBitmap(), new Point(0, 0)); } if (NumaW != null) { int BarHeight = System.Convert.ToInt32(VMaxH / NumaWCnt); for (int i = 0; i <= NumaW.n - 1; i++) { int BarPos = (i * BarHeight) + (BarHeight == 1 ? 0 : (BarHeight / 2)); using (var Pen = new Pen(Color.FromArgb(System.Convert.ToInt32((130 / NumaWMax) * NumaW.array[i]), 0, 255, 0), BarHeight)) { var P1 = new Point(0, BarPos); var P2 = new Point(VMaxW, BarPos); g.DrawLine(Pen, P1, P2); } } } if (NumaH != null) { int BarWidth = Math.Max(System.Convert.ToInt32(VMaxW / NumaHCnt), 1); for (int i = 0; i <= NumaH.n - 1; i++) { int BarPos = (i * BarWidth) + (BarWidth == 1 ? 0 : (BarWidth / 2)); using (var Pen = new Pen(Color.FromArgb(System.Convert.ToInt32((130 / NumaHMax) * NumaH.array[i]), 0, 0, 255), BarWidth)) { var P1 = new Point(BarPos, 0); var P2 = new Point(BarPos, VMaxH); g.DrawLine(Pen, P1, P2); } } } return(new Pix(n)); } } }
public Pix DisplayNumaBarGraph(Numa NumaH = null, Pix BgPix = null, bool Swap = false) { var NumaW = this; if (Swap == true) { var TMpH = NumaH; var TmpW = this; NumaH = TmpW; NumaW = TMpH; } int NumaHCnt = 1; if (NumaH != null) { NumaHCnt = NumaH.n; } int NumaWCnt = 1; if (NumaW != null) { NumaWCnt = NumaW.n; } double NumaHMax = 1; if (NumaH != null) { NumaHMax = (int)NumaH.array.Max(); } double NumaWMax = 1; if (NumaW != null) { NumaWMax = (int)NumaW.array.Max(); } int VMaxH = (int)Math.Max(NumaHMax, NumaWCnt); if (VMaxH > 2000) { VMaxH = 2000; } int VMaxW = (int)Math.Max(NumaWMax, NumaHCnt); if (VMaxW > 2000) { VMaxW = 2000; } int xres = 96, yres = 96; if (BgPix != null) { VMaxH = (int)BgPix.h; VMaxW = (int)BgPix.w; xres = BgPix.xres; yres = BgPix.yres; } double DiffH = VMaxH / NumaHMax; double DiffW = VMaxW / NumaWMax; using (var n = new Bitmap(VMaxW, VMaxH, PixelFormat.Format32bppArgb)) { n.SetResolution(xres, yres); using (var Pen1 = new Pen(Color.FromArgb(150, 0, 255, 0), 1)) using (var Pen2 = new Pen(Color.FromArgb(150, 255, 0, 0), 1)) using (var g = Graphics.FromImage(n)) { if (BgPix == null) { g.FillRectangle(Brushes.WhiteSmoke, new Rectangle(0, 0, VMaxW, VMaxH)); } if (BgPix != null) { g.DrawImage(BgPix.ToBitmap(), new Point(0, 0)); } if (NumaW != null) { for (int i = 0; i <= NumaW.n - 1; i++) { g.DrawLine(Pen1, new Point(0, i + 1), new Point((int)NumaW.array[i] * (int)DiffW, i + 1)); } } if (NumaH != null) { for (int i = 0; i <= NumaH.n - 1; i++) { g.DrawLine(Pen2, new Point(i + 1, (int)VMaxH - ((int)NumaH.array[i] * (int)DiffH)), new Point(i + 1, VMaxH)); } } return(new Pix(n)); } } }