/src/FreeRDP/libfreerdp/gdi/drawing.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * FreeRDP: A Remote Desktop Protocol Implementation |
3 | | * GDI Drawing Functions |
4 | | * |
5 | | * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com> |
6 | | * Copyright 2016 Armin Novak <armin.novak@thincast.com> |
7 | | * Copyright 2016 Thincast Technologies GmbH |
8 | | * |
9 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
10 | | * you may not use this file except in compliance with the License. |
11 | | * You may obtain a copy of the License at |
12 | | * |
13 | | * http://www.apache.org/licenses/LICENSE-2.0 |
14 | | * |
15 | | * Unless required by applicable law or agreed to in writing, software |
16 | | * distributed under the License is distributed on an "AS IS" BASIS, |
17 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
18 | | * See the License for the specific language governing permissions and |
19 | | * limitations under the License. |
20 | | */ |
21 | | |
22 | | /* GDI Drawing Functions: http://msdn.microsoft.com/en-us/library/dd162760/ */ |
23 | | |
24 | | #include <freerdp/config.h> |
25 | | |
26 | | #include <stdio.h> |
27 | | #include <string.h> |
28 | | #include <stdlib.h> |
29 | | |
30 | | #include <freerdp/freerdp.h> |
31 | | #include <freerdp/gdi/gdi.h> |
32 | | |
33 | | #include <freerdp/gdi/dc.h> |
34 | | #include "drawing.h" |
35 | | |
36 | | /** |
37 | | * @brief Set current foreground draw mode. |
38 | | * msdn{dd144922} |
39 | | * |
40 | | * @param hdc device context |
41 | | * |
42 | | * @return draw mode |
43 | | */ |
44 | | |
45 | | INT32 gdi_GetROP2(HGDI_DC hdc) |
46 | 0 | { |
47 | 0 | return hdc->drawMode; |
48 | 0 | } |
49 | | |
50 | | /** |
51 | | * @brief Set current foreground draw mode. |
52 | | * msdn{dd145088} |
53 | | * |
54 | | * @param hdc device context |
55 | | * @param fnDrawMode draw mode |
56 | | * |
57 | | * @return previous draw mode |
58 | | */ |
59 | | |
60 | | INT32 gdi_SetROP2(HGDI_DC hdc, INT32 fnDrawMode) |
61 | 0 | { |
62 | 0 | INT32 prevDrawMode = hdc->drawMode; |
63 | |
|
64 | 0 | if (fnDrawMode > 0 && fnDrawMode <= 16) |
65 | 0 | hdc->drawMode = fnDrawMode; |
66 | |
|
67 | 0 | return prevDrawMode; |
68 | 0 | } |
69 | | |
70 | | /** |
71 | | * @brief Get the current background color. |
72 | | * msdn{dd144852} |
73 | | * |
74 | | * @param hdc device context |
75 | | * |
76 | | * @return background color |
77 | | */ |
78 | | |
79 | | UINT32 gdi_GetBkColor(HGDI_DC hdc) |
80 | 0 | { |
81 | 0 | return hdc->bkColor; |
82 | 0 | } |
83 | | |
84 | | /** |
85 | | * @brief Set the current background color. |
86 | | * msdn{dd162964} |
87 | | * |
88 | | * @param hdc device color |
89 | | * @param crColor new background color |
90 | | * |
91 | | * @return previous background color |
92 | | */ |
93 | | |
94 | | UINT32 gdi_SetBkColor(HGDI_DC hdc, UINT32 crColor) |
95 | 0 | { |
96 | 0 | UINT32 previousBkColor = hdc->bkColor; |
97 | 0 | hdc->bkColor = crColor; |
98 | 0 | return previousBkColor; |
99 | 0 | } |
100 | | |
101 | | /** |
102 | | * @brief Get the current background mode. |
103 | | * msdn{dd144853} |
104 | | * |
105 | | * @param hdc device context |
106 | | * |
107 | | * @return background mode |
108 | | */ |
109 | | |
110 | | INT32 gdi_GetBkMode(HGDI_DC hdc) |
111 | 0 | { |
112 | 0 | return hdc->bkMode; |
113 | 0 | } |
114 | | |
115 | | /** |
116 | | * @brief Set the current background mode. |
117 | | * msdn{dd162965} |
118 | | * |
119 | | * @param hdc device context |
120 | | * @param iBkMode background mode |
121 | | * |
122 | | * @return previous background mode on success, 0 on failure |
123 | | */ |
124 | | |
125 | | INT32 gdi_SetBkMode(HGDI_DC hdc, INT32 iBkMode) |
126 | 0 | { |
127 | 0 | if (iBkMode == GDI_OPAQUE || iBkMode == GDI_TRANSPARENT) |
128 | 0 | { |
129 | 0 | INT32 previousBkMode = hdc->bkMode; |
130 | 0 | hdc->bkMode = iBkMode; |
131 | 0 | return previousBkMode; |
132 | 0 | } |
133 | | |
134 | 0 | return TRUE; |
135 | 0 | } |
136 | | |
137 | | /** @brief Set the current text color. |
138 | | * https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-settextcolor |
139 | | * |
140 | | * @param hdc device context |
141 | | * @param crColor new text color |
142 | | * |
143 | | * @return previous text color |
144 | | */ |
145 | | |
146 | | UINT32 gdi_SetTextColor(HGDI_DC hdc, UINT32 crColor) |
147 | 0 | { |
148 | 0 | UINT32 previousTextColor = hdc->textColor; |
149 | 0 | hdc->textColor = crColor; |
150 | 0 | return previousTextColor; |
151 | 0 | } |