public override void OnDraw() { #if SourceDepth24 FormatRGB pixf = new FormatRGB(rbuf_window(), new BlenderBGR()); #else pixfmt_alpha_blend_rgba32 pixf = new pixfmt_alpha_blend_rgba32(rbuf_window(), new blender_bgra32()); pixfmt_alpha_blend_rgba32 pixfImage = new pixfmt_alpha_blend_rgba32(rbuf_img(0), new blender_bgra32()); #endif FormatClippingProxy clippingProxy = new FormatClippingProxy(pixf); clippingProxy.Clear(new RGBA_Doubles(1.0, 1.0, 1.0)); clippingProxy.CopyFrom(rbuf_img(0), new RectInt(0, 0, (int)Width.ToInt(), (int)Height.ToInt()), 110, 35); string buf = string.Format("NSteps={0:F0}", m_num_steps); GsvText <T> t = new GsvText <T>(); t.StartPoint(10.0, 295.0); t.SetFontSize(10.0); t.Text = buf; ConvStroke <T> pt = new ConvStroke <T>(t); pt.Width = M.New <T>(1.5); m_Rasterizer.AddPath(pt); Renderer <T> .RenderSolid(clippingProxy, m_Rasterizer, m_ScanlinePacked, new RGBA_Bytes(0, 0, 0)); if (m_time1 != m_time2 && m_num_pix > 0.0) { buf = string.Format("{0:F2} Kpix/sec", m_num_pix / (m_time2 - m_time1)); t.StartPoint(10.0, 310.0); t.Text = buf; m_Rasterizer.AddPath(pt); Renderer <T> .RenderSolid(clippingProxy, m_Rasterizer, m_ScanlinePacked, new RGBA_Bytes(0, 0, 0)); } if (m_filters.cur_item() >= 14) { m_radius.Visible = true; } else { m_radius.Visible = true; } base.OnDraw(); }
void transform_image(double angle) { double width = rbuf_img(0).Width; double height = rbuf_img(0).Height; #if SourceDepth24 FormatRGB pixf = new FormatRGB(rbuf_img(0), new BlenderBGR()); FormatRGB pixf_pre = new FormatRGB(rbuf_img(0), new BlenderPreMultBGR()); #else pixfmt_alpha_blend_rgba32 pixf = new pixfmt_alpha_blend_rgba32(rbuf_img(0), new blender_bgra32()); pixfmt_alpha_blend_rgba32 pixf_pre = new pixfmt_alpha_blend_rgba32(rbuf_img(0), new blender_bgra_pre()); #endif FormatClippingProxy rb = new FormatClippingProxy(pixf); FormatClippingProxy rb_pre = new FormatClippingProxy(pixf_pre); rb.Clear(new RGBA_Doubles(1.0, 1.0, 1.0)); IAffineTransformMatrix <T> src_mtx = MatrixFactory <T> .NewIdentity(VectorDimension.Two); src_mtx.Translate(MatrixFactory <T> .CreateVector2D(-width / 2.0, -height / 2.0)); src_mtx.RotateAlong(MatrixFactory <T> .CreateVector2D(0, 0), angle * Math.PI / 180.0); src_mtx.Translate(MatrixFactory <T> .CreateVector2D(width / 2.0, height / 2.0)); IAffineTransformMatrix <T> img_mtx = MatrixFactory <T> .CreateAffine(src_mtx); img_mtx = img_mtx.Inverse; double r = width; if (height < r) { r = height; } r *= 0.5; r -= 4.0; VertexSource.Ellipse <T> ell = new AGG.VertexSource.Ellipse <T>(width / 2.0, height / 2.0, r, r, 200); ConvTransform <T> tr = new ConvTransform <T>(ell, src_mtx); m_num_pix += r * r * Math.PI; SpanInterpolatorLinear <T> interpolator = new SpanInterpolatorLinear <T>(img_mtx); ImageFilterLookUpTable <T> filter = new ImageFilterLookUpTable <T>(); bool norm = m_normalize.status(); #if SourceDepth24 FormatRGB pixf_img = new FormatRGB(rbuf_img(1), new BlenderBGR()); #else pixfmt_alpha_blend_rgba32 pixf_img = new pixfmt_alpha_blend_rgba32(rbuf_img(1), new blender_bgra32()); #endif RasterBufferAccessorClip source = new RasterBufferAccessorClip(pixf_img, RGBA_Doubles.RgbaPre(0, 0, 0, 0)); switch (m_filters.cur_item()) { case 0: { #if SourceDepth24 SpanImageFilterRgbNN <T> sg = new SpanImageFilterRgbNN <T>(source, interpolator); #else span_image_filter_rgba_nn sg = new span_image_filter_rgba_nn(source, interpolator); #endif m_Rasterizer.AddPath(tr); Renderer <T> .GenerateAndRender(m_Rasterizer, m_ScanlineUnpacked, rb_pre, m_SpanAllocator, sg); } break; case 1: { #if SourceDepth24 //span_image_filter_rgb_bilinear_clip sg = new span_image_filter_rgb_bilinear_clip(pixf_img, rgba.rgba_pre(0, 0.4, 0, 0.5), interpolator); SpanImageFilterRgbBilinear <T> sg = new SpanImageFilterRgbBilinear <T>(source, interpolator); #else //span_image_filter_rgba_bilinear_clip sg = new span_image_filter_rgba_bilinear_clip(pixf_img, rgba.rgba_pre(0, 0, 0, 0), interpolator); span_image_filter_rgba_bilinear sg = new span_image_filter_rgba_bilinear(source, interpolator); #endif m_Rasterizer.AddPath(tr); Renderer <T> .GenerateAndRender(m_Rasterizer, m_ScanlineUnpacked, rb_pre, m_SpanAllocator, sg); } break; case 5: case 6: case 7: { switch (m_filters.cur_item()) { case 5: filter.Calculate(new ImageFilterHanning <T>(), norm); break; case 6: filter.Calculate(new ImageFilterHamming <T>(), norm); break; case 7: filter.Calculate(new ImageFilterHermite <T>(), norm); break; } SpanImageFilterRgb2x2 <T> sg = new SpanImageFilterRgb2x2 <T>(source, interpolator, filter); m_Rasterizer.AddPath(tr); Renderer <T> .GenerateAndRender(m_Rasterizer, m_ScanlineUnpacked, rb_pre, m_SpanAllocator, sg); } 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 (m_filters.cur_item()) { case 2: filter.Calculate(new ImageFilterBicubic <T>(), norm); break; case 3: filter.Calculate(new ImageFilterSpline16 <T>(), norm); break; case 4: filter.Calculate(new ImageFilterSpline36 <T>(), norm); break; case 8: filter.Calculate(new ImageFilterKaiser <T>(), norm); break; case 9: filter.Calculate(new ImageFilterQuadric <T>(), norm); break; case 10: filter.Calculate(new ImageFilterCatrom <T>(), norm); break; case 11: filter.Calculate(new ImageFilterGaussian <T>(), norm); break; case 12: filter.Calculate(new ImageFilterBessel <T>(), norm); break; case 13: filter.Calculate(new ImageFilterMitchell <T>(), norm); break; case 14: filter.Calculate(new ImageFilterSinc <T>(m_radius.value()), norm); break; case 15: filter.Calculate(new ImageFilterLanczos <T>(m_radius.value()), norm); break; case 16: filter.Calculate(new ImageFilterBlackman <T>(m_radius.value()), norm); break; } #if SourceDepth24 SpanImageFilterRgb <T> sg = new SpanImageFilterRgb <T>(source, interpolator, filter); #else span_image_filter_rgb sg = new span_image_filter_rgba(source, interpolator, filter); #endif m_Rasterizer.AddPath(tr); Renderer <T> .GenerateAndRender(m_Rasterizer, m_ScanlineUnpacked, rb_pre, m_SpanAllocator, sg); } break; } }