public PreviewImage(BitmapSource image, IColorHandler colorHandler, bool useStdDevStretch, int quality) { Image = image; ColorHandler = colorHandler; UseStdDevStretch = useStdDevStretch; Quality = quality; }
public PreviewImage(BitmapSource image, IColorHandler colorHandler, bool useStdDevStretch, int quality) { Image = image; ColorHandler = colorHandler; UseStdDevStretch = useStdDevStretch; Quality = quality; }
public Visualizer(IColorHandler colorHandler) { this.colorHandler = colorHandler; }
private static unsafe BitmapSource CreateBitmapSource(Grid<int> grid, SQuantizedExtent3D extent, QuantizedStatistics statistics, bool useStdDevStretch, IColorHandler colorHandler, int quality) { var ramp = colorHandler as ColorRamp; var map = colorHandler as ColorMapDistinct; var bmp = new WriteableBitmap(grid.SizeX, grid.SizeY, 96, 96, System.Windows.Media.PixelFormats.Bgra32, null); bmp.Lock(); var pBackBuffer = bmp.BackBuffer; var p = (int*)pBackBuffer; if (map != null) { //CreateColorBufferMap(grid, p, map); } else { if (ramp == null) ramp = ColorRamp.PredefinedColorRamps.Grayscale; var qualityRatio = (float)quality / 100; var rampSize = (int)(qualityRatio * 300); StretchBase stretch = null; if(useStdDevStretch) stretch = new StdDevStretch(extent.MinZ, extent.MaxZ, statistics, 2); else stretch = new MinMaxStretch(extent.MinZ, extent.MaxZ); var cachedRamp = ramp.CreateCachedRamp(stretch, rampSize); //var sw = Stopwatch.StartNew(); //int count = 300; //for (int i = 0; i < count; i++) { CreateColorBufferMap(grid, p, cachedRamp); } //sw.Stop(); //Context.WriteLine("fps: {0}", (double)1000 * count / sw.ElapsedMilliseconds); } bmp.AddDirtyRect(new System.Windows.Int32Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight)); bmp.Unlock(); bmp.Freeze(); return bmp; }
private static unsafe BitmapSource CreateBitmapSource(Grid <int> grid, SQuantizedExtent3D extent, QuantizedStatistics statistics, bool useStdDevStretch, IColorHandler colorHandler, int quality) { var ramp = colorHandler as ColorRamp; var map = colorHandler as ColorMapDistinct; var bmp = new WriteableBitmap(grid.SizeX, grid.SizeY, 96, 96, System.Windows.Media.PixelFormats.Bgra32, null); bmp.Lock(); var pBackBuffer = bmp.BackBuffer; var p = (int *)pBackBuffer; if (map != null) { //CreateColorBufferMap(grid, p, map); } else { if (ramp == null) { ramp = ColorRamp.PredefinedColorRamps.Grayscale; } var qualityRatio = (float)quality / 100; var rampSize = (int)(qualityRatio * 300); StretchBase stretch = null; if (useStdDevStretch) { stretch = new StdDevStretch(extent.MinZ, extent.MaxZ, statistics, 2); } else { stretch = new MinMaxStretch(extent.MinZ, extent.MaxZ); } var cachedRamp = ramp.CreateCachedRamp(stretch, rampSize); //var sw = Stopwatch.StartNew(); //int count = 300; //for (int i = 0; i < count; i++) { CreateColorBufferMap(grid, p, cachedRamp); } //sw.Stop(); //Context.WriteLine("fps: {0}", (double)1000 * count / sw.ElapsedMilliseconds); } bmp.AddDirtyRect(new System.Windows.Int32Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight)); bmp.Unlock(); bmp.Freeze(); return(bmp); }
public void UnSubscribe(IColorHandler item) { handlers.Remove(item); }
public void Subscribe(IColorHandler item) { handlers.Add(item); }