Coverage Report

Created: 2025-07-01 06:46

/src/FreeRDP/libfreerdp/gdi/pen.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * FreeRDP: A Remote Desktop Protocol Implementation
3
 * GDI Pen Functions
4
 *
5
 * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
 *
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
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
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.
18
 */
19
20
/* GDI Pen Functions: http://msdn.microsoft.com/en-us/library/dd162790 */
21
22
#include <freerdp/config.h>
23
24
#include <stdio.h>
25
#include <stdlib.h>
26
27
#include <freerdp/api.h>
28
#include <freerdp/freerdp.h>
29
#include <freerdp/gdi/gdi.h>
30
31
#include <freerdp/gdi/pen.h>
32
33
/**
34
 * @brief Create a new pen.
35
 * msdn{dd183509}
36
 *
37
 * @param fnPenStyle pen style
38
 * @param nWidth pen width
39
 * @param crColor pen color
40
 * @param format the color format
41
 * @param palette A pointer to a color palette
42
 *
43
 * @return new pen
44
 */
45
46
HGDI_PEN gdi_CreatePen(UINT32 fnPenStyle, UINT32 nWidth, UINT32 crColor, UINT32 format,
47
                       const gdiPalette* palette)
48
0
{
49
0
  HGDI_PEN hPen = (HGDI_PEN)calloc(1, sizeof(GDI_PEN));
50
0
  if (!hPen)
51
0
    return NULL;
52
0
  hPen->objectType = GDIOBJECT_PEN;
53
0
  hPen->style = fnPenStyle;
54
0
  hPen->color = crColor;
55
0
  WINPR_ASSERT(nWidth <= INT32_MAX);
56
0
  hPen->width = (int)nWidth;
57
0
  hPen->format = format;
58
0
  hPen->palette = palette;
59
0
  return hPen;
60
0
}
61
62
UINT32 gdi_GetPenColor(HGDI_PEN pen, UINT32 format)
63
0
{
64
0
  return FreeRDPConvertColor(pen->color, pen->format, format, pen->palette);
65
0
}