« Return to Thread: Blending and Drawing produce different image..

Re: Blending and Drawing produce different image..

by George-156 :: Rate this Message:

Reply to Author | View in Thread

Peter Yang wrote:
Here is situation..

1. Draw rectangle A with Solid Color RGBA(0,0,255,128)
2. Draw rectangle B with solid color RGBA(0,255,0,128) overlapped with A  
3. Draw rectangle C -RGBA(0,255,0,128) in different DIB buffer 
   and blend over rectangle A 

all pixel format was agg::pixfmt_bgra32

overllapped area between 1 and 2, 1 and 3 produce different color :(..

How can I fix this problem..??





------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
  
Hi all,

on the same subject, I am a bit confused on the pre_mult, plain and bgra32 formats and blenders. In essence I have wrapper canvas classes which provide functionality on agg::pixmap of pxfmt_bgra32. When I try to blend two of these canvases using blend_from the only time I get acceptable (no artifacts) results is when both base pixmaps are of pixfmt_bgra32_plain. I also read that this is the slowest blender due to the division in there.

So the question is simple, I have different canvas (with pixmap, buffer, render etc) which I wish to be able to blend with each other using blend_from(). What is the best way to achieve
bgra32 to bgra32 blending?

Here is some code to replicate the problem:

                    typedef agg::pixfmt_bgra32 pixfmt;      // if this is not set to pixfmt_bgra32_plain artifacts occur
                    typedef agg::renderer_base<pixfmt>                                                    baseren;
                    typedef agg::renderer_scanline_aa_solid<baseren>                                solidren;

                    pixel_map    pixmap1;
                    pixel_map    pixmap2;
                   
                    pixmap1.create(400, 400, org_e::org_color32, 0);
                    pixmap2.create(400, 400, org_e::org_color32, 0);
                   

                    rendering_buffer mBuffer1( pixmap1.buf(), pixmap1.width(), pixmap1.height(), pixmap1.stride() );                   
                    rendering_buffer mBuffer2( pixmap2.buf(), pixmap2.width(), pixmap2.height(), pixmap2.stride() );                   


                    pixfmt        pixfmt1(mBuffer1);
                    pixfmt        pixfmt2(mBuffer2);

                    scanline_u8                    sca1;
                    scanline_u8                    sca2;

                    rasterizer_scanline_aa<>    ras1;
                    rasterizer_scanline_aa<>    ras2;

                    baseren        baseRenderer1(pixfmt1);
                    baseren        baseRenderer2(pixfmt2);

                    solidren                ren1(baseRenderer1);
                    solidren                ren2(baseRenderer2);

                    baseRenderer1.clear(rgba8(168,128,255));
                    baseRenderer2.clear(rgba8(0,0,0,0));


                    path_storage                path;
                    path.move_to(100.5,100.5);
                    path.line_to(301.6,255.4);
                    path.line_to(201.6,200.4);

                    agg::conv_stroke<path_storage>        stroke(path);
                    stroke.width(5.0);
                    stroke.line_join(line_join_e::round_join);

                    ras2.reset();
                    ras2.add_path(stroke);

                    ren2.color(rgba8(255,255,128));      // yellow

                    render_scanlines(ras2, sca2, ren2);
                    render_scanlines(ras1, sca1, ren1);   

                    baseRenderer1.blend_from(pixfmt2);

                    pixmap1.save_as_bmp("c:\\temp.bmp");

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

 « Return to Thread: Blending and Drawing produce different image..