+2004-01-19 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPath.cs: Implemented. Still needs testing, though.
+ Particular the PathPoints property, I ran into a P/Invoke problem,
+ I need to first fix that before I can go on with the rest of the testing.
+
2004-01-13 Ravindra <rkumar@novell.com>
* Matrix.cs: Made the Matrix(IntPtr) constructor internal.
Because default access is private, that makes it unusable
by other classes.
+2004-01-11 Duncan Mak <duncan@ximian.com>
+
+ * Matrix.cs (Matrix): Removed reference to GpRect/GpRectF.
+
2004-01-10 Ravindra <rkumar@novell.com>
* All Enums: Made serializable.
//\r
// Authors:\r
//\r
-// Miguel de Icaza (miguel@ximian.com)\r
+// Miguel de Icaza (miguel@ximian.com)v\r
+// Duncan Mak (duncan@ximian.com)\r
//\r
-// (C) 2003 Ximian, Inc\r
+// (C) 2004 Novell, Inc\r
//\r
+\r
using System;\r
using System.Drawing;\r
using System.Runtime.InteropServices;\r
namespace System.Drawing.Drawing2D\r
{\r
\r
-public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable {\r
+ public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable {\r
\r
- public GraphicsPath ()\r
- {\r
- }\r
- \r
- public object Clone ()\r
- {\r
- throw new NotImplementedException ();\r
- }\r
-\r
- public void Dispose ()\r
- {\r
- Dispose (true);\r
- System.GC.SuppressFinalize (this);\r
- }\r
-\r
- ~GraphicsPath ()\r
- {\r
- Dispose (false);\r
- }\r
+ internal IntPtr nativePath;\r
+\r
+ GraphicsPath (IntPtr ptr)\r
+ {\r
+ nativePath = ptr;\r
+ }\r
+\r
+ public GraphicsPath ()\r
+ {\r
+ GDIPlus.GdipCreatePath (FillMode.Alternate, out nativePath);\r
+ }\r
\r
- void Dispose (bool disposing)\r
- {\r
+ public object Clone ()\r
+ {\r
+ IntPtr clone;\r
+\r
+ GDIPlus.GdipClonePath (nativePath, out clone);\r
+\r
+ return new GraphicsPath (clone);\r
+ }\r
+\r
+ public void Dispose ()\r
+ {\r
+ Dispose (true);\r
+ System.GC.SuppressFinalize (this);\r
+ }\r
+\r
+ ~GraphicsPath ()\r
+ {\r
+ Dispose (false);\r
+ }\r
+ \r
+ void Dispose (bool disposing)\r
+ {\r
\r
- }\r
-\r
- //\r
- // AddArc\r
- //\r
- public void AddArc (Rectangle rect, float start_angle, float sweep_angle)\r
- {\r
- }\r
-\r
- public void AddArc (RectangleF rect, float start_angle, float sweep_angle)\r
- {\r
- }\r
-\r
- public void AddArc (int x, int y, int width, int height, float start_angle, float sweep_angle)\r
- {\r
- }\r
-\r
- public void AddArc (float x, float y, float width, float height, float start_angle, float sweep_angle)\r
- {\r
- }\r
-\r
- //\r
- // AddLine\r
- //\r
- public void AddLine (Point a, Point b)\r
- {\r
- }\r
-\r
- public void AddLine (PointF a, PointF b)\r
- {\r
- }\r
-\r
- public void AddLine (int x1, int y1, int x2, int y2)\r
- {\r
- }\r
-\r
- public void AddLine (float x1, float y1, float x2, float y2)\r
- {\r
- }\r
+ }\r
\r
- \r
- \r
-}\r
\r
+ public FillMode FillMode {\r
+ get {\r
+\r
+ FillMode mode;\r
+ GDIPlus.GdipGetPathFillMode (nativePath, out mode);\r
+ return mode;\r
+ }\r
+\r
+ set {\r
+ GDIPlus.GdipSetPathFillMode (nativePath, value);\r
+ }\r
+ }\r
+\r
+ public PathData PathData {\r
+\r
+ get {\r
+ IntPtr tmp;\r
+ GDIPlus.GdipGetPathData (nativePath, out tmp);\r
+\r
+ throw new Exception ();\r
+ }\r
+ }\r
+\r
+ public PointF [] PathPoints {\r
+\r
+ get {\r
+ int count;\r
+ \r
+ GDIPlus.GdipGetPointCount (nativePath, out count);\r
+\r
+ PointF [] points = new PointF [count];\r
+\r
+ GDIPlus.GdipGetPathPoints (nativePath, points, count); \r
+\r
+ return points;\r
+ }\r
+ }\r
+\r
+ public byte [] PathTypes {\r
+\r
+ get {\r
+ int count;\r
+ GDIPlus.GdipGetPointCount (nativePath, out count);\r
+\r
+ byte [] types = new byte [count];\r
+ GDIPlus.GdipGetPathTypes (nativePath, types, count);\r
+\r
+ return types;\r
+ }\r
+ }\r
+\r
+ public int PathCount {\r
+\r
+ get {\r
+ int count;\r
+\r
+ GDIPlus.GdipGetPointCount (nativePath, out count);\r
+\r
+ return count;\r
+ }\r
+ }\r
+ \r
+ //\r
+ // AddArc\r
+ //\r
+ public void AddArc (Rectangle rect, float start_angle, float sweep_angle)\r
+ {\r
+ GDIPlus.GdipAddPathArcI (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);\r
+ }\r
+\r
+ public void AddArc (RectangleF rect, float start_angle, float sweep_angle)\r
+ {\r
+ GDIPlus.GdipAddPathArc (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);\r
+ }\r
+\r
+ public void AddArc (int x, int y, int width, int height, float start_angle, float sweep_angle)\r
+ {\r
+ GDIPlus.GdipAddPathArcI (nativePath, x, y, width, height, start_angle, sweep_angle); \r
+ }\r
+\r
+ public void AddArc (float x, float y, float width, float height, float start_angle, float sweep_angle)\r
+ {\r
+ GDIPlus.GdipAddPathArc (nativePath, x, y, width, height, start_angle, sweep_angle);\r
+ }\r
+\r
+ //\r
+ // AddBezier\r
+ //\r
+ public void AddBezier (Point pt1, Point pt2, Point pt3, Point pt4)\r
+ {\r
+ GDIPlus.GdipAddPathBezierI (nativePath, pt1.X, pt1.Y,\r
+ pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);\r
+ }\r
+\r
+ public void AddBezier (PointF pt1, PointF pt2, PointF pt3, PointF pt4)\r
+ {\r
+ GDIPlus.GdipAddPathBezier (nativePath, pt1.X, pt1.Y,\r
+ pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);\r
+ }\r
+\r
+ public void AddBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)\r
+ {\r
+ GDIPlus.GdipAddPathBezierI (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);\r
+ }\r
+\r
+ public void AddBezier (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)\r
+ {\r
+ GDIPlus.GdipAddPathBezier (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);\r
+ }\r
+\r
+ //\r
+ // AddBeziers\r
+ //\r
+ public void AddBeziers (Point [] pts)\r
+ {\r
+ GDIPlus.GdipAddPathBeziersI (nativePath, pts, pts.Length);\r
+ }\r
+\r
+ public void AddBeziers (PointF [] pts)\r
+ {\r
+ GDIPlus.GdipAddPathBeziers (nativePath, pts, pts.Length);\r
+ }\r
+\r
+ //\r
+ // AddLine\r
+ //\r
+ public void AddLine (Point a, Point b)\r
+ {\r
+ GDIPlus.GdipAddPathLineI (nativePath, a.X, a.Y, b.X, b.Y);\r
+ }\r
+\r
+ public void AddLine (PointF a, PointF b)\r
+ {\r
+ GDIPlus.GdipAddPathLine (nativePath, a.X, a.Y, b.X,\r
+ b.Y);\r
+ }\r
+\r
+ public void AddLine (int x1, int y1, int x2, int y2)\r
+ {\r
+ GDIPlus.GdipAddPathLineI (nativePath, x1, y1, x2, y2);\r
+ }\r
+\r
+ public void AddLine (float x1, float y1, float x2, float y2)\r
+ {\r
+ GDIPlus.GdipAddPathLine (nativePath, x1, y1, x2,\r
+ y2); \r
+ }\r
+\r
+ //\r
+ // AddLines\r
+ //\r
+ public void AddLines (Point [] points)\r
+ {\r
+ int length = points.Length;\r
+\r
+ for (int i = 0; i < length - 2; i += 2) {\r
+ int j = i + 1;\r
+ GDIPlus.GdipAddPathLineI (nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);\r
+ }\r
+ }\r
+\r
+ public void AddLines (PointF [] points)\r
+ {\r
+ int length = points.Length;\r
+\r
+ for (int i = 0; i < length - 2; i += 2) {\r
+ int j = i + 1;\r
+ GDIPlus.GdipAddPathLine (nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);\r
+ }\r
+ }\r
+ \r
+ //\r
+ // AddPie\r
+ //\r
+ public void AddPie (Rectangle rect, float startAngle, float sweepAngle)\r
+ {\r
+ GDIPlus.GdipAddPathPie (nativePath, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);\r
+ }\r
+\r
+ public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle)\r
+ {\r
+ GDIPlus.GdipAddPathPie (nativePath, x, y, width, height, sweepAngle, sweepAngle);\r
+ }\r
+\r
+ public void AddPie (float x, float y, float width, float height, float startAngle, float sweepAngle)\r
+ {\r
+ GDIPlus.GdipAddPathPie (nativePath, x, y, width, height, sweepAngle, sweepAngle); \r
+ }\r
+\r
+ //\r
+ // AddPolygon\r
+ //\r
+ public void AddPolygon (Point [] points)\r
+ {\r
+\r
+ GDIPlus.GdipAddPathPolygonI (nativePath, points, points.Length);\r
+ }\r
+\r
+ public void AddPolygon (PointF [] points)\r
+ {\r
+ GDIPlus.GdipAddPathPolygon (nativePath, points, points.Length);\r
+ }\r
+\r
+ //\r
+ // AddRectangle\r
+ //\r
+ public void AddRectangle (Rectangle rect)\r
+ {\r
+ GDIPlus.GdipAddPathRectangleI (nativePath, rect.X, rect.Y, rect.Width, rect.Height);\r
+ }\r
+\r
+ public void AddRectangle (RectangleF rect)\r
+ {\r
+ GDIPlus.GdipAddPathRectangle (nativePath, rect.X, rect.Y, rect.Width, rect.Height);\r
+ }\r
+\r
+ //\r
+ // AddRectangles\r
+ //\r
+ public void AddRectangles (Rectangle [] rects)\r
+ {\r
+ GDIPlus.GdipAddPathRectanglesI (nativePath, rects, rects.Length);\r
+ }\r
+\r
+ public void AddRectangles (RectangleF [] rects)\r
+ {\r
+ GDIPlus.GdipAddPathRectangles (nativePath, rects, rects.Length);\r
+ }\r
+\r
+ public PointF GetLastPoint ()\r
+ {\r
+ PointF pt;\r
+ GDIPlus.GdipGetPathLastPoint (nativePath, out pt);\r
+\r
+ return pt;\r
+ }\r
+\r
+ public void Reset ()\r
+ {\r
+ GDIPlus.GdipResetPath (nativePath);\r
+ }\r
+\r
+ public void Reverse ()\r
+ {\r
+ GDIPlus.GdipReversePath (nativePath);\r
+ }\r
+\r
+ public void Transform (Matrix matrix)\r
+ {\r
+ GDIPlus.GdipTransformPath (nativePath, matrix.nativeMatrix);\r
+ }\r
+ }\r
}\r
+\r
+\r
\r
namespace System.Drawing.Drawing2D\r
{\r
- public sealed class Matrix : MarshalByRefObject, IDisposable\r
+ public sealed class Matrix : MarshalByRefObject, IDisposable\r
{\r
internal IntPtr nativeMatrix;\r
\r
\r
public Matrix (Rectangle rect , Point[] plgpts)\r
{\r
- GpRect rectangle = new GpRect (rect);\r
-\r
- GDIPlus.GdipCreateMatrix3I (rectangle, plgpts, out nativeMatrix);\r
+ GDIPlus.GdipCreateMatrix3I (rect, plgpts, out nativeMatrix);\r
}\r
\r
public Matrix (RectangleF rect , PointF[] pa)\r
{\r
- GpRectF rectangle = new GpRectF (rect);\r
-\r
- GDIPlus.GdipCreateMatrix3 (rectangle, pa, out nativeMatrix);\r
+ GDIPlus.GdipCreateMatrix3 (rect, pa, out nativeMatrix);\r
}\r
\r
public Matrix (float m11, float m12, float m21, float m22, float dx, float dy)\r
// properties\r
public float[] Elements {\r
get {\r
- IntPtr tmp = Marshal.AllocHGlobal (8 * 6);\r
+ IntPtr tmp = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (float)) * 6);\r
+ float [] retval = new float [6];\r
\r
Status s = GDIPlus.GdipGetMatrixElements (nativeMatrix, tmp);\r
\r
- float [] retval = new float [6];\r
-\r
Marshal.Copy (tmp, retval, 0, 6);\r
\r
Marshal.FreeHGlobal (tmp);\r
{
Console.WriteLine("Bitmap.LockBits");
- GpRect rc = new GpRect (rect);
BitmapData result = new BitmapData();
if (nativeObject == (IntPtr) 0)
IntPtr lfBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(result));
Marshal.StructureToPtr(result, lfBuffer, false);
- Status status = GDIPlus.GdipBitmapLockBits (nativeObject, ref rc, flags, format, lfBuffer);
+ Status status = GDIPlus.GdipBitmapLockBits (nativeObject, ref rect, flags, format, lfBuffer);
result = (BitmapData) Marshal.PtrToStructure(lfBuffer, typeof(BitmapData));
Marshal.FreeHGlobal (lfBuffer);
+2004-01-19 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs: Import functions for GraphicsPath.
+
2004-01-14 Ravindra <rkumar@novell.com>
* SolidBrush.cs: Made SolidBrush to initialize its color
* gdipFunctions.cs: Added call to GdipGetSolidFillColor GDI+ API.
+2004-01-11 Duncan Mak <duncan@ximian.com>
+
+ * Bitmap.cs (LockBits):
+ * Graphics.cs (DrawString): Removed reference to GpRectF.
+
+2004-01-09 Duncan Mak <duncan@ximian.com>
+
+ * gdipStructs.cs (GpRectF, GpRect, GpPointF, GpPoint):
+ Removed. Didn't know that structs are laid out sequentially by
+ default. We don't need these anymore.
+
2004-01-12 Ben Maurer <bmaurer@users.sourceforge.net>
* Color.cs: Keep KnownColors in an array so that we avoid ht lookup.
[MonoTODO("Ignores the font")]
public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
{
- GpRectF rf = new GpRectF (layoutRectangle);
-
- GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref rf, IntPtr.Zero, brush.nativeObject);
+ GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref layoutRectangle, IntPtr.Zero, brush.nativeObject);
}
[MonoTODO("This ignores the font")]
public void DrawString (string s, Font font, Brush brush, PointF point)
{
- GpRectF rc = new GpRectF ();
- rc.left = point.X;
- rc.top = point.Y;
- rc.right = 0;
- rc.bottom = 0;
+ RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref rc, IntPtr.Zero, brush.nativeObject);
}
[MonoTODO ("This ignores the font and format")]
public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
{
- GpRectF rc = new GpRectF ();
- rc.left = point.X;
- rc.top = point.Y;
- rc.right = 0;
- rc.bottom = 0;
+ RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref rc, IntPtr.Zero, brush.nativeObject);
}
[MonoTODO ("This ignores the font and the format")]
public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
{
- GpRectF rect = new GpRectF (layoutRectangle);
-
- GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref rect, IntPtr.Zero, brush.nativeObject);
-
+ GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref layoutRectangle, IntPtr.Zero, brush.nativeObject);
}
[MonoTODO("This ignores the font")]
public void DrawString (string s, Font font, Brush brush, float x, float y)
{
Console.WriteLine("DrawString!");
- GpRectF rc = new GpRectF ();
- rc.left = x;
- rc.top = y;
- rc.right = 0;
- rc.bottom = 0;
+ RectangleF rc = new RectangleF (x, y, 0, 0);
Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero,
ref rc, IntPtr.Zero, brush.nativeObject);
[DllImport("gdiplus.dll")]
static internal extern Status GdipFillRectangle (IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2);
[DllImport("gdiplus.dll")]
- static internal extern Status GdipDrawString (IntPtr graphics, string text, int len, IntPtr font, ref GpRectF rc, IntPtr format, IntPtr brush);
+ static internal extern Status GdipDrawString (IntPtr graphics, string text, int len, IntPtr font, ref RectangleF rc, IntPtr format, IntPtr brush);
[DllImport("gdiplus.dll")]
static internal extern Status GdipGetDC (IntPtr graphics, out int hdc);
[DllImport("gdiplus.dll")]
internal static extern Status GdipCreateBitmapFromGraphics (int width, int height, IntPtr target, out int bitmap);
[DllImport("gdiplus.dll")]
- internal static extern Status GdipBitmapLockBits (IntPtr bmp, ref GpRect rc, ImageLockMode flags, PixelFormat format, [In, Out] IntPtr bmpData);
+ internal static extern Status GdipBitmapLockBits (IntPtr bmp, ref Rectangle rc, ImageLockMode flags, PixelFormat format, [In, Out] IntPtr bmpData);
// This an internal GDIPlus Cairo function, not part GDIPlus interface
//[DllImport("gdiplus.dll")]
[DllImport ("gdiplus.dll")]
internal static extern Status GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipCreateMatrix3 (GpRectF rect, PointF[] dstplg, out IntPtr matrix);
+ internal static extern Status GdipCreateMatrix3 (RectangleF rect, PointF[] dstplg, out IntPtr matrix);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipCreateMatrix3I (GpRect rect, Point[] dstplg, out IntPtr matrix);
+ internal static extern Status GdipCreateMatrix3I (Rectangle rect, Point[] dstplg, out IntPtr matrix);
[DllImport ("gdiplus.dll")]
internal static extern Status GdipDeleteMatrix (IntPtr matrix);
[DllImport ("gdiplus.dll")]
internal static extern Status GdipCreatePath2 (PointF points, byte [] types, int count, FillMode brushMode, out IntPtr path);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipClonePath (IntPtr path, out GraphicsPath clonePath);
+ internal static extern Status GdipClonePath (IntPtr path, out IntPtr clonePath);
[DllImport ("gdiplus.dll")]
internal static extern Status GdipDeletePath (IntPtr path);
[DllImport ("gdiplus.dll")]
[DllImport ("gdiplus.dll")]
internal static extern Status GdipGetPointCount (IntPtr path, out int count);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipGetPathTypes (IntPtr path, out IntPtr types, out int count);
+ internal static extern Status GdipGetPathTypes (IntPtr path, byte [] types, int count);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipGetPathPoints (IntPtr path, out IntPtr points, out int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipGetPathPointsI (IntPtr path, out IntPtr points, out int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipGetPathFillMode (IntPtr path, out FillMode mode);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipSetPathFillMode (IntPtr path, FillMode mode);
+ internal static extern Status GdipGetPathPoints (IntPtr path, PointF [] points, int count);
[DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathPointsI (IntPtr path, Point [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathFillMode (IntPtr path, out FillMode fillMode);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetPathFillMode (IntPtr path, FillMode fillMode);
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipGetPathData (IntPtr path, out IntPtr pathData);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipStartPathFigure (IntPtr path);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipClosePathFigure (IntPtr path);
- [DllImport ("gdiplus.dll")]
- internal static extern Status ClosePathFigures (IntPtr path);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipClosePathFigures (IntPtr path);
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipSetPathMarker (IntPtr path);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipClearPathMarkers (IntPtr path);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipReversePath (IntPtr path);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipGetPathLastPoint (IntPtr path, out IntPtr lastPoint);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddLine (IntPtr path, float x1, float y1, float x2, float y2);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathLine2 (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathLastPoint (IntPtr path, out PointF lastPoint);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathLine (IntPtr path, float x1, float y1, float x2, float y2);
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathArc (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathBezier (IntPtr path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathBeziers (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathCurve (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathCurve2 (IntPtr path, IntPtr points, int count, float tension);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathCurve3 (IntPtr path, IntPtr points, int count, int offset, int numberOfSegments, float tension);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathClosedCurve (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathClosedCurve2 (IntPtr path, IntPtr points, int count, float tension);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathBeziers (IntPtr path, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathCurve (IntPtr path, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathRectangle (IntPtr path, float x, float y, float width, float height);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathRectangles (IntPtr path, IntPtr rects, int count);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathRectangles (IntPtr path, RectangleF [] rects, int count);
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathEllipse (IntPtr path, float x, float y, float width, float height);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathPie (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathPolygon (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathPath (IntPtr path, GraphicsPath addingPath, bool connect);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathPolygon (IntPtr path, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathPath (IntPtr path, IntPtr addingPath, bool connect);
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathLineI (IntPtr path, int x1, int y1, int x2, int y2);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathLine2I (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathArcI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
+
[DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathBezierI (IntPtr path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
-
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathBeziersI (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathCurveI (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathCurve2I (IntPtr path, IntPtr points, int count, float tension);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathCurve3I (IntPtr path, IntPtr points, int count, int offset, int numberOfSegments, float tension);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathClosedCurveI (IntPtr path, IntPtr points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathBeziersI (IntPtr path, Point [] points, int count);
+
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathClosedCurve2I (IntPtr path, IntPtr points, int count, float tension);
+ internal static extern Status GdipAddPathPolygonI (IntPtr path, Point [] points, int count);
[DllImport ("gdiplus.dll")]
internal static extern Status GdipAddPathRectangleI (IntPtr path, int x, int y, int width, int height);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathRectanglesI (IntPtr path, IntPtr rects, int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathEllipseI (IntPtr path, int x, int y, int width, int height);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathPieI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipAddPathPolygonI (IntPtr path, IntPtr points, int count);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipFlattenPath (IntPtr path, IntPtr matrix, float flatness);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipWindingModeOutline (IntPtr path, IntPtr matrix, float flatness);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipWidenPath (IntPtr nativePath, IntPtr pen, IntPtr matrix, float flatness);
- [DllImport ("gdiplus.dll")]
- internal static extern Status GdipWarpPath (IntPtr nativePath, IntPtr matrix, IntPtr points, int count, float src, float srcy, float srcwidth, float srcheight, WarpMode warpMode, float flatness);
- [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathRectanglesI (IntPtr path, Rectangle [] rects, int count);
+ [DllImport ("gdiplus.dll")]
internal static extern Status GdipTransformPath (IntPtr path, IntPtr matrix);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipGetPathWorldBounds (IntPtr path, IntPtr bounds, IntPtr matrix, IntPtr pen);
- [DllImport ("gdiplus.dll")]
internal static extern Status GdipGetPathWorldBoundsI (IntPtr path, IntPtr bounds, IntPtr matrix, IntPtr pen);
[DllImport ("gdiplus.dll")]
internal static extern Status GdipIsVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
[DllImport ("gdiplus.dll")]
internal static extern Status GdipIsOutlineVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
[DllImport ("gdiplus.dll")]
- internal static extern Status GdipIsOutlineVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result);
+ internal static extern Status GdipIsOutlineVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result);
+
#endregion
}
}
[StructLayout(LayoutKind.Sequential)]
internal struct GdiplusStartupInput
{
- uint GdiplusVersion;
- IntPtr DebugEventCallback;
- int SuppressBackgroundThread;
- int SuppressExternalCodecs;
+ uint GdiplusVersion;
+ IntPtr DebugEventCallback;
+ int SuppressBackgroundThread;
+ int SuppressExternalCodecs;
internal static GdiplusStartupInput MakeGdiplusStartupInput ()
{
return result;
}
- }
+ }
[StructLayout(LayoutKind.Sequential)]
internal struct GdiplusStartupOutput
{
- internal IntPtr NotificationHook;
- internal IntPtr NotificationUnhook;
-
+ internal IntPtr NotificationHook;
+ internal IntPtr NotificationUnhook;
+
internal static GdiplusStartupOutput MakeGdiplusStartupOutput ()
{
GdiplusStartupOutput result = new GdiplusStartupOutput ();
return result;
}
}
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct GpRect
- {
- internal int left;
- internal int top;
- internal int right;
- internal int bottom;
-
- internal GpRect (Rectangle r)
- {
- left = r.Left;
- top = r.Top;
- right = r.Right;
- bottom = r.Bottom;
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct GpRectF
- {
- internal float left;
- internal float top;
- internal float right;
- internal float bottom;
-
- internal GpRectF (RectangleF r)
- {
- left = r.Left;
- top = r.Top;
- right = r.Right;
- bottom = r.Bottom;
- }
- }
-
-
}
+2004-01-19 Duncan Mak <duncan@ximian.com>
+
+ * graphics-path.c (GdipGetPathPoints): Fixed.
+ (GdipCreatePath): Remember to initialize the arrays instead of
+ just setting them to NULL.
+ (GdipGetPathTypes, GdipGetPathPoints): Fix signature.
+
+ * Makefile (local_sources): Add graphics-path.c to the build.
+
+2004-01-13 Duncan Mak <duncan@ximian.com>
+
+ * matrix.c (GdipCreateMatrix): Use gdip_get_status instead of just
+ returning Ok;
+
2004-01-13 Bernie Solomon <bernard@ugsolutions.com>
* graphics-path.c (append): fix struct initialization
* graphics.c restore position in GRAPHICS_STATE stack
* matrix.c order of matrices in GdipMultiplyMatrix changed
* pen.c initialization of fields, protection in GdipDeletePen function added
-
2003-12-25 Duncan Mak <duncan@ximian.com>
brush.o \
general.o \
graphics.o \
+ graphics-path.o \
image.o \
matrix.o \
pen.o \
GpStatus GdipIsMatrixIdentity (GpMatrix *matrix, int *result);
GpStatus GdipIsMatrixEqual (GpMatrix *matrix, GpMatrix *matrix2, int *result);
+/* Path*/
+#include "graphics-path.h"
+
/* Memory */
void *GdipAlloc (int size);
void GdipFree (void *ptr);
return p;
}
-static GpPoint *
-float_to_int (const GpPointF *pts, int count)
-{
- GpPoint *p = (GpPoint *) GdipAlloc (sizeof (GpPoint) * count);
- GpPointF *tmp = (GpPointF *) pts;
- int i;
-
- for (i = 0; i < count; i++, p++, tmp++) {
- p->X = (int) tmp->X;
- p->Y = (int) tmp->Y;
- }
-
- return p;
-}
-
static GpPointF *
int_to_float (const GpPoint *pts, int count)
{
GpPointF pt;
pt.X = x;
pt.Y = y;
+
g_array_append_val (path->points, pt);
g_byte_array_append (path->types, &t, 1);
+ path->count++;
}
static void
append_point (GpPath *path, GpPointF pt, GpPathPointType type)
{
- byte t = (byte) type;
- g_array_append_val (path->points, pt);
- g_byte_array_append (path->types, &t, 1);
+ append (path, pt.X, pt.Y, type);
}
static void
*path = (GpPath *) GdipAlloc (sizeof (GpPath));
(*path)->fill_mode = brushMode;
- (*path)->points = NULL;
- (*path)->types = NULL;
+ (*path)->points = g_array_new (FALSE, FALSE, sizeof (GpPointF));
+ (*path)->types = g_byte_array_new ();
(*path)->count = 0;
return Ok;
}
GpStatus
-GdipGetPathTypes (GpPath *path, byte *types, int *count)
+GdipGetPathTypes (GpPath *path, byte *types, int count)
{
- *count = path->count;
- types = g_byte_array_to_array (path->types);
+ int i;
+
+ for (i = 0; i < count; i++)
+ types [i] = path->types->data [i];
return Ok;
}
GpStatus
-GdipGetPathPoints (GpPath *path, GpPointF *points, int *count)
+GdipGetPathPoints (GpPath *path, GpPointF *points, int count)
{
- *count = path->count;
- points = g_array_to_array (path->points);
-
+ int i;
+
+ for (i = 0; i < count; i++) {
+ GpPointF point = g_array_index (path->points, GpPointF, i);
+ points [i].X = point.X;
+ points [i].Y = point.Y;
+ }
+
return Ok;
}
GpStatus
-GdipGetPathPointsI (GpPath *path, GpPoint *points, int *count)
+GdipGetPathPointsI (GpPath *path, GpPoint *points, int count)
{
- *count = path->count;
- PointF *tmp = g_array_to_array (path->points);
+ int i;
- points = float_to_int (tmp, path->count);
+ for (i = 0; i < count; i++) {
+ GpPoint point = g_array_index (path->points, GpPoint, i);
+ points [i].X = (int) point.X;
+ points [i].Y = (int) point.Y;
+ }
- GdipFree (tmp);
-
return Ok;
}
GpStatus
GdipAddPathBezier (GpPath *path,
- float x1, float y1, float x2, float y2,
- float x3, float y3, float x4, float y4)
+ float x1, float y1, float x2, float y2,
+ float x3, float y3, float x4, float y4)
{
append (path, x1, y1, PathPointTypeStart);
append_bezier (path, x2, y2, x3, y3, x4, y4);
return NotImplemented;
}
-/* XXX: This one is really hard. They really translate a string into bezier points and what not */
+/* XXX: This one is really hard. They really translate a string into
+bezier points and what not */
/*
* GpStatus
* GdipAddString (GpPath *path, const char *string, int length,
- * const GpFontFamily *family, int style, float emSize, const GpRectF *layoutRect,
+ * const GpFontFamily *family, int style, float emSize,
+const GpRectF *layoutRect,
* const GpStringFormat *format)
* {
* return NotImplemented;
/*
* GpStatus
* GdipAddString (GpPath *path, const char *string, int length,
- * const GpFontFamily *family, int style, float emSize, const GpRect *layoutRect,
+ * const GpFontFamily *family, int style, float emSize,
+const GpRect *layoutRect,
* const GpStringFormat *format)
* {
* return NotImplemented;
}
GpStatus
-GdipAddPathCurve3I (GpPath *path, const GpPoint *points,
+GdipAddPathCurve3I (GpPath *path, const GpPoint *points,
int count, int offset, int numberOfSegments, float tension)
{
return NotImplemented;
GpStatus
GdipWarpPath (GpPath *nativePath, GpMatrix *matrix, const GpPointF *points, int count,
- float src, float srcy, float srcwidth, float srcheight, WarpMode warpMode, float flatness)
+ float src, float srcy, float srcwidth, float srcheight,
+ WarpMode warpMode, float flatness)
{
return NotImplemented;
}
{
return NotImplemented;
}
+
+
GpStatus GdipDeletePath (GpPath *path);
GpStatus GdipResetPath (GpPath *path);
GpStatus GdipGetPointCount (GpPath *path, int *count);
-GpStatus GdipGetPathTypes (GpPath *path, byte *types, int *count);
-GpStatus GdipGetPathPoints (GpPath *path, GpPointF *points, int *count);
-GpStatus GdipGetPathPointsI (GpPath *path, GpPoint *points, int *count);
+GpStatus GdipGetPathTypes (GpPath *path, byte *types, int count);
+GpStatus GdipGetPathPoints (GpPath *path, GpPointF *points, int count);
+GpStatus GdipGetPathPointsI (GpPath *path, GpPoint *points, int count);
GpStatus GdipGetPathFillMode (GpPath *path, GpFillMode *fillmode);
GpStatus GdipSetPathFillMode (GpPath *path, GpFillMode fillmode);
GpStatus GdipGetPathData (GpPath *path, GpPathData *pathData);
GdipCreateMatrix (GpMatrix **matrix)
{
*matrix = cairo_matrix_create ();
- cairo_matrix_set_affine (*matrix, 1, 0, 0, 1, 0, 0);
- return Ok;
+
+ return gdip_get_status (
+ cairo_matrix_set_affine (*matrix, 1, 0, 0, 1, 0, 0));
}
GpStatus
return Ok;
}
-static int
+static bool
matrix_equals (GpMatrix *x, GpMatrix *y)
{
double ax, bx, cx, dx, ex, fx;
if ((ax != ay) || (bx != by) || (cx != cy) ||
(dx != dy) || (ex != ey) || (fx != fy))
- return 0;
+ return FALSE;
- return 1;
+ return TRUE;
}
GpStatus