2 * Copyright (C) 2007 Google (Evan Stade)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "gdiplus_private.h"
30 GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
34 if(!iterator || !path)
35 return InvalidParameter;
37 size = path->pathdata.Count;
39 *iterator = GdipAlloc(sizeof(GpPathIterator));
40 if(!*iterator) return OutOfMemory;
42 (*iterator)->pathdata.Types = GdipAlloc(size);
43 (*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
45 memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
46 memcpy((*iterator)->pathdata.Points, path->pathdata.Points,
47 size * sizeof(PointF));
48 (*iterator)->pathdata.Count = size;
50 (*iterator)->subpath_pos = 0;
51 (*iterator)->marker_pos = 0;
52 (*iterator)->pathtype_pos = 0;
57 GpStatus WINGDIPAPI GdipDeletePathIter(GpPathIterator *iter)
60 return InvalidParameter;
62 GdipFree(iter->pathdata.Types);
63 GdipFree(iter->pathdata.Points);
69 GpStatus WINGDIPAPI GdipPathIterCopyData(GpPathIterator* iterator,
70 INT* resultCount, GpPointF* points, BYTE* types, INT startIndex, INT endIndex)
72 if(!iterator || !types || !points)
73 return InvalidParameter;
75 if(endIndex > iterator->pathdata.Count - 1 || startIndex < 0 ||
76 endIndex < startIndex){
81 *resultCount = endIndex - startIndex + 1;
83 memcpy(types, &(iterator->pathdata.Types[startIndex]), *resultCount);
84 memcpy(points, &(iterator->pathdata.Points[startIndex]),
85 *resultCount * sizeof(PointF));
90 GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator,
91 INT *resultCount, INT* startIndex, INT* endIndex, BOOL* isClosed)
96 return InvalidParameter;
98 count = iterator->pathdata.Count;
100 if(iterator->subpath_pos == count){
101 *startIndex = *endIndex = *resultCount = 0;
106 *startIndex = iterator->subpath_pos;
108 for(i = iterator->subpath_pos + 1; i < count &&
109 !(iterator->pathdata.Types[i] == PathPointTypeStart); i++);
112 iterator->subpath_pos = i;
114 *resultCount = *endIndex - *startIndex + 1;
116 if(iterator->pathdata.Types[*endIndex] & PathPointTypeCloseSubpath)
123 GpStatus WINGDIPAPI GdipPathIterRewind(GpPathIterator *iterator)
126 return InvalidParameter;
128 iterator->subpath_pos = 0;
129 iterator->marker_pos = 0;
130 iterator->pathtype_pos = 0;