Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorKonstantin Triger <kostat@mono-cvs.ximian.com>2005-11-13 13:55:09 +0300
committerKonstantin Triger <kostat@mono-cvs.ximian.com>2005-11-13 13:55:09 +0300
commit912cee669c735329c34a6509a437389ee01af313 (patch)
treec5679c436933b95312e87fa27d550d336c4b4464 /mcs
parentc0064d3b493e78456d449ad335c8ad948e7453be (diff)
restore quadTo as curveTo affects quality
svn path=/trunk/mcs/; revision=52963
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog4
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs86
2 files changed, 53 insertions, 37 deletions
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
index ea5e0c8844b..96177f685d9 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
@@ -1,5 +1,9 @@
2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+ * ExtendedGeneralPath.jvm.cs: restore quadTo as curveTo affects quality
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
* PathData.cs: fixing access modifiers.
2005-10-31 Konstantin Triger <kostat@mainsoft.com>
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs
index fc497a2410a..7c9c9d81363 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs
@@ -179,8 +179,13 @@ namespace System.Drawing.Drawing2D
private PathData GetPathData ()
{
PathData pathData = new PathData();
- pathData.Types = new byte [PointCount];
- pathData.Points = new PointF [PointCount];
+ int nPts = PointCount;
+ for (int i = 0; i < TypesCount; i++)
+ if ((Types [i] & SEG_MASK) == SEG_QUADTO)
+ nPts++;
+
+ pathData.Types = new byte [nPts];
+ pathData.Points = new PointF [nPts];
int tpos = 0;
int ppos = 0;
int cpos = 0;
@@ -206,11 +211,37 @@ namespace System.Drawing.Drawing2D
pathData.InternalPoints [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
break;
case SEG_QUADTO:
- // FIXME : use 4 cp , two of which
+ /*
+ .net does not support Quadratic curves, so convert to Cubic according to http://pfaedit.sourceforge.net/bezier.html
+
+ The end points of the cubic will be the same as the quadratic's.
+ CP0 = QP0
+ CP3 = QP2
+
+ The two control points for the cubic are:
+
+ CP1 = QP0 + 2/3 *(QP1-QP0)
+ CP2 = CP1 + 1/3 *(QP2-QP0)
+ */
+
+ float x0 = Coords[cpos-2]; //QP0
+ float y0 = Coords[cpos-1]; //QP0
+
+ float x1 = x0 + (2/3 * (Coords [cpos++]-x0));
+ float y1 = y0 + (2/3 * (Coords [cpos++]-y0));
+
+ float x3 = Coords [cpos++]; //QP2
+ float y3 = Coords [cpos++]; //QP2
+
+ float x2 = x1 + (1/3 * (x3-x0));
+ float y2 = y1 + (1/3 * (y3-y0));
+
pathData.InternalTypes [tpos++] = (byte)(byte) PathPointType.Bezier;
- pathData.InternalPoints [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ pathData.InternalPoints [ppos++] = new PointF (x1, y1);
+ pathData.InternalTypes [tpos++] = (byte)(byte) PathPointType.Bezier;
+ pathData.InternalPoints [ppos++] = new PointF (x2, y2);
pathData.InternalTypes [tpos++] = (byte) ((byte)PathPointType.Bezier | marker);
- pathData.InternalPoints [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ pathData.InternalPoints [ppos++] = new PointF (x3, y3);
break;
case SEG_CUBICTO:
pathData.InternalTypes [tpos++] = (byte)(byte) PathPointType.Bezier3;
@@ -439,37 +470,14 @@ namespace System.Drawing.Drawing2D
public void quadTo(float x1, float y1, float x2, float y2)
{
-// ClearCache ();
-// needRoom (1, 4, true);
-// _types [_typesCount++] = SEG_QUADTO;
-// _coords [_coordsCount++] = x1;
-// _coords [_coordsCount++] = y1;
-// _coords [_coordsCount++] = x2;
-// _coords [_coordsCount++] = y2;
-
- /*
- .net does not support Quadratic curves, so convert to Cubic according to http://pfaedit.sourceforge.net/bezier.html
-
- The end points of the cubic will be the same as the quadratic's.
- CP0 = QP0
- CP3 = QP2
-
- The two control points for the cubic are:
-
- CP1 = QP0 + 2/3 *(QP1-QP0)
- CP2 = CP1 + 1/3 *(QP2-QP0)
- */
-
- float x0 = _coords[_coordsCount-2];
- float y0 = _coords[_coordsCount-1];
-
- float cx1 = x0 + (2/3 * (x1-x0));
- float cy1 = y0 + (2/3 * (y1-y0));
-
- float cx2 = cx1 + (1/3 * (x2-x0));
- float cy2 = cy1 + (1/3 * (y2-y0));
-
- curveTo(cx1, cy1, cx2, cy2, x2, y2);
+ // restore quadTo as cubic affects quality
+ ClearCache ();
+ needRoom (1, 4, true);
+ _types [_typesCount++] = SEG_QUADTO;
+ _coords [_coordsCount++] = x1;
+ _coords [_coordsCount++] = y1;
+ _coords [_coordsCount++] = x2;
+ _coords [_coordsCount++] = y2;
}
public void reset()
@@ -489,8 +497,12 @@ namespace System.Drawing.Drawing2D
public void transform(AffineTransform at)
{
+ transform(at, 0, CoordsCount);
+ }
+
+ public void transform(AffineTransform at, int startCoord, int numCoords) {
ClearCache ();
- at.transform (_coords, 0, _coords, 0, _coordsCount/2);
+ at.transform (_coords, startCoord, _coords, startCoord, numCoords/2);
}
private void needRoom(int newTypes, int newCoords, bool needMove)