From: Stephan A. <sup...@gm...> - 2019-06-02 08:32:52
|
Hi, just to give you a quick reply, the templates need to be declared in such a way that they fit together. You are defining your "pixel format" type to RGB24, which has no alpha channel, and then you are trying to use that with classes that expect an alpha channel (typedef agg::span_pattern_rgba). You need to make sure that everything matches. The "typedefs" at the beginning of your code make sure that they are consistent, because they are based on each other. You can change something in the beginning and the later declarations automatically adjust. But then in your code, you have additional typedefs and template declarations which are not based on the earlier typedefs and are therefore not forced to match. Often, you also need to adjust the #includes, especially when switching between classes with alpha and without alpha, since they are declared in different .h files. Hope this helps, -Stephan Am 02.06.2019 um 09:06 schrieb KarthikRIyer: > #define AGG_RGB24 > typedef agg::pixfmt_rgb24 pixfmt; > typedef agg::renderer_base<pixfmt> renderer_base; > typedef agg::renderer_base<pixfmt_pre> renderer_base_pre; > typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_aa; > typedef agg::renderer_scanline_bin_solid<renderer_base> renderer_bin; > typedef agg::rasterizer_scanline_aa<> rasterizer_scanline; > typedef agg::scanline_p8 scanline; > typedef agg::rgba Color; > agg::rasterizer_scanline_aa<> m_ras; > agg::scanline_p8 m_sl_p8; > agg::line_cap_e roundCap = agg::round_cap; > renderer_base rb; > renderer_aa ren_aa; > int pngBufferSize = 0; > > agg::int8u* m_pattern; > agg::rendering_buffer m_pattern_rbuf; > agg::path_storage m_ps; > renderer_base_pre rb_pre; > rb = renderer_base(pixf); > ren_aa = renderer_aa(rb); > rb_pre = renderer_base_pre(pixf_pre); > > > void generate_pattern(){ > m_ps.move_to(0,0); > m_ps.line_to(10,10); > int size = 10; > agg::conv_stroke<agg::path_storage> stroke(m_ps); > stroke.width(5); > m_pattern = new agg::int8u[size * size * 3]; > m_pattern_rbuf.attach(m_pattern, size, size, size*3); > pixfmt pixf1(m_pattern_rbuf); > agg::renderer_base<pixfmt> rb1(pixf); > agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > > rs1(rb1); > rb.clear(agg::rgba_pre(1, 1, 1, 0)); > m_ras.add_path(stroke); > rs1.color(agg::rgba8(0,0,0)); > agg::render_scanlines(m_ras, m_sl_p8, rs1); > } > > void draw_solid_rect_transformed(const float *x, const float *y, float > r, float g, float b, float a){ > generate_pattern(); > agg::path_storage rect_path; > rect_path.move_to(*x, *y); > for (int i = 1; i < 4; i++) { > rect_path.line_to(*(x+i),*(y+i)); > } > rect_path.close_polygon(); > agg::trans_affine matrix; > matrix *= agg::trans_affine_translation(sub_width*0.1f, > sub_height*0.1f); > agg::conv_transform<agg::path_storage, agg::trans_affine> > trans(rect_path, matrix); > // m_ras.add_path(trans); > // Color c(r, g, b, a); > // ren_aa.color(c); > // agg::render_scanlines(m_ras, m_sl_p8, ren_aa); > > typedef agg::wrap_mode_reflect_auto_pow2 wrap_x_type; > typedef agg::wrap_mode_reflect_auto_pow2 wrap_y_type; > typedef agg::image_accessor_wrap<pixfmt, > wrap_x_type, > wrap_y_type> img_source_type; > typedef agg::span_pattern_rgba<img_source_type> span_gen_type; > agg::span_allocator<color_type> sa; > pixfmt img_pixf(m_pattern_rbuf); > img_source_type img_src(img_pixf); > span_gen_type sg(img_src, 0,0); > sg.alpha(span_gen_type::value_type(0.6 * 255.0)); > > m_ras.add_path(trans); > Color c(r, g, b, a); > // ren_aa.color(c); > // agg::render_scanlines(m_ras, m_sl_p8, ren_aa); > agg::render_scanlines_aa(m_ras, m_sl_p8, rb_pre, sa, sg); > > } > > I need to add some hatching to a rectangle am trying to follow the pattern > fill example in the demo. > Above is the code I'm trying out. > > Can someone please explain how the pattern fill works? > > I'm getting this error while compiling: > //home/karthik/swiftplot/framework/AGG/include/agg_span_pattern_rgba.h:77:41: > error: no member named 'A' in 'agg::order_rgb' > span->a = p[order_type::A]; > ^ > /home/karthik/swiftplot/framework/AGG/include/agg_renderer_scanline.h:168:22: > note > : in instantiation of member function > 'agg::span_pattern_rgba<agg::image_accessor_wrap<agg::pixfmt_alpha_blend_rgb<agg::blender_rgb<agg::rgba8, > agg::order_rgb>, agg::row_accessor<unsigned char> >, > agg::wrap_mode_reflect_auto_pow2, agg::wrap_mode_reflect_auto_pow2> >> ::generate' requested here > span_gen.generate(colors, x, y, len); > ^ > > /home/karthik/swiftplot/framework/AGG/include/agg_renderer_scanline.h:189:17: > note: in instantiation of function template specialization > 'agg::render_scanline_aa<agg::scanline_p8, > agg::renderer_base<agg::pixfmt_alpha_blend_rgb<agg::blender_rgb_pre<agg::rgba8, > agg::order_rgb>, agg::row_accessor<unsigned char> > >, > agg::span_allocator<agg::rgba8>, > agg::span_pattern_rgba<agg::image_accessor_wrap<agg::pixfmt_alpha_blend_rgb<agg::blender_rgb<agg::rgba8, > agg::order_rgb>, agg::row_accessor<unsigned char> >, > agg::wrap_mode_reflect_auto_pow2, agg::wrap_mode_reflect_auto_pow2> > >' > requested here > > render_scanline_aa(sl, ren, alloc, span_gen); > ^ > /home/karthik/swiftplot/framework/AGGRenderer/CPPAGGRenderer/CPPAGGRenderer.cpp:167:12: > note: in instantiation of function template specialization > 'agg::render_scanlines_aa<agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_int> >> , agg::scanline_p8, > agg::renderer_base<agg::pixfmt_alpha_blend_rgb<agg::blender_rgb_pre<agg::rgba8, > agg::order_rgb>, agg::row_accessor<unsigned char> > >, > agg::span_allocator<agg::rgba8>, > agg::span_pattern_rgba<agg::image_accessor_wrap<agg::pixfmt_alpha_blend_rgb<agg::blender_rgb<agg::rgba8, > agg::order_rgb>, agg::row_accessor<unsigned char> >, > agg::wrap_mode_reflect_auto_pow2, agg::wrap_mode_reflect_auto_pow2> > >' > requested here > > agg::render_scanlines_aa(m_ras, m_sl_p8, rb_pre, sa, sg); > / > > > > > -- > Sent from: http://anti-grain-geometry.1086185.n5.nabble.com/ > > > _______________________________________________ > Vector-agg-general mailing list > Vec...@li... > https://lists.sourceforge.net/lists/listinfo/vector-agg-general > |