In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Provide the display code:
Agg::rendering_buffer & rbuf = rbuf_window ()
Agg::pixfmt_bgr24 pixf (rbuf)
Typedef agg::renderer_base renderer_base_type
Renderer_base_type renb (pixf)
Typedef agg::renderer_scanline_aa_solid renderder_scanline_type
Renderder_scanline_type rensl (renb)
Agg::rasterizer_scanline_aa ras
Agg::scanline_u8 sl
Ras.reset ()
Double x [4]
Double y [4]
Double h = 100.33
X [0] = 10; y [0] = 10
X [1] = 100; y [1] = 10
X [2] = 100; y [2] = y [0] + h
X [3] = 10; y [3] = y [0] + h
Agg::path_storage ps
Ps.move_to (x [0], y [0])
Ps.line_to (x [1], y [1])
Ps.line_to (x [2], y [2])
Ps.line_to (x [3], y [3])
Ps.close_polygon ()
Ras.add_path (ps)
Agg::render_scanlines_aa_solid (ras,sl,renb,agg::rgba8 (255,0,0))
Ps.remove_all ()
Ras.reset ()
Ps.move_to (x [0] + 10heroin y [0] + h)
Ps.line_to (x [1] + 10heroin y [1] + h)
Ps.line_to (x [2] + 10heroin y [2] + h)
Ps.line_to (x [3] + 10heroin y [3] + h)
Ps.close_polygon ()
Ras.add_path (ps)
Agg::render_scanlines_aa_solid (ras,sl,renb,agg::rgba8 (255,0,0))
It is very obvious that there is a shallow white edge on the boundary between the two rectangles.
The email questioned:
As you can see there is a brighter line between the two rectangles. I
Know where it is from-this is a result of alpha blending of two
Partially covered scanlines. And this is a problem form me.
Do you have any idea how to get rid of this line? I mean how to make
It in the same color as the rectangles. My application draws metafiles
And sometimes there are such shapes in them and I get ugly banded
Drawings... Do you have any ideas?
Here is the author's explanation:
It's a well known problem that can't be eliminated easily. It exists in
All SVG engies and appears as thin "web" upon the p_w_picpath, when you draw adjacent
Shapes: http://www.antigrain.com/svg/index.htmlSay, initially you have color. Then you draw a white pixel on it with
0.5 opacity (which is equivalent 0.5 of pixel coverage). You will have
(0.5) which is correct. Then you draw another pixel upon it, also with
Opacity=0.5. According to the color blending rules you will have
(0.75), not (1) This is what happens when you draw your
Rectrangles.
The problem can't be easily solved. In the SVG example I use conv_contour to
Dilate all polygons. But this solution isn't perfect and kinda unfair.
But you can't render a multicolor scene in such a way. It's possible only in
Macromedia Flash, but it requires not only another rasterization algorithm, but
Also changing the whole data model. Your data shall be represented not as a set
Of polygons, but as a set of edges with attributes-color on the left and
Color on the right.
> Say, initially you have color. Then you draw a white pixel on it with
> 0.5 opacity (which is equivalent 0.5 of pixel coverage). You will have
> (0.5, 0.5) which is correct. Then you draw another pixel upon it, also with
> opacity=0.5. According to the color blending rules you will have
> (0.75) (0.75), not (1) This is what happens when you draw your
> rectrangles.
This is the color from the original post:
> > ren_aa.color (agg::rgba (0.4,0.3,0.2,1.0))
The opacity of the color is 1.0, not 0.5. So what Maxim tried to say is I
Guess something like this: "Then you draw a white pixel on it with 0.5
Pixel coverage (which is equivalent to 0.5 opacity). "
Now, forgive me for my ignorance if this is trivial, I really haven't had
To think about this particular problem, but here's an idea: suppose you
Are doing a flash-like multicolor fill where you know that no polygon
Overlaps another (triangulation, tesselation, whatever). Can the blending
Rule in AGG be changed so that the alpha channel is not interpreted as a
Genuine alpha, but as a coverage percentage instead? So that for example
In this particular case 0.5, 0.5 would be 1.0? This wouldn't work if you
Also want alpha, but the presumption here is that you really don't need it.
> Now, forgive me for my ignorance if this is trivial, I really haven't had
> to think about this particular problem, but here's an idea: suppose you
> are doing a flash-like multicolor fill where you know that no polygon
> overlaps another (triangulation, tesselation, whatever). Can the blending
> rule in AGG be changed so that the alpha channel is not interpreted as a
> genuine alpha, but as a coverage percentage instead? So that for example
> in this particular case 0.5, 0.5 would be 1.0? This wouldn't work if you
Also want alpha, but the presumption here is that you really don't need it.
Actually, that's an idea, I'm not sure it's doable, but it's seems to be. One
Pixel can be overlapped by many polygons even if the polygons themselves do not
Overlap.
Http://antigrain.com/stuff/multipoly_cover.gif-the central pixel is covered
By 6 triangles. It means that there are 6 different cover values and 6 colors.
And the resulting color must be calculated as the weigted average, where weight
Is coverage. But we should keep a whole list of coverage values for each pixel!
Another solution is to use the alpha channel for coverage values. Suppose we
Have not RGBA, but RGBC color space. Initially all cover values are 0. At a
Time we always operate with 2 colors and two coverage values. We accumulate the
Coverage values (with clipping at 1.0) and calculate the resulting color as the
Weighted average of 2 colors/covers. It looks very familiar, and remainds me
The formulae for alpha blending in plain (non-premultiplied) color space.
> And the resulting color must be calculated as the weigted average, where weight
> is coverage. But we should keep a whole list of coverage values for each pixel!
Assume for example that you have calculated values
Nom = (w1*a1+w2*a2+w3*a3) / (w1+w2+w3) (the weighted mean so far)
Den = w1+w2+w3 (the sum of weights so far)
Then you can calculate new values
Nom = (nom*den + w4*a4) / (den+w4)
Den + = w4
Expanding those formulas you will get the correct results. That is, you do
Not need to keep a record of all the colors in order to calculate an
Update to the weighted mean, the mean so far plus the weight (kept in
Alpha) is sufficient.
Extracted from: http://sourceforge.net/p/vector-agg/mailman/vector-agg-general/?viewmonth=200504
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.