Hi everyone, I have been using libart for 2 months
(not so long, still a newbie) and I'm having some problems with the alpha
blended rendering. The following code should render a 160x160 image as in figure
1, but unfortunately what is being rendered is in figure 2. I'll also attach the
code to make it easy to know what I am trying to expect and, if you run the
code, what I'm getting. What's the deal here? It's my fault? It's
libart's?
Peace,
Rodolfo.
/* Code */
#include <vector>
#include <libart_lgpl\libart.h>
using namespace std;
struct FPoint
{
FPoint(double X, double Y) :
x(X), y(Y) {};
FPoint() : x(0), y(0)
{};
double x,y;
};
void AddSeg(ArtSVP *&_pSVP,
vector<FPoint> &vPoint, int iEsp)
{ int iPoints=0, iPointsMax=50; ArtVpath *pVPath = art_new(ArtVpath, iPointsMax); // Create ArtVpath from
vector<FPoint>
art_vpath_add_point(&pVPath,
&iPoints, &iPointsMax, ART_MOVETO, vPoint[0].x,
vPoint[0].y);
for(int i=1; i<vPoint.size(); i++) art_vpath_add_point(&pVPath, &iPoints, &iPointsMax,ART_LINETO, vPoint[i].x, vPoint[i].y); art_vpath_add_point(&pVPath, &iPoints, &iPointsMax,ART_END, 0, 0); ArtSVP *pSVP =
art_svp_vpath_stroke(pVPath,ART_PATH_STROKE_JOIN_ROUND,ART_PATH_STROKE_CAP_ROUND,iEsp,5,2);
art_free(pVPath); if(_pSVP !=
NULL)
{ ArtSVP *pSVPaux = art_svp_union(pSVP,_pSVP); // Maybe the bug is in art_svp_union art_free(_pSVP); art_free(pSVP); _pSVP = pSVPaux; } else _pSVP = pSVP; } int void main()
{
vector<vector<FPoint>
> vvParte;
vvParte.push_back(vector<FPoint>()); vvParte[0].push_back(FPoint(-8,135)); vvParte[0].push_back(FPoint(78,136));
vvParte.push_back(vector<FPoint>());
vvParte[1].push_back(FPoint(78,136));
vvParte[1].push_back(FPoint(78,81));
vvParte.push_back(vector<FPoint>());
vvParte[2].push_back(FPoint(78,136)); vvParte[2].push_back(FPoint(82,136)); vvParte[2].push_back(FPoint(159,135));
vvParte.push_back(vector<FPoint>());
vvParte[3].push_back(FPoint(78,196)); vvParte[3].push_back(FPoint(78,136)); ArtSVP *pSVP =
NULL;
for(int p=0;
p<vvParte.size(); ++p)
AddSeg(pSVP,vvParte[p],11); unsigned char
pBuffer[160][160];
art_rgb_svp_alpha(pSVP,0,0,160,160,RGB(255,0,255),pBuffer, 160, NULL); // Maybe
the bug is here
// PS: when we change
art_rgb_svp_alpha to art_rgb_svp_aa the output looks right
// Render pBuffer on
screen
RenderBuffer(pBuffer); // Operational system dependent
function, make your own...
return 0;
}
|
Attachment:
figure_2.jpg
Description: JPEG image
Attachment:
figure_1.jpg
Description: JPEG image