image rendering

View: New views
3 Messages — Rating Filter:   Alert me  

image rendering

by klaas.holwerda-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am rendering images, and it work well. But when i zoom in a lot, it
becomes very slow.
The reason is that the rectangle added to the rasterizer is almost
completely outside the rendering buffer.
So the whole buffer size/reactangle is just a small part of the rendered
rectangle.
Eventually in agg::render_scanlines almost all of the scanlines pixels
are outside of the buffer.
They are clipped, but still take time.

So is there a way to add a path that is the intersection of the
rectangle with the buffer area.
In that case the result of that will be completely in the rendering
buffer, and rendering that is fast  again.
Of course i could do a high level Intersect/AND operation using gpc or
kbool.
But i wonder is there is a simpler way to achieve the intersection of
two rectangles.
The image can be rotated, but it surrounding polygon is still a
rectangle although rotated.

Or maybe i just don;t have the right approach??

Thanks for some advice on this,

Klaas

 My image rendring code is like this:

    int imagew=image.GetWidth();
    int imageh=image.GetHeight();

    pixfmt pixf(*m_rendering_buffer);
    ren_base renb(pixf);

    renderer_bin ren(renb);
    renb.clip_box( m_clipboxdev.x, m_clipboxdev.y, m_clipboxdev.x +
m_clipboxdev.width, m_clipboxdev.y + m_clipboxdev.height);

    agg::trans_affine mtxi;
    mtxi *= agg::trans_affine_scaling( width/imagew, height/imageh );
    mtxi *= agg::trans_affine_translation( x-width/2, y-height/2 );

    const a2dAffineMatrix &r2d = GetUserToDeviceTransform();
    agg::trans_affine mtx(
        r2d.GetValue(0,0), r2d.GetValue(0,1),
        r2d.GetValue(1,0), r2d.GetValue(1,1),
        r2d.GetValue(2,0), r2d.GetValue(2,1)
        );
    mtxi *= mtx;
    mtxi.invert();

    typedef agg::span_allocator<agg::rgba8> span_alloc_type;

    span_alloc_type sa;
    typedef agg::image_accessor_clip<pixfmt> img_source_type;
    typedef agg::span_interpolator_linear<> interpolator_type;
    interpolator_type interpolator(mtxi);

    typedef agg::span_image_filter_rgb_nn<img_source_type,
interpolator_type> span_gen_type;
    typedef agg::span_converter<span_gen_type,
span_conv_const_alpha_rgba8> span_conv;
    typedef agg::renderer_scanline_aa<ren_base, span_alloc_type,
span_conv> renderer_type_alpha;
    typedef agg::renderer_scanline_bin<ren_base, span_alloc_type,
span_gen_type> renderer_type_normal;

    agg::rendering_buffer image_buffer;
    image_buffer.attach( image.GetData(), imagew, imageh, imagew*3 );
    pixfmt img_pixf(image_buffer);
    img_source_type img_src(img_pixf, agg::rgba(1,1,1,0));

    span_gen_type sg(img_src, interpolator);
    agg::rounded_rect er(x-width/2, y-height/2 ,x+width/2, y+height/2, 0);
    er.normalize_radius();
    agg::conv_transform<agg::rounded_rect> tr(er, mtx);
    m_ras.add_path(tr);

        span_conv_const_alpha_rgba8 color_alpha( m_OpacityFactor );
        span_conv sc(sg, color_alpha);
        renderer_type_alpha ri(renb, sa, sc);
        agg::render_scanlines(m_ras, m_sl, ri);


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: image rendering

by Lorne Laliberte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi klaas,

The rasterizer also has a clip box which you can set.

So, set the m_ras clip box to an appropriate rectangle before
rasterizing and rendering the path.

Hope that helps!

Lorne Laliberte
Senior Software Developer, Indigo Rose Software



On Mon, Jul 20, 2009 at 4:41 PM, klaas.holwerda<ngi@...> wrote:

> Hi,
>
> I am rendering images, and it work well. But when i zoom in a lot, it
> becomes very slow.
> The reason is that the rectangle added to the rasterizer is almost
> completely outside the rendering buffer.
> So the whole buffer size/reactangle is just a small part of the rendered
> rectangle.
> Eventually in agg::render_scanlines almost all of the scanlines pixels
> are outside of the buffer.
> They are clipped, but still take time.
>
> So is there a way to add a path that is the intersection of the
> rectangle with the buffer area.
> In that case the result of that will be completely in the rendering
> buffer, and rendering that is fast  again.
> Of course i could do a high level Intersect/AND operation using gpc or
> kbool.
> But i wonder is there is a simpler way to achieve the intersection of
> two rectangles.
> The image can be rotated, but it surrounding polygon is still a
> rectangle although rotated.
>
> Or maybe i just don;t have the right approach??
>
> Thanks for some advice on this,
>
> Klaas
>
>  My image rendring code is like this:
>
>    int imagew=image.GetWidth();
>    int imageh=image.GetHeight();
>
>    pixfmt pixf(*m_rendering_buffer);
>    ren_base renb(pixf);
>
>    renderer_bin ren(renb);
>    renb.clip_box( m_clipboxdev.x, m_clipboxdev.y, m_clipboxdev.x +
> m_clipboxdev.width, m_clipboxdev.y + m_clipboxdev.height);
>
>    agg::trans_affine mtxi;
>    mtxi *= agg::trans_affine_scaling( width/imagew, height/imageh );
>    mtxi *= agg::trans_affine_translation( x-width/2, y-height/2 );
>
>    const a2dAffineMatrix &r2d = GetUserToDeviceTransform();
>    agg::trans_affine mtx(
>        r2d.GetValue(0,0), r2d.GetValue(0,1),
>        r2d.GetValue(1,0), r2d.GetValue(1,1),
>        r2d.GetValue(2,0), r2d.GetValue(2,1)
>        );
>    mtxi *= mtx;
>    mtxi.invert();
>
>    typedef agg::span_allocator<agg::rgba8> span_alloc_type;
>
>    span_alloc_type sa;
>    typedef agg::image_accessor_clip<pixfmt> img_source_type;
>    typedef agg::span_interpolator_linear<> interpolator_type;
>    interpolator_type interpolator(mtxi);
>
>    typedef agg::span_image_filter_rgb_nn<img_source_type,
> interpolator_type> span_gen_type;
>    typedef agg::span_converter<span_gen_type,
> span_conv_const_alpha_rgba8> span_conv;
>    typedef agg::renderer_scanline_aa<ren_base, span_alloc_type,
> span_conv> renderer_type_alpha;
>    typedef agg::renderer_scanline_bin<ren_base, span_alloc_type,
> span_gen_type> renderer_type_normal;
>
>    agg::rendering_buffer image_buffer;
>    image_buffer.attach( image.GetData(), imagew, imageh, imagew*3 );
>    pixfmt img_pixf(image_buffer);
>    img_source_type img_src(img_pixf, agg::rgba(1,1,1,0));
>
>    span_gen_type sg(img_src, interpolator);
>    agg::rounded_rect er(x-width/2, y-height/2 ,x+width/2, y+height/2, 0);
>    er.normalize_radius();
>    agg::conv_transform<agg::rounded_rect> tr(er, mtx);
>    m_ras.add_path(tr);
>
>        span_conv_const_alpha_rgba8 color_alpha( m_OpacityFactor );
>        span_conv sc(sg, color_alpha);
>        renderer_type_alpha ri(renb, sa, sc);
>        agg::render_scanlines(m_ras, m_sl, ri);
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: image rendering

by klaas.holwerda-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lorne Laliberte wrote:
> Hi klaas,
>
> The rasterizer also has a clip box which you can set.
>
> So, set the m_ras clip box to an appropriate rectangle before
> rasterizing and rendering the path.
>
> Hope that helps!
>  
Perfect! Thanks a lot.

Klaas



------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general