void drawRawChroms() { int pixelWidth, pixelHeight; WriteableBitmap bitmap; PixelFormat pixelFormat = PixelFormats.Bgra32; int bytesPerPixel = pixelFormat.BitsPerPixel / 8; byte[] byteData; Rect visRect; float tot, r, g, b, a; int ncells = 0; int pos; if (visOutSet.visRawSeries.Length > 0) { visRect = visOutSet.visRawSeries[0].visRect; pixelWidth = (int)(width * visRect.Width); pixelHeight = (int)(height * visRect.Height); bitmap = new WriteableBitmap(pixelWidth, pixelHeight, 96, 96, pixelFormat, null); byteData = new byte[pixelHeight * pixelWidth * bytesPerPixel]; rBuffer = new float[pixelWidth, pixelHeight]; gBuffer = new float[pixelWidth, pixelHeight]; bBuffer = new float[pixelWidth, pixelHeight]; totBuffer = new float[pixelWidth, pixelHeight]; foreach (VisSerie visSerie in visOutSet.visRawSeries) { circlePattern = Util.getCirclePoints(convVirtYsize(visSerie.drawSize / 2)); drawChrom(visSerie, bitmap); ncells += visSerie.visPoints.Length; } ncells /= visOutSet.comps.Count; pos = 0; for (int y = 0; y < pixelHeight; y++) { for (int x = 0; x < pixelWidth; x++) { tot = totBuffer[x, y]; if (tot != 0) { r = rBuffer[x, y] / tot; if (r > 1) { r = 1; } g = gBuffer[x, y] / tot; if (g > 1) { g = 1; } b = bBuffer[x, y] / tot; if (b > 1) { b = 1; } a = tot * 10 / ncells; if (a > 1) { a = 1; } byteData[pos] = (byte)(b * 0xFF); byteData[pos + 1] = (byte)(g * 0xFF); byteData[pos + 2] = (byte)(r * 0xFF); byteData[pos + 3] = (byte)(a * 0xFF); } pos += bytesPerPixel; } } bitmap.WritePixels(new Int32Rect(0, 0, pixelWidth, pixelHeight), byteData, pixelWidth * bytesPerPixel, 0, 0); mainImage.Margin = new Thickness(0, ymargin1, 0, 0); mainImage.Source = bitmap; mainImage.InvalidateVisual(); } }