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