2 * FreeRDP: A Remote Desktop Protocol Client
5 * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
24 #include <freerdp/freerdp.h>
25 #include <freerdp/gdi/gdi.h>
27 #include <freerdp/gdi/32bpp.h>
28 #include <freerdp/gdi/16bpp.h>
29 #include <freerdp/gdi/8bpp.h>
31 #include <freerdp/gdi/line.h>
43 * Draw a line from the current position to the given position.\n
45 * @param hdc device context
46 * @param nXEnd ending x position
47 * @param nYEnd ending y position
48 * @return 1 if successful, 0 otherwise
51 int gdi_LineTo(HGDI_DC hdc, int nXEnd, int nYEnd)
53 p_LineTo _LineTo = LineTo_[IBPP(hdc->bitsPerPixel)];
56 return _LineTo(hdc, nXEnd, nYEnd);
62 * Draw one or more straight lines
63 * @param hdc device context
64 * @param lppt array of points
65 * @param cCount number of points
68 int gdi_PolylineTo(HGDI_DC hdc, GDI_POINT *lppt, int cCount)
72 for (i = 0; i < cCount; i++)
74 gdi_LineTo(hdc, lppt[i].x, lppt[i].y);
75 gdi_MoveToEx(hdc, lppt[i].x, lppt[i].y, NULL);
82 * Draw one or more straight lines
83 * @param hdc device context
84 * @param lppt array of points
85 * @param cPoints number of points
88 int gdi_Polyline(HGDI_DC hdc, GDI_POINT *lppt, int cPoints)
95 gdi_MoveToEx(hdc, lppt[0].x, lppt[0].y, &pt);
97 for (i = 0; i < cPoints; i++)
99 gdi_LineTo(hdc, lppt[i].x, lppt[i].y);
100 gdi_MoveToEx(hdc, lppt[i].x, lppt[i].y, NULL);
103 gdi_MoveToEx(hdc, pt.x, pt.y, NULL);
110 * Draw multiple series of connected line segments
111 * @param hdc device context
112 * @param lppt array of points
113 * @param lpdwPolyPoints array of numbers of points per series
114 * @param cCount count of entries in lpdwPolyPoints
117 int gdi_PolyPolyline(HGDI_DC hdc, GDI_POINT *lppt, int *lpdwPolyPoints, int cCount)
122 for (i = 0; i < cCount; i++)
124 cPoints = lpdwPolyPoints[i];
125 gdi_Polyline(hdc, &lppt[j], cPoints);
133 * Move pen from the current device context to a new position.
134 * @param hdc device context
135 * @param X x position
136 * @param Y y position
137 * @return 1 if successful, 0 otherwise
140 int gdi_MoveToEx(HGDI_DC hdc, int X, int Y, HGDI_POINT lpPoint)
144 lpPoint->x = hdc->pen->posX;
145 lpPoint->y = hdc->pen->posY;