diff options
-rw-r--r-- | html/en/drv/gdiplus.html | 5 | ||||
-rw-r--r-- | html/en/func/filled.html | 7 | ||||
-rw-r--r-- | html/en/history.html | 8 | ||||
-rw-r--r-- | src/drv/cdgl.c | 7 | ||||
-rw-r--r-- | src/drv/cdirgb.c | 3 | ||||
-rw-r--r-- | src/gdiplus/cdwinp.cpp | 22 |
6 files changed, 28 insertions, 24 deletions
diff --git a/html/en/drv/gdiplus.html b/html/en/drv/gdiplus.html index 2229207..027fda8 100644 --- a/html/en/drv/gdiplus.html +++ b/html/en/drv/gdiplus.html @@ -82,11 +82,6 @@ </ul> <h4>Attributes </h4> <ul> - <li><a href="../func/filled.html#cdBackOpacity"><font face="Courier"><strong> - BackOpacity</strong></font></a>: only changes the transparency of the background color to 0 (transparent) or 255 - (opaque).</li> - <li><a href="../func/filled.html#cdHatch"><font face="Courier"><strong>Hatch</strong></font></a>: - diagonal styles are drawn with anti-aliasing.</li> <li><a href="../func/attributes.html#cdWriteMode"><font face="Courier"> <strong> WriteMode</strong></font></a>: does nothing. There is no support for XOR or NOT_XOR.</li> diff --git a/html/en/func/filled.html b/html/en/func/filled.html index 036f015..447bf9a 100644 --- a/html/en/func/filled.html +++ b/html/en/func/filled.html @@ -114,9 +114,10 @@ canvas:wChord(xc, yc, w, h, angle1, angle2: number) (WC) [in Lua]</pre> canvas:BackOpacity(opacity: number) -> (old_opacity: number) [in Lua]</pre> <p>Configures the background opacity to filling primitives based on the - foreground and background colors. Values: <font><b> + foreground and background colors. Note that only when InteriorStyle is <b> + CD_HATCH</b> or <b>CD_STIPPLE</b> that backopacity is used. Values: <font><b> CD_TRANSPARENT</b></font> or <b>CD_OPAQUE</b>. If it is opaque - the primitive will erase whatever is in background with the background color. + the primitive will erase whatever is in the background with the background color. If it is transparent, only the foreground color is painted. It returns the previous value. Default value: <b> CD_TRANSPARENT</b>. Value <b><b>CD_QUERY</b> </b>simply returns the current value. In some drivers is always opaque.</p> @@ -140,7 +141,7 @@ canvas:InteriorStyle(style: number) -> (old_style: number) [in Lua]</pre> <p>Configures the current style for the area filling primitives: <b> CD_SOLID</b>, <strong><b>CD_HOLLOW</b></strong>, <b>CD_HATCH</b>, - <b>CD_STIPPLE</b> or <b>CD_PATTERN</b>. Note that <b> + <b>CD_STIPPLE</b> or <b>CD_PATTERN</b>. Note that only <b> CD_HATCH</b> and <b>CD_STIPPLE</b> are affected by the backopacity. It returns the previous value. Default value: <b>CD_SOLID</b>. Value <b><b>CD_QUERY</b> </b>simply returns the current value.</p> diff --git a/html/en/history.html b/html/en/history.html index 1a11558..678a7b5 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -38,6 +38,14 @@ <li> <span class="hist_fixed">Fixed:</span> canvas:Transform when nil is used to reset the transformation.</li> + <li> + <span class="hist_fixed">Fixed:</span> <strong>cdCanvasClear</strong> + not considering the transparency of the background color in the GDI+ + base driver and in the CD_GL driver.</li> + <li> + <span class="hist_fixed">Fixed:</span> background transparency was not + being considered when backopacity was set to OPAQUE after the background + color was set in the GDI+ base driver.</li> </ul> <h3><a href="http://sourceforge.net/projects/canvasdraw/files/5.4/">Version 5.4</a> (24/June/2010)</h3> <ul> diff --git a/src/drv/cdgl.c b/src/drv/cdgl.c index 4357e5a..fb1739d 100644 --- a/src/drv/cdgl.c +++ b/src/drv/cdgl.c @@ -638,10 +638,11 @@ static long int cdforeground(cdCtxCanvas *ctxcanvas, long int color) static void cdclear(cdCtxCanvas* ctxcanvas) { - unsigned char r, g, b; + unsigned char r, g, b, a; cdDecodeColor(ctxcanvas->canvas->background, &r, &g, &b); - glClearColor((GLclampf)((double)r/255.0), (GLclampf)((double)g/255.0), (GLclampf)((double)b/255.0), 0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + a = cdDecodeAlpha(ctxcanvas->canvas->background); + glClearColor((GLclampf)r/255.0f, (GLclampf)g/255.0f, (GLclampf)b/255.0f, (GLclampf)a/255.0f); + glClear(GL_COLOR_BUFFER_BIT); } static void cdfline(cdCtxCanvas *ctxcanvas, double x1, double y1, double x2, double y2) diff --git a/src/drv/cdirgb.c b/src/drv/cdirgb.c index 68a5766..d9dd6a8 100644 --- a/src/drv/cdirgb.c +++ b/src/drv/cdirgb.c @@ -430,7 +430,8 @@ static void cdclear(cdCtxCanvas* ctxcanvas) memset(ctxcanvas->red, cdRed(ctxcanvas->canvas->background), size); memset(ctxcanvas->green, cdGreen(ctxcanvas->canvas->background), size); memset(ctxcanvas->blue, cdBlue(ctxcanvas->canvas->background), size); - if (ctxcanvas->alpha) memset(ctxcanvas->alpha, cdAlpha(ctxcanvas->canvas->background), size); /* here is the normal alpha coding */ + if (ctxcanvas->alpha) + memset(ctxcanvas->alpha, cdAlpha(ctxcanvas->canvas->background), size); /* here is the normal alpha coding */ } static void irgPostProcessIntersect(unsigned char* clip, int size) diff --git a/src/gdiplus/cdwinp.cpp b/src/gdiplus/cdwinp.cpp index db09cd6..522f136 100644 --- a/src/gdiplus/cdwinp.cpp +++ b/src/gdiplus/cdwinp.cpp @@ -139,9 +139,7 @@ static void sUpdateFillBrush(cdCtxCanvas* ctxcanvas) { // only stipple depends on Foreground and Background Color. if (ctxcanvas->canvas->interior_style == CD_STIPPLE) - { cdstipple(ctxcanvas, ctxcanvas->canvas->stipple_w, ctxcanvas->canvas->stipple_h, ctxcanvas->canvas->stipple); - } break; } } @@ -158,18 +156,17 @@ static long int cdforeground(cdCtxCanvas* ctxcanvas, long int color) return color; } -static Color sSetAlpha(const Color& c, BYTE alpha) +static Color sTranspAlpha(const Color& c) { - return Color(alpha, c.GetRed(), c.GetGreen(), c.GetBlue()); + return Color(0, c.GetRed(), c.GetGreen(), c.GetBlue()); } static long int cdbackground(cdCtxCanvas* ctxcanvas, long int color) { ctxcanvas->bg = sColor2Windows(color); - if ((ctxcanvas->canvas->back_opacity == CD_TRANSPARENT) && - (cdAlpha(ctxcanvas->canvas->background) == 255)) - ctxcanvas->bg = sSetAlpha(ctxcanvas->bg, (BYTE)0); + if (ctxcanvas->canvas->back_opacity == CD_TRANSPARENT) + ctxcanvas->bg = sTranspAlpha(ctxcanvas->bg); /* set background as full transparent */ sUpdateFillBrush(ctxcanvas); @@ -181,10 +178,10 @@ static int cdbackopacity(cdCtxCanvas* ctxcanvas, int opacity) switch (opacity) { case CD_TRANSPARENT: - ctxcanvas->bg = sSetAlpha(ctxcanvas->bg, (BYTE)0); + ctxcanvas->bg = sTranspAlpha(ctxcanvas->bg); /* set background as full transparent */ break; case CD_OPAQUE: - ctxcanvas->bg = sSetAlpha(ctxcanvas->bg, (BYTE)255); + ctxcanvas->bg = sColor2Windows(ctxcanvas->canvas->background); break; } @@ -1619,7 +1616,8 @@ static void cdclear(cdCtxCanvas* ctxcanvas) if (ctxcanvas->canvas->clip_mode != CD_CLIPOFF) ctxcanvas->graphics->ResetClip(); - ctxcanvas->graphics->Clear(sSetAlpha(ctxcanvas->bg, (BYTE)255)); + /* do NOT use "ctxcanvas->bg" here, because it depends on backopacity */ + ctxcanvas->graphics->Clear(sColor2Windows(ctxcanvas->canvas->background)); if (ctxcanvas->canvas->clip_mode != CD_CLIPOFF) cdclip(ctxcanvas, ctxcanvas->canvas->clip_mode); @@ -2717,8 +2715,8 @@ cdCtxCanvas *cdwpCreateCanvas(cdCanvas* canvas, Graphics* graphics, int wtype) set_aa_attrib(ctxcanvas, "1"); // default is ANTIALIAS=1 - ctxcanvas->fg = Color(); // black - ctxcanvas->bg = Color(255, 255, 255); // white + ctxcanvas->fg = Color(); // black,opaque + ctxcanvas->bg = Color(255, 255, 255); // white,opaque => used only for fill canvas->invert_yaxis = 1; |