image_resample_application(PixelFormats format, ERenderOrigin RenderOrigin) : base(format, RenderOrigin) { m_gamma_lut = new GammaLut(2.0); m_quad = new AGG.UI.polygon_ctrl <T>(4, 5.0); m_trans_type = new AGG.UI.rbox_ctrl <T>(400, 5.0, 430 + 170.0, 100.0); m_gamma = new AGG.UI.SliderWidget <T>(5.0, 5.0 + 15 * 0, 400 - 5, 10.0 + 15 * 0); m_blur = new AGG.UI.SliderWidget <T>(5.0, 5.0 + 15 * 1, 400 - 5, 10.0 + 15 * 1); m_old_gamma = M.New <T>(2); g_rasterizer = new RasterizerScanlineAA <T>(); g_scanline = new ScanlineUnpacked8(); m_trans_type.text_size(7); m_trans_type.add_item("Affine No Resample"); m_trans_type.add_item("Affine Resample"); m_trans_type.add_item("Perspective No Resample LERP"); m_trans_type.add_item("Perspective No Resample Exact"); m_trans_type.add_item("Perspective Resample LERP"); m_trans_type.add_item("Perspective Resample Exact"); m_trans_type.cur_item(4); AddChild(m_trans_type); m_gamma.range(0.5, 3.0); m_gamma.value(2.0); m_gamma.label("Gamma={0:F3}"); AddChild(m_gamma); m_blur.range(0.5, 5.0); m_blur.value(1.0); m_blur.label("Blur={0:F3}"); AddChild(m_blur); }
public styles_gouraud(mesh_ctrl mesh, GammaLut gamma) { uint i; for (i = 0; i < mesh.num_triangles(); i++) { mesh_triangle t = mesh.triangle(i); mesh_point p1 = mesh.vertex(t.p1); mesh_point p2 = mesh.vertex(t.p2); mesh_point p3 = mesh.vertex(t.p3); RGBA_Bytes c1 = p1.color; RGBA_Bytes c2 = p2.color; RGBA_Bytes c3 = p3.color; c1.ApplyGammaDir(gamma); c2.ApplyGammaDir(gamma); c3.ApplyGammaDir(gamma); SpanGouraudRgba <T> gouraud = new SpanGouraudRgba <T>(c1, c2, c3, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y); gouraud.Prepare(); m_triangles.Add(gouraud); } }
//-------------------------------------------------------------------- public RGBA_Bytes ApplyGammaDir(GammaLut gamma) { //R_Byte = gamma.Dir((byte)R_Byte); //G_Byte = gamma.Dir((byte)G_Byte); //B_Byte = gamma.Dir((byte)B_Byte); return(new RGBA_Bytes( gamma.Dir((byte)R_Byte), gamma.Dir((byte)G_Byte), gamma.Dir((byte)B_Byte), A_Byte)); }
//-------------------------------------------------------------------- public void ApplyGammaDir(GammaLut gamma) { R_Byte = gamma.Dir((byte)R_Byte); G_Byte = gamma.Dir((byte)G_Byte); B_Byte = gamma.Dir((byte)B_Byte); }
public override void OnDraw() { GammaLut gamma = new GammaLut(m_gamma.value().ToDouble()); IBlender NormalBlender = new BlenderBGRA(); IBlender GammaBlender = new BlenderGammaBGRA(gamma); FormatRGBA pixf = new FormatRGBA(rbuf_window(), NormalBlender); FormatClippingProxy clippingProxy = new FormatClippingProxy(pixf); clippingProxy.Clear(m_white_on_black.status() ? new RGBA_Doubles(0, 0, 0) : new RGBA_Doubles(1, 1, 1)); RasterizerScanlineAA <T> ras = new RasterizerScanlineAA <T>(); ScanlinePacked8 sl = new ScanlinePacked8(); Ellipse <T> e = new Ellipse <T>(); // TODO: If you drag the control circles below the bottom of the window we get an exception. This does not happen in AGG. // It needs to be debugged. Turning on clipping fixes it. But standard agg works without clipping. Could be a bigger problem than this. //ras.clip_box(0, 0, width(), height()); // Render two "control" circles e.Init(m_x[0], m_y[0], M.New <T>(3), M.New <T>(3), 16); ras.AddPath(e); Renderer <T> .RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(127, 127, 127)); e.Init(m_x[1], m_y[1], M.New <T>(3), M.New <T>(3), 16); ras.AddPath(e); Renderer <T> .RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(127, 127, 127)); T d = m_offset.value(); // Creating a rounded rectangle RoundedRect <T> r = new RoundedRect <T>(m_x[0].Add(d), m_y[0].Add(d), m_x[1].Add(d), m_y[1].Add(d), m_radius.value()); r.NormalizeRadius(); // Drawing as an outline if (!m_DrawAsOutlineCheckBox.status()) { ConvStroke <T> p = new ConvStroke <T>(r); p.Width = M.One <T>(); ras.AddPath(p); } else { ras.AddPath(r); } pixf.Blender = GammaBlender; Renderer <T> .RenderSolid(clippingProxy, ras, sl, m_white_on_black.status()?new RGBA_Bytes(1, 1, 1) : new RGBA_Bytes(0, 0, 0)); // this was in the original demo, but it does nothing because we changed the blender not the gamma function. //ras.gamma(new gamma_none()); // so let's change the blender instead pixf.Blender = NormalBlender; // Render the controls //m_radius.Render(ras, sl, clippingProxy); //m_gamma.Render(ras, sl, clippingProxy); //m_offset.Render(ras, sl, clippingProxy); //m_white_on_black.Render(ras, sl, clippingProxy); //m_DrawAsOutlineCheckBox.Render(ras, sl, clippingProxy); base.OnDraw(); }