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
25 #include "gdiplus_private.h"
27 GpStatus WINGDIPAPI
GdipCreatePathIter(GpPathIterator
**iterator
, GpPath
* path
)
31 if(!iterator
|| !path
)
32 return InvalidParameter
;
34 size
= path
->pathdata
.Count
;
36 *iterator
= GdipAlloc(sizeof(GpPathIterator
));
37 if(!*iterator
) return OutOfMemory
;
39 (*iterator
)->pathdata
.Types
= GdipAlloc(size
);
40 (*iterator
)->pathdata
.Points
= GdipAlloc(size
* sizeof(PointF
));
42 memcpy((*iterator
)->pathdata
.Types
, path
->pathdata
.Types
, size
);
43 memcpy((*iterator
)->pathdata
.Points
, path
->pathdata
.Points
,
44 size
* sizeof(PointF
));
45 (*iterator
)->pathdata
.Count
= size
;
47 (*iterator
)->subpath_pos
= 0;
48 (*iterator
)->marker_pos
= 0;
49 (*iterator
)->pathtype_pos
= 0;
54 GpStatus WINGDIPAPI
GdipDeletePathIter(GpPathIterator
*iter
)
57 return InvalidParameter
;
59 GdipFree(iter
->pathdata
.Types
);
60 GdipFree(iter
->pathdata
.Points
);
66 GpStatus WINGDIPAPI
GdipPathIterCopyData(GpPathIterator
* iterator
,
67 INT
* resultCount
, GpPointF
* points
, BYTE
* types
, INT startIndex
, INT endIndex
)
69 if(!iterator
|| !types
|| !points
)
70 return InvalidParameter
;
72 if(endIndex
> iterator
->pathdata
.Count
- 1 || startIndex
< 0 ||
73 endIndex
< startIndex
){
78 *resultCount
= endIndex
- startIndex
+ 1;
80 memcpy(types
, &(iterator
->pathdata
.Types
[startIndex
]), *resultCount
);
81 memcpy(points
, &(iterator
->pathdata
.Points
[startIndex
]),
82 *resultCount
* sizeof(PointF
));
87 GpStatus WINGDIPAPI
GdipPathIterNextSubpath(GpPathIterator
* iterator
,
88 INT
*resultCount
, INT
* startIndex
, INT
* endIndex
, BOOL
* isClosed
)
93 return InvalidParameter
;
95 count
= iterator
->pathdata
.Count
;
97 if(iterator
->subpath_pos
== count
){
98 *startIndex
= *endIndex
= *resultCount
= 0;
103 *startIndex
= iterator
->subpath_pos
;
105 for(i
= iterator
->subpath_pos
+ 1; i
< count
&&
106 !(iterator
->pathdata
.Types
[i
] == PathPointTypeStart
); i
++);
109 iterator
->subpath_pos
= i
;
111 *resultCount
= *endIndex
- *startIndex
+ 1;
113 if(iterator
->pathdata
.Types
[*endIndex
] & PathPointTypeCloseSubpath
)
120 GpStatus WINGDIPAPI
GdipPathIterRewind(GpPathIterator
*iterator
)
123 return InvalidParameter
;
125 iterator
->subpath_pos
= 0;
126 iterator
->marker_pos
= 0;
127 iterator
->pathtype_pos
= 0;