public BitmapSource Render(RenderSourceType render_source) { IImageRaster <IRaster2DInteger, ElementValueType> rendered_image = inner_renderer.Render(render_source); BitmapFast bitmap_fast = new BitmapFast(rendered_image.Raster.Size0, rendered_image.Raster.Size1); bitmap_fast.Lock(); for (int y_index = 0; y_index < rendered_image.Raster.Size1; y_index++) { for (int x_index = 0; x_index < rendered_image.Raster.Size0; x_index++) { bitmap_fast.SetPixel(x_index, y_index, converter.Compute(rendered_image.GetElementValue(rendered_image.Raster.GetElementIndex(x_index, y_index)))); } } bitmap_fast.Unlock(); return(ToolsRendering.CreateBitmapSourceFromBitmap(bitmap_fast.Bitmap)); }
public BitmapFast Render(RenderSourceType render_source) { IImageRaster <IRaster2DInteger, ElementValueType> rendered_image = inner_renderer.Render(render_source); BitmapFast bitmap_fast = new BitmapFast(rendered_image.Raster.Size0, rendered_image.Raster.Size1); bitmap_fast.Lock(); //for (int y_index = 0; y_index < rendered_image.Raster.SizeY; y_index++) //{ Parallel.For(0, rendered_image.Raster.Size1, y_index => { for (int x_index = 0; x_index < rendered_image.Raster.Size0; x_index++) { bitmap_fast.SetPixel(x_index, y_index, converter.Compute(rendered_image.GetElementValue(rendered_image.Raster.GetElementIndex(x_index, y_index)))); } }); bitmap_fast.Unlock(); return(bitmap_fast); }
public void Render(BitmapFast bitmap_fast, Tuple <IImageRaster2D <bool>, IImageRaster2D <Color> > render_image) { IImageRaster2D <bool> mask = render_image.Item1; IImageRaster2D <Color> color = render_image.Item2; bitmap_fast.Lock(); for (int y_index = 0; y_index < bitmap_fast.Height; y_index++) { for (int x_index = 0; x_index < bitmap_fast.Width; x_index++) { if (mask.GetElementValue(x_index, y_index)) { bitmap_fast.SetPixel(x_index, y_index, color.GetElementValue(x_index, y_index)); } } } bitmap_fast.Unlock(); }
public BitmapFast Render(Tuple <double[][], Color[]> render_image) { double[][] points = render_image.Item1; Color[] colors = render_image.Item2; double [][] projected_points = new double [points.Length][]; int[] coordinates = new int[3]; for (int point_index = 0; point_index < points.Length; point_index++) { projected_points[point_index] = (projection_matrix * (points[point_index] - offset_matrix)).ToArray1DFloat64(); } Raster2DInteger bitmap_raster = new Raster2DInteger(bitmap_size_x, bitmap_size_y); BitmapFast destination_image = new BitmapFast(this.bitmap_size_x, this.bitmap_size_y); destination_image.Lock(); for (int index_y = 0; index_y < bitmap_raster.Size1; index_y++) { for (int index_x = 0; index_x < bitmap_raster.Size0; index_x++) { destination_image.SetPixel(index_x, index_y, Color.Black); } } for (int element_index = 0; element_index < points.Length; element_index++) { int x_target = (int)(projected_points[element_index][0] * this.scale) + (bitmap_raster.Size0 / 2); int y_target = (int)(projected_points[element_index][1] * this.scale) + (bitmap_raster.Size1 / 2); if (bitmap_raster.ContainsCoordinates(x_target, y_target)) { destination_image.SetPixel(x_target, y_target, colors[element_index]); } } destination_image.Unlock(); return(destination_image); }