protected void AddOverlay(Bitmap bmp, ColourScale cs) { int divInc = 0; int pixInc = 0; int xStart = 0; if (groupsToSide) { xStart = SIDE_BOX_SIZE; } double cumu = 0; double cnt = 0; for (int j = 0; j < entries; j++) { cumu += rankVal[j]; cnt++; divInc++; if (divInc % rangeBoxCount == 0) { int blen = Math.Min((int)(cumu / cnt), baseCount - 1); for (int i = 0; i < blen; i++) { SetOverLayPix(cs, bmp, i + xStart, pixInc); } pixInc++; } } }
protected void SetOverLayPix(ColourScale cs, Bitmap bmp, int x, int y) { Color stcol = bmp.GetPixel(x, y); Color next; if (cs == ColourScale.GreenBlue) { next = Color.FromArgb(Math.Min((int)stcol.R + 120, 255), Math.Min((int)stcol.G + 10, 255), Math.Min((int)stcol.B + 10, 255)); } else { next = Color.FromArgb(Math.Min((int)stcol.R + 10, 255), Math.Min((int)stcol.G + 10, 255), Math.Min((int)stcol.B + 120, 255)); } bmp.SetPixel(x, y, next); }
protected Color GetScaledColor(double min, double max, double mean, double stdDev, double v, ColourScale cs) { if (v > 0) { double st2 = mean + stdDev * COL2_SCALE; double scale = (v - min) / (st2 - min); int c1; int c2; if (scale < 1) { c1 = 30 + (int)(225.0 * scale); c2 = 30; } else { scale = (v - st2) / (max - st2); c1 = 255; c2 = 30 + (int)(225.0 * scale); } if (cs == ColourScale.GreenBlue) { return(Color.FromArgb(0, c1, c2)); } else { return(Color.FromArgb(c2, c1, 0)); } } else { return(Color.Black); } }
protected Bitmap MakeBmap(List <List <double> > colScal, ColourScale cs) { int xPix = baseCount; int xStart = 0; if (groupsToSide) { xPix += SIDE_BOX_SIZE; xStart = SIDE_BOX_SIZE; } int yPix = entries / rangeBoxCount; if (entries % rangeBoxCount != 0) { yPix++; } Bitmap bmp = new Bitmap(xPix, yPix); double min = 9999999; double max = 0; List <double> all = new List <double>(); for (int i = 0; i < baseCount; i++) { for (int j = 0; j < entries; j++) { if (double.IsNaN(colScal [j] [i])) { colScal [j] [i] = 0; } all.Add(colScal[j][i]); min = Math.Min(min, colScal[j][i]); max = Math.Max(max, colScal[j][i]); } } double stdDev = Statistics.StandardDeviation(all); double mean = Statistics.Mean(all); for (int i = 0; i < baseCount; i++) { int divInc = 0; int pixInc = 0; List <Color> cols = new List <Color>(); for (int j = 0; j < entries; j++) { divInc++; cols.Add(GetScaledColor(min, max, mean, stdDev, colScal[j][i], cs)); if (divInc % rangeBoxCount == 0) { bmp.SetPixel(i + xStart, pixInc, MergeColList(cols)); pixInc++; cols.Clear(); } } } if (groupsToSide) { DrawSideBoxes(bmp); } if (overlayLengths) { AddOverlay(bmp, cs); } return(bmp); }