summaryrefslogtreecommitdiff
path: root/src/win32
diff options
context:
space:
mode:
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/cdwdib.c38
-rw-r--r--src/win32/cdwin.c27
-rw-r--r--src/win32/cdwin.h1
3 files changed, 48 insertions, 18 deletions
diff --git a/src/win32/cdwdib.c b/src/win32/cdwdib.c
index aff3f64..25851cd 100644
--- a/src/win32/cdwdib.c
+++ b/src/win32/cdwdib.c
@@ -323,6 +323,44 @@ void cdwDIBEncodeRGBARect(cdwDIB* dib, const unsigned char *red, const unsigned
}
}
+void cdwDIBEncodeRGBARectMirror(cdwDIB* dib, const unsigned char *red, const unsigned char *green, const unsigned char *blue, const unsigned char *alpha, int xi, int yi, int wi, int hi)
+{
+ int x,y, resto1, resto2, offset, line_size;
+ BYTE* bits;
+
+ line_size = cdwDIBLineSize(dib->w, 32);
+
+ bits = dib->bits + line_size*(dib->h-1);
+ resto1 = line_size - dib->w * 4;
+ resto2 = wi - dib->w;
+
+ offset = wi * yi + xi;
+
+ red = red + offset;
+ green = green + offset;
+ blue = blue + offset;
+ alpha = alpha + offset;
+
+ for (y = 0; y < dib->h; y++)
+ {
+ for (x = 0; x < dib->w; x++)
+ {
+ *bits++ = CD_ALPHAPRE(*blue, *alpha); blue++;
+ *bits++ = CD_ALPHAPRE(*green, *alpha); green++;
+ *bits++ = CD_ALPHAPRE(*red, *alpha); red++;
+ *bits++ = *alpha++;
+ }
+
+ bits += resto1;
+ bits -= 2*line_size;
+
+ red += resto2;
+ green += resto2;
+ blue += resto2;
+ alpha += resto2;
+ }
+}
+
void cdwDIBEncodeAlphaRect(cdwDIB* dib, const unsigned char *alpha, int xi, int yi, int wi, int hi)
{
int x,y, resto1, resto2, offset;
diff --git a/src/win32/cdwin.c b/src/win32/cdwin.c
index 972f5a9..e2eb9ea 100644
--- a/src/win32/cdwin.c
+++ b/src/win32/cdwin.c
@@ -896,12 +896,11 @@ static void cdpoly(cdCtxCanvas* ctxcanvas, int mode, cdPoint* poly, int n)
old_arcmode = SetArcDirection(ctxcanvas->hDC, ctxcanvas->canvas->invert_yaxis? AD_CLOCKWISE: AD_COUNTERCLOCKWISE);
}
- Arc(ctxcanvas->hDC, arc.LeftRect, arc.TopRect, arc.RightRect, arc.BottomRect, arc.XStartArc, arc.YStartArc, arc.XEndArc, arc.YEndArc);
+ ArcTo(ctxcanvas->hDC, arc.LeftRect, arc.TopRect, arc.RightRect, arc.BottomRect, arc.XStartArc, arc.YStartArc, arc.XEndArc, arc.YEndArc);
if (old_arcmode) /* restore */
SetArcDirection(ctxcanvas->hDC, old_arcmode);
- MoveToEx(ctxcanvas->hDC, arc.XEndArc, arc.YEndArc, NULL);
current_set = 1;
i += 3;
@@ -1760,10 +1759,12 @@ static void sFixImageY(cdCanvas* canvas, int *y, int *h)
/* Here, y is from top to bottom,
is at the bottom-left corner of the image if h>0
is at the top-left corner of the image if h<0. (Undocumented feature)
+
cdCalcZoom expects Y at top-left if h>0
and Y at bottom-left if h<0
if h<0 then eh<0 to StretchDIBits mirror the image.
- BUT!!!!!! AlphaBlend will NOT mirror the image. */
+ BUT!!!!!! AlphaBlend will NOT mirror the image.
+ So it must be manually made there. */
if (!canvas->invert_yaxis)
*h = -(*h);
@@ -1879,26 +1880,16 @@ static void cdputimagerectrgba(cdCtxCanvas* ctxcanvas, int width, int height, co
return;
}
- cdwDIBEncodeRGBARect(&dib, red, green, blue, alpha, bx, by, width, height);
-
if (eh < 0) /* must mirror the image */
{
- XFORM xForm;
-
+ /* Fix position */
eh = -eh;
+ ey = ey - eh;
- SetGraphicsMode(hDCMem, GM_ADVANCED);
- ModifyWorldTransform(hDCMem, NULL, MWT_IDENTITY);
-
- /* configure a bottom-up coordinate system */
- xForm.eM11 = (FLOAT)1;
- xForm.eM12 = (FLOAT)0;
- xForm.eM21 = (FLOAT)0;
- xForm.eM22 = (FLOAT)-1;
- xForm.eDx = (FLOAT)0;
- xForm.eDy = (FLOAT)(bh-1);
- ModifyWorldTransform(hDCMem, &xForm, MWT_LEFTMULTIPLY);
+ cdwDIBEncodeRGBARectMirror(&dib, red, green, blue, alpha, bx, by, width, height);
}
+ else
+ cdwDIBEncodeRGBARect(&dib, red, green, blue, alpha, bx, by, width, height);
hOldBitmap = SelectObject(hDCMem, hBitmap);
diff --git a/src/win32/cdwin.h b/src/win32/cdwin.h
index a8230e7..94ed62c 100644
--- a/src/win32/cdwin.h
+++ b/src/win32/cdwin.h
@@ -169,6 +169,7 @@ void cdwDIBEncodePattern(cdwDIB* dib, const long int *colors);
void cdwDIBEncodeMapRect(cdwDIB* dib, const unsigned char *index, const long int *colors, int xi, int yi, int wi, int hi);
void cdwDIBEncodeRGBRect(cdwDIB* dib, const unsigned char *red, const unsigned char *green, const unsigned char *blue, int xi, int yi, int wi, int hi);
void cdwDIBEncodeRGBARect(cdwDIB* dib, const unsigned char *red, const unsigned char *green, const unsigned char *blue, const unsigned char *alpha, int xi, int yi, int wi, int hi);
+void cdwDIBEncodeRGBARectMirror(cdwDIB* dib, const unsigned char *red, const unsigned char *green, const unsigned char *blue, const unsigned char *alpha, int xi, int yi, int wi, int hi);
void cdwDIBEncodeRGBARectZoom(cdwDIB* dib, const unsigned char *red, const unsigned char *green, const unsigned char *blue, const unsigned char *alpha, int w, int h, int xi, int yi, int wi, int hi);
void cdwDIBEncodeAlphaRect(cdwDIB* dib, const unsigned char *alpha, int xi, int yi, int wi, int hi);