Exemplo n.º 1
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			ScanlineRasterizer ras = new ScanlineRasterizer();
			scanline_unpacked_8 sl = new scanline_unpacked_8();

			ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage);
			clippingProxy.clear(new RGBA_Floats(0, 0, 0));

			m_profile.text_size(8.0);

			// draw a background to show how the alpha is working
			int RectWidth = 32;
			int xoffset = 238;
			int yoffset = 171;
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			for (int i = 0; i < 7; i++)
			{
				for (int j = 0; j < 7; j++)
				{
					if ((i + j) % 2 != 0)
					{
						VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset,
							(i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2);
						rect.normalize_radius();

						ras.add_path(rect);
						scanlineRenderer.RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(.9, .9, .9));
					}
				}
			}

			double ini_scale = 1.0;

			Transform.Affine mtx1 = Affine.NewIdentity();
			mtx1 *= Affine.NewScaling(ini_scale, ini_scale);
			mtx1 *= Affine.NewTranslation(center_x, center_y);

			VertexSource.Ellipse e1 = new MatterHackers.Agg.VertexSource.Ellipse();
			e1.init(0.0, 0.0, 110.0, 110.0, 64);

			Transform.Affine mtx_g1 = Affine.NewIdentity();
			mtx_g1 *= Affine.NewScaling(ini_scale, ini_scale);
			mtx_g1 *= Affine.NewScaling(m_SaveData.m_scale, m_SaveData.m_scale);
			mtx_g1 *= Affine.NewScaling(m_scale_x, m_scale_y);
			mtx_g1 *= Affine.NewRotation(m_SaveData.m_angle);
			mtx_g1 *= Affine.NewTranslation(m_SaveData.m_center_x, m_SaveData.m_center_y);
			mtx_g1.invert();

			RGBA_Bytes[] color_profile = new RGBA_Bytes[256]; // color_type is defined in pixel_formats.h
			for (int i = 0; i < 256; i++)
			{
				color_profile[i] = new RGBA_Bytes(m_spline_r.spline()[i],
														m_spline_g.spline()[i],
														m_spline_b.spline()[i],
														m_spline_a.spline()[i]);
			}

			VertexSourceApplyTransform t1 = new VertexSourceApplyTransform(e1, mtx1);

			IGradient innerGradient = null;
			switch (m_GradTypeRBox.SelectedIndex)
			{
				case 0:
					innerGradient = new gradient_radial();
					break;

				case 1:
					innerGradient = new gradient_diamond();
					break;

				case 2:
					innerGradient = new gradient_x();
					break;

				case 3:
					innerGradient = new gradient_xy();
					break;

				case 4:
					innerGradient = new gradient_sqrt_xy();
					break;

				case 5:
					innerGradient = new gradient_conic();
					break;
			}

			IGradient outerGradient = null;
			switch (m_GradWrapRBox.SelectedIndex)
			{
				case 0:
					outerGradient = new gradient_reflect_adaptor(innerGradient);
					break;

				case 1:
					outerGradient = new gradient_repeat_adaptor(innerGradient);
					break;

				case 2:
					outerGradient = new gradient_clamp_adaptor(innerGradient);
					break;
			}

			span_allocator span_alloc = new span_allocator();
			color_function_profile colors = new color_function_profile(color_profile, m_profile.gamma());
			span_interpolator_linear inter = new span_interpolator_linear(mtx_g1);
			span_gradient span_gen = new span_gradient(inter, outerGradient, colors, 0, 150);

			ras.add_path(t1);
			scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy, span_alloc, span_gen);
			base.OnDraw(graphics2D);
		}
Exemplo n.º 2
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			if (orignialSize.x == 0)
			{
				orignialSize.x = WindowSize.x;
				orignialSize.y = WindowSize.y;
			}

			ImageBuffer destImageWithPreMultBlender = new ImageBuffer();
			switch (widgetsSubImage.BitDepth)
			{
				case 24:
					destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGR());
					break;

				case 32:
					destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGRA());
					break;

				default:
					throw new Exception("Unknown bit depth");
			}

			ImageClippingProxy clippingProxy_pre = new ImageClippingProxy(destImageWithPreMultBlender);

			clippingProxy_pre.clear(new RGBA_Floats(1.0, 1.0, 1.0));

			Affine src_mtx = Affine.NewIdentity();
			src_mtx *= Affine.NewTranslation(-orignialSize.x / 2 - 10, -orignialSize.y / 2 - 20 - 10);
			src_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0);
			src_mtx *= Affine.NewScaling(drawScale.Value);
			src_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20);

			Affine img_mtx = Affine.NewIdentity();
			img_mtx *= Affine.NewTranslation(-orignialSize.x / 2 + 10, -orignialSize.y / 2 + 20 + 10);
			img_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0);
			img_mtx *= Affine.NewScaling(drawScale.Value);
			img_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20);
			img_mtx.invert();

			MatterHackers.Agg.span_allocator sa = new span_allocator();

			span_interpolator_linear interpolator = new span_interpolator_linear(img_mtx);

			span_image_filter sg;
			switch (sourceImage.BitDepth)
			{
				case 24:
					{
						ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes());
						sg = new span_image_filter_rgb_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator);
					}
					break;

				case 32:
					{
						ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes());
						sg = new span_image_filter_rgba_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator);
					}
					break;

				default:
					throw new Exception("Bad sourc depth");
			}

			ScanlineRasterizer ras = new ScanlineRasterizer();
			ras.SetVectorClipBox(0, 0, Width, Height);
			ScanlineCachePacked8 sl = new ScanlineCachePacked8();
			//scanline_unpacked_8 sl = new scanline_unpacked_8();

			double r = orignialSize.x;
			if (orignialSize.y - 60 < r)
			{
				r = orignialSize.y - 60;
			}

			VertexSource.Ellipse ell = new VertexSource.Ellipse(orignialSize.x / 2.0 + 10,
				orignialSize.y / 2.0 + 20 + 10,
				r / 2.0 + 16.0,
				r / 2.0 + 16.0, 200);

			VertexSourceApplyTransform tr = new VertexSourceApplyTransform(ell, src_mtx);

			ras.add_path(tr);
			//clippingProxy_pre.SetClippingBox(30, 0, (int)width(), (int)height());
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy_pre, sa, sg);

			base.OnDraw(graphics2D);
		}
Exemplo n.º 3
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			if (!didInit)
			{
				didInit = true;
				OnInitialize();
			}

			if (m_gamma.Value != m_old_gamma)
			{
				m_gamma_lut.SetGamma(m_gamma.Value);
				ImageIO.LoadImageData("spheres.bmp", m_SourceImage);
				//m_SourceImage.apply_gamma_dir(m_gamma_lut);
				m_old_gamma = m_gamma.Value;
			}

			ImageBuffer pixf = new ImageBuffer();
			switch (widgetsSubImage.BitDepth)
			{
				case 24:
					pixf.Attach(widgetsSubImage, new BlenderBGR());
					break;

				case 32:
					pixf.Attach(widgetsSubImage, new BlenderBGRA());
					break;

				default:
					throw new NotImplementedException();
			}

			ImageClippingProxy clippingProxy = new ImageClippingProxy(pixf);

			clippingProxy.clear(new RGBA_Floats(1, 1, 1));

			if (m_trans_type.SelectedIndex < 2)
			{
				// For the affine parallelogram transformations we
				// calculate the 4-th (implicit) point of the parallelogram
				m_quad.SetXN(3, m_quad.GetXN(0) + (m_quad.GetXN(2) - m_quad.GetXN(1)));
				m_quad.SetYN(3, m_quad.GetYN(0) + (m_quad.GetYN(2) - m_quad.GetYN(1)));
			}

			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			// draw a background to show how the alpha is working
			int RectWidth = 70;
			int xoffset = 50;
			int yoffset = 50;
			for (int i = 0; i < 7; i++)
			{
				for (int j = 0; j < 7; j++)
				{
					if ((i + j) % 2 != 0)
					{
						VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset,
							(i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2);
						rect.normalize_radius();

						g_rasterizer.add_path(rect);
						scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(.2, .2, .2));
					}
				}
			}

			//--------------------------
			// Render the "quad" tool and controls
			g_rasterizer.add_path(m_quad);
			scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0.3, 0.5, 0.1));

			// Prepare the polygon to rasterize. Here we need to fill
			// the destination (transformed) polygon.
			g_rasterizer.SetVectorClipBox(0, 0, Width, Height);
			g_rasterizer.reset();
			int b = 0;
			g_rasterizer.move_to_d(m_quad.GetXN(0) - b, m_quad.GetYN(0) - b);
			g_rasterizer.line_to_d(m_quad.GetXN(1) + b, m_quad.GetYN(1) - b);
			g_rasterizer.line_to_d(m_quad.GetXN(2) + b, m_quad.GetYN(2) + b);
			g_rasterizer.line_to_d(m_quad.GetXN(3) - b, m_quad.GetYN(3) + b);

			//typedef agg::span_allocator<color_type> span_alloc_type;
			span_allocator sa = new span_allocator();
			image_filter_bilinear filter_kernel = new image_filter_bilinear();
			ImageFilterLookUpTable filter = new ImageFilterLookUpTable(filter_kernel, true);

			ImageBufferAccessorClamp source = new ImageBufferAccessorClamp(m_SourceImage);

			stopwatch.Restart();

			switch (m_trans_type.SelectedIndex)
			{
				case 0:
					{
						/*
								agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);

								typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
								interpolator_type interpolator(tr);

								typedef image_filter_2x2_type<source_type,
															  interpolator_type> span_gen_type;
								span_gen_type sg(source, interpolator, filter);
								agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
						 */
						break;
					}

				case 1:
					{
						/*
								agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);

								typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
								typedef image_resample_affine_type<source_type> span_gen_type;

								interpolator_type interpolator(tr);
								span_gen_type sg(source, interpolator, filter);
								sg.blur(m_blur.Value);
								agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
						 */
						break;
					}

				case 2:
					{
						/*
								agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
								if(tr.is_valid())
								{
									typedef agg::span_interpolator_linear_subdiv<agg::trans_perspective> interpolator_type;
									interpolator_type interpolator(tr);

									typedef image_filter_2x2_type<source_type,
																  interpolator_type> span_gen_type;
									span_gen_type sg(source, interpolator, filter);
									agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
								}
						 */
						break;
					}

				case 3:
					{
						/*
								agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
								if(tr.is_valid())
								{
									typedef agg::span_interpolator_trans<agg::trans_perspective> interpolator_type;
									interpolator_type interpolator(tr);

									typedef image_filter_2x2_type<source_type,
																  interpolator_type> span_gen_type;
									span_gen_type sg(source, interpolator, filter);
									agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
								}
						 */
						break;
					}

				case 4:
					{
						//typedef agg::span_interpolator_persp_lerp<> interpolator_type;
						//typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type;

						span_interpolator_persp_lerp interpolator = new span_interpolator_persp_lerp(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
						span_subdiv_adaptor subdiv_adaptor = new span_subdiv_adaptor(interpolator);

						span_image_resample sg = null;
						if (interpolator.is_valid())
						{
							switch (source.SourceImage.BitDepth)
							{
								case 24:
									sg = new span_image_resample_rgb(source, subdiv_adaptor, filter);
									break;

								case 32:
									sg = new span_image_resample_rgba(source, subdiv_adaptor, filter);
									break;
							}

							sg.blur(m_blur.Value);
							scanlineRenderer.GenerateAndRender(g_rasterizer, g_scanline, clippingProxy, sa, sg);
						}
						break;
					}

				case 5:
					{
						/*
								typedef agg::span_interpolator_persp_exact<> interpolator_type;
								typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type;

								interpolator_type interpolator(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
								subdiv_adaptor_type subdiv_adaptor(interpolator);

								if(interpolator.is_valid())
								{
									typedef image_resample_type<source_type,
																subdiv_adaptor_type> span_gen_type;
									span_gen_type sg(source, subdiv_adaptor, filter);
									sg.blur(m_blur.Value);
									agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
								}
						 */
						break;
					}
			}

			double tm = stopwatch.ElapsedMilliseconds;
			//pixf.apply_gamma_inv(m_gamma_lut);

			gsv_text t = new gsv_text();
			t.SetFontSize(10.0);

			Stroke pt = new Stroke(t);
			pt.width(1.5);

			string buf = string.Format("{0:F2} ms", tm);
			t.start_point(10.0, 70.0);
			t.text(buf);

			g_rasterizer.add_path(pt);
			scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0, 0));

			//--------------------------
			//m_trans_type.Render(g_rasterizer, g_scanline, clippingProxy);
			//m_gamma.Render(g_rasterizer, g_scanline, clippingProxy);
			//m_blur.Render(g_rasterizer, g_scanline, clippingProxy);
			base.OnDraw(graphics2D);
		}
Exemplo n.º 4
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            if (orignialSize.x == 0)
            {
                orignialSize.x = WindowSize.x;
                orignialSize.y = WindowSize.y;
            }

            ImageBuffer destImageWithPreMultBlender = new ImageBuffer();

            switch (widgetsSubImage.BitDepth)
            {
            case 24:
                destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGR());
                break;

            case 32:
                destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGRA());
                break;

            default:
                throw new Exception("Unknown bit depth");
            }

            ImageClippingProxy clippingProxy_pre = new ImageClippingProxy(destImageWithPreMultBlender);

            clippingProxy_pre.clear(new RGBA_Floats(1.0, 1.0, 1.0));

            Affine src_mtx = Affine.NewIdentity();

            src_mtx *= Affine.NewTranslation(-orignialSize.x / 2 - 10, -orignialSize.y / 2 - 20 - 10);
            src_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0);
            src_mtx *= Affine.NewScaling(drawScale.Value);
            src_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20);

            Affine img_mtx = Affine.NewIdentity();

            img_mtx *= Affine.NewTranslation(-orignialSize.x / 2 + 10, -orignialSize.y / 2 + 20 + 10);
            img_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0);
            img_mtx *= Affine.NewScaling(drawScale.Value);
            img_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20);
            img_mtx.invert();

            MatterHackers.Agg.span_allocator sa = new span_allocator();

            span_interpolator_linear interpolator = new span_interpolator_linear(img_mtx);

            span_image_filter sg;

            switch (sourceImage.BitDepth)
            {
            case 24:
            {
                ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes());
                sg = new span_image_filter_rgb_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator);
            }
            break;

            case 32:
            {
                ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes());
                sg = new span_image_filter_rgba_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator);
            }
            break;

            default:
                throw new Exception("Bad sourc depth");
            }

            ScanlineRasterizer ras = new ScanlineRasterizer();

            ras.SetVectorClipBox(0, 0, Width, Height);
            ScanlineCachePacked8 sl = new ScanlineCachePacked8();
            //scanline_unpacked_8 sl = new scanline_unpacked_8();

            double r = orignialSize.x;

            if (orignialSize.y - 60 < r)
            {
                r = orignialSize.y - 60;
            }

            VertexSource.Ellipse ell = new VertexSource.Ellipse(orignialSize.x / 2.0 + 10,
                                                                orignialSize.y / 2.0 + 20 + 10,
                                                                r / 2.0 + 16.0,
                                                                r / 2.0 + 16.0, 200);

            VertexSourceApplyTransform tr = new VertexSourceApplyTransform(ell, src_mtx);

            ras.add_path(tr);
            //clippingProxy_pre.SetClippingBox(30, 0, (int)width(), (int)height());
            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();

            scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy_pre, sa, sg);

            if (false)             // this is test code to check different quality settings for scalling
            {
                Vector2 screenCenter = new Vector2(Width / 2, Height / 2);
                Vector2 deltaToMouse = mousePosition - screenCenter;
                double  angleToMouse = Math.Atan2(deltaToMouse.y, deltaToMouse.x);
                double  diagonalSize = Math.Sqrt(sourceImage.Width * sourceImage.Width + sourceImage.Height * sourceImage.Height);
                double  distToMouse  = deltaToMouse.Length;
                double  scalling     = distToMouse / diagonalSize;
                graphics2D.Render(sourceImage, Width / 2, Height / 2, angleToMouse - MathHelper.Tau / 8, scalling, scalling);
            }

            base.OnDraw(graphics2D);
        }
Exemplo n.º 5
0
		internal void render_gouraud(IImageByte backBuffer, IScanlineCache sl, IRasterizer ras, RenderPoint[] points)
		{
			ImageBuffer image = new ImageBuffer();
			image.Attach(backBuffer, new BlenderZBuffer());

			ImageClippingProxy ren_base = new ImageClippingProxy(image);

			MatterHackers.Agg.span_allocator span_alloc = new span_allocator();
			span_gouraud_rgba span_gen = new span_gouraud_rgba();

			span_gen.colors(points[0].color, points[1].color, points[2].color);
			span_gen.triangle(points[0].position.x, points[0].position.y, points[1].position.x, points[1].position.y, points[2].position.x, points[2].position.y);
			ras.add_path(span_gen);
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);
		}
Exemplo n.º 6
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            ScanlineRasterizer  ras = new ScanlineRasterizer();
            scanline_unpacked_8 sl  = new scanline_unpacked_8();

            ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage);

            clippingProxy.clear(new RGBA_Floats(0, 0, 0));

            m_profile.text_size(8.0);

            // draw a background to show how the alpha is working
            int RectWidth = 32;
            int xoffset   = 238;
            int yoffset   = 171;
            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if ((i + j) % 2 != 0)
                    {
                        VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset,
                                                                                     (i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2);
                        rect.normalize_radius();

                        ras.add_path(rect);
                        scanlineRenderer.render_scanlines_aa_solid(clippingProxy, ras, sl, new RGBA_Bytes(.9, .9, .9));
                    }
                }
            }

            double ini_scale = 1.0;

            Transform.Affine mtx1 = Affine.NewIdentity();
            mtx1 *= Affine.NewScaling(ini_scale, ini_scale);
            mtx1 *= Affine.NewTranslation(center_x, center_y);

            VertexSource.Ellipse e1 = new MatterHackers.Agg.VertexSource.Ellipse();
            e1.init(0.0, 0.0, 110.0, 110.0, 64);

            Transform.Affine mtx_g1 = Affine.NewIdentity();
            mtx_g1 *= Affine.NewScaling(ini_scale, ini_scale);
            mtx_g1 *= Affine.NewScaling(m_SaveData.m_scale, m_SaveData.m_scale);
            mtx_g1 *= Affine.NewScaling(m_scale_x, m_scale_y);
            mtx_g1 *= Affine.NewRotation(m_SaveData.m_angle);
            mtx_g1 *= Affine.NewTranslation(m_SaveData.m_center_x, m_SaveData.m_center_y);
            mtx_g1.invert();


            RGBA_Bytes[] color_profile = new RGBA_Bytes[256]; // color_type is defined in pixel_formats.h
            for (int i = 0; i < 256; i++)
            {
                color_profile[i] = new RGBA_Bytes(m_spline_r.spline()[i],
                                                  m_spline_g.spline()[i],
                                                  m_spline_b.spline()[i],
                                                  m_spline_a.spline()[i]);
            }

            VertexSourceApplyTransform t1 = new VertexSourceApplyTransform(e1, mtx1);

            IGradient innerGradient = null;

            switch (m_GradTypeRBox.SelectedIndex)
            {
            case 0:
                innerGradient = new gradient_radial();
                break;

            case 1:
                innerGradient = new gradient_diamond();
                break;

            case 2:
                innerGradient = new gradient_x();
                break;

            case 3:
                innerGradient = new gradient_xy();
                break;

            case 4:
                innerGradient = new gradient_sqrt_xy();
                break;

            case 5:
                innerGradient = new gradient_conic();
                break;
            }

            IGradient outerGradient = null;

            switch (m_GradWrapRBox.SelectedIndex)
            {
            case 0:
                outerGradient = new gradient_reflect_adaptor(innerGradient);
                break;

            case 1:
                outerGradient = new gradient_repeat_adaptor(innerGradient);
                break;

            case 2:
                outerGradient = new gradient_clamp_adaptor(innerGradient);
                break;
            }

            span_allocator           span_alloc = new span_allocator();
            color_function_profile   colors     = new color_function_profile(color_profile, m_profile.gamma());
            span_interpolator_linear inter      = new span_interpolator_linear(mtx_g1);
            span_gradient            span_gen   = new span_gradient(inter, outerGradient, colors, 0, 150);

            ras.add_path(t1);
            scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy, span_alloc, span_gen);
            base.OnDraw(graphics2D);
        }
Exemplo n.º 7
0
        //template<class Scanline, class Ras>
        public void render_gouraud(IImageByte backBuffer, IScanlineCache sl, IRasterizer ras)
        {
            double alpha = m_alpha.Value;
            double brc   = 1;

#if SourceDepth24
            pixfmt_alpha_blend_rgb pf = new pixfmt_alpha_blend_rgb(backBuffer, new blender_bgr());
#else
            ImageBuffer image = new ImageBuffer();
            image.Attach(backBuffer, new BlenderBGRA());
#endif
            ImageClippingProxy ren_base = new ImageClippingProxy(image);

            MatterHackers.Agg.span_allocator span_alloc = new span_allocator();
            span_gouraud_rgba span_gen = new span_gouraud_rgba();

            ras.gamma(new gamma_linear(0.0, m_gamma.Value));

            double d = m_dilation.Value;

            // Six triangles
            double xc = (m_x[0] + m_x[1] + m_x[2]) / 3.0;
            double yc = (m_y[0] + m_y[1] + m_y[2]) / 3.0;

            double x1 = (m_x[1] + m_x[0]) / 2 - (xc - (m_x[1] + m_x[0]) / 2);
            double y1 = (m_y[1] + m_y[0]) / 2 - (yc - (m_y[1] + m_y[0]) / 2);

            double x2 = (m_x[2] + m_x[1]) / 2 - (xc - (m_x[2] + m_x[1]) / 2);
            double y2 = (m_y[2] + m_y[1]) / 2 - (yc - (m_y[2] + m_y[1]) / 2);

            double x3 = (m_x[0] + m_x[2]) / 2 - (xc - (m_x[0] + m_x[2]) / 2);
            double y3 = (m_y[0] + m_y[2]) / 2 - (yc - (m_y[0] + m_y[2]) / 2);

            span_gen.colors(new ColorF(1, 0, 0, alpha),
                            new ColorF(0, 1, 0, alpha),
                            new ColorF(brc, brc, brc, alpha));
            span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], xc, yc, d);
            ras.add_path(span_gen);
            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
            scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

            span_gen.colors(new ColorF(0, 1, 0, alpha),
                            new ColorF(0, 0, 1, alpha),
                            new ColorF(brc, brc, brc, alpha));
            span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], xc, yc, d);
            ras.add_path(span_gen);
            scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

            span_gen.colors(new ColorF(0, 0, 1, alpha),
                            new ColorF(1, 0, 0, alpha),
                            new ColorF(brc, brc, brc, alpha));
            span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], xc, yc, d);
            ras.add_path(span_gen);
            scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

            brc = 1 - brc;
            span_gen.colors(new ColorF(1, 0, 0, alpha),
                            new ColorF(0, 1, 0, alpha),
                            new ColorF(brc, brc, brc, alpha));
            span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], x1, y1, d);
            ras.add_path(span_gen);
            scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

            span_gen.colors(new ColorF(0, 1, 0, alpha),
                            new ColorF(0, 0, 1, alpha),
                            new ColorF(brc, brc, brc, alpha));
            span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], x2, y2, d);
            ras.add_path(span_gen);
            scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

            span_gen.colors(new ColorF(0, 0, 1, alpha),
                            new ColorF(1, 0, 0, alpha),
                            new ColorF(brc, brc, brc, alpha));
            span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], x3, y3, d);
            ras.add_path(span_gen);
            scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);
        }
Exemplo n.º 8
0
        private void transform_image(double angle)
        {
            double width  = m_TempDestImage.Width;
            double height = m_TempDestImage.Height;

#if SourceDepthFloat
            ImageClippingProxyFloat clippedDest = new ImageClippingProxyFloat(m_TempDestImage);
#else
            ImageClippingProxy clippedDest = new ImageClippingProxy(m_TempDestImage);
#endif

            clippedDest.clear(new ColorF(1.0, 1.0, 1.0));

            Affine src_mtx = Affine.NewIdentity();
            src_mtx *= Affine.NewTranslation(-width / 2.0, -height / 2.0);
            src_mtx *= Affine.NewRotation(angle * Math.PI / 180.0);
            src_mtx *= Affine.NewTranslation(width / 2.0, height / 2.0);

            Affine img_mtx = new Affine(src_mtx);
            img_mtx.invert();

            double r = width;
            if (height < r)
            {
                r = height;
            }

            r *= 0.5;
            r -= 4.0;
            VertexSource.Ellipse       ell = new MatterHackers.Agg.VertexSource.Ellipse(width / 2.0, height / 2.0, r, r, 200);
            VertexSourceApplyTransform tr  = new VertexSourceApplyTransform(ell, src_mtx);

            m_num_pix += r * r * Math.PI;

#if SourceDepthFloat
            span_interpolator_linear_float interpolator = new span_interpolator_linear_float(img_mtx);
#else
            span_interpolator_linear interpolator = new span_interpolator_linear(img_mtx);
#endif

            ImageFilterLookUpTable filter = new ImageFilterLookUpTable();
            bool norm = m_normalize.Checked;

#if SourceDepthFloat
            ImageBufferAccessorClipFloat source = new ImageBufferAccessorClipFloat(m_RotatedImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).ToColorF());
#else
            ImageBufferAccessorClip source = new ImageBufferAccessorClip(m_RotatedImage, ColorF.rgba_pre(0, 0, 0, 0).ToColor());
#endif
            IImageFilterFunction filterFunction   = null;
            ScanlineRenderer     scanlineRenderer = new ScanlineRenderer();

            switch (filterSelectionButtons.SelectedIndex)
            {
            case 0:
            {
#if SourceDepthFloat
                span_image_filter_float spanGenerator;
#else
                span_image_filter spanGenerator;
#endif

                switch (source.SourceImage.BitDepth)
                {
                case 24:
#if SourceDepthFloat
                    throw new NotImplementedException();
#else
                    spanGenerator = new span_image_filter_rgb_nn(source, interpolator);
#endif
                    break;

                case 32:
#if SourceDepthFloat
                    throw new NotImplementedException();
#else
                    spanGenerator = new span_image_filter_rgba_nn(source, interpolator);
#endif
                    break;

                default:
                    throw new NotImplementedException("only support 24 and 32 bit");
                }

                m_Rasterizer.add_path(tr);
                scanlineRenderer.GenerateAndRender(m_Rasterizer, m_ScanlineUnpacked, clippedDest, m_SpanAllocator, spanGenerator);
            }
            break;

            case 1:
            {
#if SourceDepthFloat
                span_image_filter_float spanGenerator;
#else
                span_image_filter spanGenerator;
#endif
                switch (source.SourceImage.BitDepth)
                {
                case 24:
#if SourceDepthFloat
                    throw new NotImplementedException();
#else
                    spanGenerator = new span_image_filter_rgb_bilinear(source, interpolator);
#endif
                    break;

                case 32:
#if SourceDepthFloat
                    throw new NotImplementedException();
#else
                    spanGenerator = new span_image_filter_rgba_bilinear(source, interpolator);
#endif
                    break;

#if SourceDepthFloat
                case 128:
                    spanGenerator = new span_image_filter_rgba_bilinear_float(source, interpolator);
                    break;
#endif

                default:
                    throw new NotImplementedException("only support 24 and 32 bit");
                }
                m_Rasterizer.add_path(tr);
                scanlineRenderer.GenerateAndRender(m_Rasterizer, m_ScanlineUnpacked, clippedDest, m_SpanAllocator, spanGenerator);
            }
            break;

            case 5:
            case 6:
            case 7:
            {
                switch (filterSelectionButtons.SelectedIndex)
                {
                case 5: filter.calculate(new image_filter_hanning(), norm); break;

                case 6: filter.calculate(new image_filter_hamming(), norm); break;

                case 7: filter.calculate(new image_filter_hermite(), norm); break;
                }

#if SourceDepthFloat
                throw new NotImplementedException();
#else
                span_image_filter_rgb_2x2 spanGenerator = new span_image_filter_rgb_2x2(source, interpolator, filter);
#endif
                m_Rasterizer.add_path(tr);
#if SourceDepthFloat
                throw new NotImplementedException();
#else
                scanlineRenderer.GenerateAndRender(m_Rasterizer, m_ScanlineUnpacked, clippedDest, m_SpanAllocator, spanGenerator);
#endif
            }
            break;

            case 2:
            case 3:
            case 4:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            {
                switch (filterSelectionButtons.SelectedIndex)
                {
                case 2: filter.calculate(new image_filter_bicubic(), norm); break;

                case 3: filter.calculate(new image_filter_spline16(), norm); break;

                case 4: filter.calculate(new image_filter_spline36(), norm); break;

                case 8: filter.calculate(new image_filter_kaiser(), norm); break;

                case 9: filter.calculate(new image_filter_quadric(), norm); break;

                case 10: filter.calculate(new image_filter_catrom(), norm); break;

                case 11: filter.calculate(new image_filter_gaussian(), norm); break;

                case 12: filter.calculate(new image_filter_bessel(), norm); break;

                case 13: filter.calculate(new image_filter_mitchell(), norm); break;

                case 14: filter.calculate(new image_filter_sinc(m_radius.Value), norm); break;

                case 15: filter.calculate(new image_filter_lanczos(m_radius.Value), norm); break;

                case 16:
                    filterFunction = new image_filter_blackman(m_radius.Value);
                    //filterFunction = new image_filter_bilinear();
                    filter.calculate(filterFunction, norm);
                    break;
                }

#if SourceDepthFloat
                span_image_filter_float spanGenerator;
#else
                span_image_filter spanGenerator;
#endif
                switch (source.SourceImage.BitDepth)
                {
                case 24:
#if SourceDepthFloat
                    throw new NotImplementedException();
#else
                    spanGenerator = new span_image_filter_rgb(source, interpolator, filter);
#endif
                    break;

                case 32:
#if SourceDepthFloat
                    throw new NotImplementedException();
#else
                    spanGenerator = new span_image_filter_rgba(source, interpolator, filter);
#endif
                    break;

#if SourceDepthFloat
                case 128:
                    spanGenerator = new span_image_filter_rgba_float(source, interpolator, filterFunction);
                    break;
#endif

                default:
                    throw new NotImplementedException("only support 24 and 32 bit");
                }

                m_Rasterizer.add_path(tr);
                scanlineRenderer.GenerateAndRender(m_Rasterizer, m_ScanlineUnpacked, clippedDest, m_SpanAllocator, spanGenerator);
            }
            break;
            }
        }
Exemplo n.º 9
0
		//template<class Scanline, class Ras>
		public void render_gouraud(IImageByte backBuffer, IScanlineCache sl, IRasterizer ras)
		{
			double alpha = m_alpha.Value;
			double brc = 1;
#if SourceDepth24
            pixfmt_alpha_blend_rgb pf = new pixfmt_alpha_blend_rgb(backBuffer, new blender_bgr());
#else
			ImageBuffer image = new ImageBuffer();
			image.Attach(backBuffer, new BlenderBGRA());
#endif
			ImageClippingProxy ren_base = new ImageClippingProxy(image);

			MatterHackers.Agg.span_allocator span_alloc = new span_allocator();
			span_gouraud_rgba span_gen = new span_gouraud_rgba();

			ras.gamma(new gamma_linear(0.0, m_gamma.Value));

			double d = m_dilation.Value;

			// Six triangles
			double xc = (m_x[0] + m_x[1] + m_x[2]) / 3.0;
			double yc = (m_y[0] + m_y[1] + m_y[2]) / 3.0;

			double x1 = (m_x[1] + m_x[0]) / 2 - (xc - (m_x[1] + m_x[0]) / 2);
			double y1 = (m_y[1] + m_y[0]) / 2 - (yc - (m_y[1] + m_y[0]) / 2);

			double x2 = (m_x[2] + m_x[1]) / 2 - (xc - (m_x[2] + m_x[1]) / 2);
			double y2 = (m_y[2] + m_y[1]) / 2 - (yc - (m_y[2] + m_y[1]) / 2);

			double x3 = (m_x[0] + m_x[2]) / 2 - (xc - (m_x[0] + m_x[2]) / 2);
			double y3 = (m_y[0] + m_y[2]) / 2 - (yc - (m_y[0] + m_y[2]) / 2);

			span_gen.colors(new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], xc, yc, d);
			ras.add_path(span_gen);
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], xc, yc, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], xc, yc, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			brc = 1 - brc;
			span_gen.colors(new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], x1, y1, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], x2, y2, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], x3, y3, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);
		}
Exemplo n.º 10
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            if (!didInit)
            {
                didInit = true;
                OnInitialize();
            }

            if (m_gamma.Value != m_old_gamma)
            {
                m_gamma_lut.SetGamma(m_gamma.Value);
                AggContext.ImageIO.LoadImageData("spheres.bmp", m_SourceImage);
                //m_SourceImage.apply_gamma_dir(m_gamma_lut);
                m_old_gamma = m_gamma.Value;
            }

            ImageBuffer pixf = new ImageBuffer();

            switch (widgetsSubImage.BitDepth)
            {
            case 24:
                pixf.Attach(widgetsSubImage, new BlenderBGR());
                break;

            case 32:
                pixf.Attach(widgetsSubImage, new BlenderBGRA());
                break;

            default:
                throw new NotImplementedException();
            }

            ImageClippingProxy clippingProxy = new ImageClippingProxy(pixf);

            clippingProxy.clear(new ColorF(1, 1, 1));

            if (m_trans_type.SelectedIndex < 2)
            {
                // For the affine parallelogram transformations we
                // calculate the 4-th (implicit) point of the parallelogram
                m_quad.SetXN(3, m_quad.GetXN(0) + (m_quad.GetXN(2) - m_quad.GetXN(1)));
                m_quad.SetYN(3, m_quad.GetYN(0) + (m_quad.GetYN(2) - m_quad.GetYN(1)));
            }

            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
            // draw a background to show how the alpha is working
            int RectWidth = 70;
            int xoffset   = 50;
            int yoffset   = 50;

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if ((i + j) % 2 != 0)
                    {
                        VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset,
                                                                                     (i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2);
                        rect.normalize_radius();

                        g_rasterizer.add_path(rect);
                        scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new Color(.2, .2, .2));
                    }
                }
            }

            //--------------------------
            // Render the "quad" tool and controls
            g_rasterizer.add_path(m_quad);
            scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new Color(0, 0.3, 0.5, 0.1));

            // Prepare the polygon to rasterize. Here we need to fill
            // the destination (transformed) polygon.
            g_rasterizer.SetVectorClipBox(0, 0, Width, Height);
            g_rasterizer.reset();
            int b = 0;

            g_rasterizer.move_to_d(m_quad.GetXN(0) - b, m_quad.GetYN(0) - b);
            g_rasterizer.line_to_d(m_quad.GetXN(1) + b, m_quad.GetYN(1) - b);
            g_rasterizer.line_to_d(m_quad.GetXN(2) + b, m_quad.GetYN(2) + b);
            g_rasterizer.line_to_d(m_quad.GetXN(3) - b, m_quad.GetYN(3) + b);

            //typedef agg::span_allocator<color_type> span_alloc_type;
            span_allocator         sa            = new span_allocator();
            image_filter_bilinear  filter_kernel = new image_filter_bilinear();
            ImageFilterLookUpTable filter        = new ImageFilterLookUpTable(filter_kernel, true);

            ImageBufferAccessorClamp source = new ImageBufferAccessorClamp(m_SourceImage);

            stopwatch.Restart();

            switch (m_trans_type.SelectedIndex)
            {
            case 0:
            {
                /*
                 *              agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *
                 *              typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
                 *              interpolator_type interpolator(tr);
                 *
                 *              typedef image_filter_2x2_type<source_type,
                 *                                                                        interpolator_type> span_gen_type;
                 *              span_gen_type sg(source, interpolator, filter);
                 *              agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 */
                break;
            }

            case 1:
            {
                /*
                 *              agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *
                 *              typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
                 *              typedef image_resample_affine_type<source_type> span_gen_type;
                 *
                 *              interpolator_type interpolator(tr);
                 *              span_gen_type sg(source, interpolator, filter);
                 *              sg.blur(m_blur.Value);
                 *              agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 */
                break;
            }

            case 2:
            {
                /*
                 *              agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              if(tr.is_valid())
                 *              {
                 *                      typedef agg::span_interpolator_linear_subdiv<agg::trans_perspective> interpolator_type;
                 *                      interpolator_type interpolator(tr);
                 *
                 *                      typedef image_filter_2x2_type<source_type,
                 *                                                                                interpolator_type> span_gen_type;
                 *                      span_gen_type sg(source, interpolator, filter);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }

            case 3:
            {
                /*
                 *              agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              if(tr.is_valid())
                 *              {
                 *                      typedef agg::span_interpolator_trans<agg::trans_perspective> interpolator_type;
                 *                      interpolator_type interpolator(tr);
                 *
                 *                      typedef image_filter_2x2_type<source_type,
                 *                                                                                interpolator_type> span_gen_type;
                 *                      span_gen_type sg(source, interpolator, filter);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }

            case 4:
            {
                //typedef agg::span_interpolator_persp_lerp<> interpolator_type;
                //typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type;

                span_interpolator_persp_lerp interpolator   = new span_interpolator_persp_lerp(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                span_subdiv_adaptor          subdiv_adaptor = new span_subdiv_adaptor(interpolator);

                span_image_resample sg = null;
                if (interpolator.is_valid())
                {
                    switch (source.SourceImage.BitDepth)
                    {
                    case 24:
                        sg = new span_image_resample_rgb(source, subdiv_adaptor, filter);
                        break;

                    case 32:
                        sg = new span_image_resample_rgba(source, subdiv_adaptor, filter);
                        break;
                    }

                    sg.blur(m_blur.Value);
                    scanlineRenderer.GenerateAndRender(g_rasterizer, g_scanline, clippingProxy, sa, sg);
                }
                break;
            }

            case 5:
            {
                /*
                 *              typedef agg::span_interpolator_persp_exact<> interpolator_type;
                 *              typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type;
                 *
                 *              interpolator_type interpolator(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              subdiv_adaptor_type subdiv_adaptor(interpolator);
                 *
                 *              if(interpolator.is_valid())
                 *              {
                 *                      typedef image_resample_type<source_type,
                 *                                                                              subdiv_adaptor_type> span_gen_type;
                 *                      span_gen_type sg(source, subdiv_adaptor, filter);
                 *                      sg.blur(m_blur.Value);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }
            }

            double tm = stopwatch.ElapsedMilliseconds;
            //pixf.apply_gamma_inv(m_gamma_lut);

            gsv_text t = new gsv_text();

            t.SetFontSize(10.0);

            Stroke pt = new Stroke(t);

            pt.width(1.5);

            string buf = string.Format("{0:F2} ms", tm);

            t.start_point(10.0, 70.0);
            t.text(buf);

            g_rasterizer.add_path(pt);
            scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new Color(0, 0, 0));

            //--------------------------
            //m_trans_type.Render(g_rasterizer, g_scanline, clippingProxy);
            //m_gamma.Render(g_rasterizer, g_scanline, clippingProxy);
            //m_blur.Render(g_rasterizer, g_scanline, clippingProxy);
            base.OnDraw(graphics2D);
        }