summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscuri <scuri>2010-02-27 21:49:25 +0000
committerscuri <scuri>2010-02-27 21:49:25 +0000
commite78601f7c788d1206aa60a57a169bb6d02b748bd (patch)
tree83adad627e1d74463c8c2f162b3edc50c797f269
parent4ed27b8eecc984e0a139eef301da535936733b1d (diff)
Fixed: alpha transparency in CanvasArc and Bezier polygon in the IMAGERGB driver.
-rw-r--r--html/en/history.html5
-rw-r--r--src/sim/sim_linepolyfill.c44
-rw-r--r--test/simple/simple.c23
3 files changed, 45 insertions, 27 deletions
diff --git a/html/en/history.html b/html/en/history.html
index 7692bb2..1d65938 100644
--- a/html/en/history.html
+++ b/html/en/history.html
@@ -27,8 +27,11 @@
<strong>CanvasBackOpacity</strong> and <strong>CanvasBackground</strong> are
supported.</li>
<li><span style="color: #FF0000">Fixed:</span> SVG driver support for
- BackOpacity=OPAQUE in Hatch. Transform and Clipping conflict. InteriorStyle
+ <strong>BackOpacity</strong>=OPAQUE in Hatch. Transform and Clipping conflict.
+ <strong>InteriorStyle</strong>
initialization. Pattern orientation was upside down.</li>
+ <li><span style="color: #FF0000">Fixed:</span> alpha transparency in <strong>
+ CanvasArc</strong> and Bezier polygon in the IMAGERGB driver.</li>
</ul>
<h3><a href="http://sourceforge.net/projects/canvasdraw/files/5.3/">Version 5.3</a> (26/Jan/2010)</h3>
<ul>
diff --git a/src/sim/sim_linepolyfill.c b/src/sim/sim_linepolyfill.c
index 44dda5b..e339fe5 100644
--- a/src/sim/sim_linepolyfill.c
+++ b/src/sim/sim_linepolyfill.c
@@ -719,7 +719,7 @@ void simLineThin(cdCanvas* canvas, int x1, int y1, int x2, int y2)
unsigned short ErrorAccTemp, Weighting;
int DeltaX, DeltaY, XDir;
long aa_fgcolor;
- unsigned char alpha = cdAlpha(canvas->foreground), aa_alpha;
+ unsigned char alpha = cdAlpha(canvas->foreground), aa_alpha1, aa_alpha2;
int no_antialias = !(canvas->simulation->antialias);
unsigned short int ls;
long fgcolor = canvas->foreground;
@@ -841,11 +841,12 @@ void simLineThin(cdCanvas* canvas, int x1, int y1, int x2, int y2)
weighting for the paired pixel.
Combine the Weighting with the existing alpha,
When Weighting is zero alpha must be fully preserved. */
- aa_alpha = (unsigned char)(((255-Weighting) * alpha) / 255);
+ aa_alpha1 = (unsigned char)(((255-Weighting) * alpha) / 255);
+ aa_alpha2 = (unsigned char)((Weighting * alpha) / 255);
- aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha1);
_cdLineDrawPixel(canvas, x1, y1, ls, aa_fgcolor);
- aa_fgcolor = cdEncodeAlpha(fgcolor, 255-aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha2);
_cdLineDrawPixel(canvas, x1 + XDir, y1, ls, aa_fgcolor);
ls = simRotateLineStyle(ls);
}
@@ -892,11 +893,12 @@ void simLineThin(cdCanvas* canvas, int x1, int y1, int x2, int y2)
weighting for the paired pixel.
Combine the Weighting with the existing alpha,
When Weighting is zero alpha must be fully preserved. */
- aa_alpha = (unsigned char)(((255-Weighting) * alpha) / 255);
+ aa_alpha1 = (unsigned char)(((255-Weighting) * alpha) / 255);
+ aa_alpha2 = (unsigned char)((Weighting * alpha) / 255);
- aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha1);
_cdLineDrawPixel(canvas, x1, y1, ls, aa_fgcolor);
- aa_fgcolor = cdEncodeAlpha(fgcolor, 255-aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha2);
_cdLineDrawPixel(canvas, x1, y1+1, ls, aa_fgcolor);
ls = simRotateLineStyle(ls);
}
@@ -915,7 +917,7 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
{
double DeltaX, DeltaY, a, b;
long aa_fgcolor;
- unsigned char alpha = cdAlpha(canvas->foreground), aa_alpha;
+ unsigned char alpha = cdAlpha(canvas->foreground), aa_alpha1, aa_alpha2;
int no_antialias = !(canvas->simulation->antialias);
int yi, xi, update_a = 1, update_b = 1;
unsigned short int ls;
@@ -976,11 +978,12 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
/* Combine the Weighting with the existing alpha,
When Weighting is zero alpha must be fully preserved. */
- aa_alpha = (unsigned char)((1.0-(x - xi)) * alpha);
+ aa_alpha1 = (unsigned char)((1.0-(x - xi)) * alpha);
+ aa_alpha2 = (unsigned char)((x - xi) * alpha);
if (no_antialias)
{
- if (aa_alpha > 128)
+ if (aa_alpha1 > 128)
_cdLineDrawPixel(canvas, xi, yi, ls, fgcolor)
else
_cdLineDrawPixel(canvas, xi+1, yi, ls, fgcolor)
@@ -1000,7 +1003,7 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
if ((xi != *last_xi_a || yi != *last_yi_a) &&
(xi != *last_xi_b || yi != *last_yi_b))
{
- aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha1);
_cdLineDrawPixel(canvas, xi, yi, ls, aa_fgcolor);
if (yi == yi_last) /* one pixel only */
@@ -1010,7 +1013,7 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
if ((xi+1 != *last_xi_a || yi != *last_yi_a) &&
(xi+1 != *last_xi_b || yi != *last_yi_b))
{
- aa_fgcolor = cdEncodeAlpha(fgcolor, 255-aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha2);
_cdLineDrawPixel(canvas, xi+1, yi, ls, aa_fgcolor);
if (yi == yi_last) /* one pixel only */
@@ -1019,9 +1022,9 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
}
else
{
- aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha1);
_cdLineDrawPixel(canvas, xi, yi, ls, aa_fgcolor);
- aa_fgcolor = cdEncodeAlpha(fgcolor, 255-aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha2);
_cdLineDrawPixel(canvas, xi+1, yi, ls, aa_fgcolor);
}
}
@@ -1062,11 +1065,12 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
/* Combine the Weighting with the existing alpha,
When Weighting is zero alpha must be fully preserved. */
- aa_alpha = (unsigned char)((1.0-(y - yi)) * alpha);
+ aa_alpha1 = (unsigned char)((1.0-(y - yi)) * alpha);
+ aa_alpha2 = (unsigned char)((y - yi) * alpha);
if (no_antialias)
{
- if (aa_alpha > 128)
+ if (aa_alpha1 > 128)
_cdLineDrawPixel(canvas, xi, yi, ls, fgcolor)
else
_cdLineDrawPixel(canvas, xi, yi+1, ls, fgcolor)
@@ -1086,7 +1090,7 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
if ((xi != *last_xi_a || yi != *last_yi_a) &&
(xi != *last_xi_b || yi != *last_yi_b))
{
- aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha1);
_cdLineDrawPixel(canvas, xi, yi, ls, aa_fgcolor);
if (xi == xi_last) /* one pixel only */
@@ -1096,7 +1100,7 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
if ((xi != *last_xi_a || yi+1 != *last_yi_a) &&
(xi != *last_xi_b || yi+1 != *last_yi_b))
{
- aa_fgcolor = cdEncodeAlpha(fgcolor, 255-aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha2);
_cdLineDrawPixel(canvas, xi, yi+1, ls, aa_fgcolor);
if (xi == xi_last) /* one pixel only */
@@ -1105,9 +1109,9 @@ void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2,
}
else
{
- aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha1);
_cdLineDrawPixel(canvas, xi, yi, ls, aa_fgcolor);
- aa_fgcolor = cdEncodeAlpha(fgcolor, 255-aa_alpha);
+ aa_fgcolor = cdEncodeAlpha(fgcolor, aa_alpha2);
_cdLineDrawPixel(canvas, xi, yi+1, ls, aa_fgcolor);
}
}
diff --git a/test/simple/simple.c b/test/simple/simple.c
index d04b96c..6091eb6 100644
--- a/test/simple/simple.c
+++ b/test/simple/simple.c
@@ -1335,12 +1335,23 @@ void SimpleDrawTest(void)
cdBackground(CD_WHITE);
cdClear();
- cdInteriorStyle(CD_SOLID);
- cdBegin(CD_FILL);
- cdVertex(w/4, h/4);
- cdVertex(w/2-w/8, h/4);
- cdVertex(w/2, h/2);
- cdVertex(w/2-w/8, h/2);
+ //cdSetAttribute("ANTIALIAS", "0");
+ cdForeground(cdEncodeAlpha(cdEncodeColor(255, 0, 0), 100));
+
+ cdfCanvasArc(cdActiveCanvas(), 255, 255, 100, 100, 0, 360);
+
+ cdLine(0, 0, 200, 200);
+
+ cdBegin(CD_BEZIER);
+ cdVertex(100, 100);
+ cdVertex(150, 200);
+ cdVertex(180, 250);
+ cdVertex(180, 200);
+ cdVertex(180, 150);
+ cdVertex(150, 100);
+ cdVertex(300, 100);
+ cdEnd();
+
cdEnd();
}