/src/FreeRDP/libfreerdp/gdi/gdi.h
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /**  | 
2  |  |  * FreeRDP: A Remote Desktop Protocol Implementation  | 
3  |  |  * GDI Library  | 
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  |  | #ifndef FREERDP_LIB_GDI_CORE_H  | 
21  |  | #define FREERDP_LIB_GDI_CORE_H  | 
22  |  |  | 
23  |  | #include "graphics.h"  | 
24  |  | #include "brush.h"  | 
25  |  |  | 
26  |  | #include <freerdp/api.h>  | 
27  |  |  | 
28  |  | FREERDP_LOCAL BOOL gdi_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate);  | 
29  |  |  | 
30  |  | FREERDP_LOCAL gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, BYTE* data);  | 
31  |  | FREERDP_LOCAL void gdi_bitmap_free_ex(gdiBitmap* gdi_bmp);  | 
32  |  |  | 
33  |  | static INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, INT32 x, INT32 y)  | 
34  | 0  | { | 
35  | 0  |   BYTE* p = NULL;  | 
36  | 0  |   HGDI_BITMAP hBmp = (HGDI_BITMAP)hdcBmp->selectedObject;  | 
37  |  | 
  | 
38  | 0  |   if ((x >= 0) && (y >= 0) && (x < hBmp->width) && (y < hBmp->height))  | 
39  | 0  |   { | 
40  | 0  |     p = hBmp->data + (y * hBmp->scanline) + (x * FreeRDPGetBytesPerPixel(hdcBmp->format));  | 
41  | 0  |     return p;  | 
42  | 0  |   }  | 
43  | 0  |   else  | 
44  | 0  |   { | 
45  | 0  |     WLog_ERR(FREERDP_TAG("gdi"), | 
46  | 0  |              "gdi_get_bitmap_pointer: requesting invalid pointer: (%" PRIu32 ",%" PRIu32  | 
47  | 0  |              ") in %" PRIu32 "x%" PRIu32 "",  | 
48  | 0  |              x, y, hBmp->width, hBmp->height);  | 
49  | 0  |     return 0;  | 
50  | 0  |   }  | 
51  | 0  | } Unexecuted instantiation: bitmap.c:gdi_get_bitmap_pointer Unexecuted instantiation: gdi.c:gdi_get_bitmap_pointer Unexecuted instantiation: shape.c:gdi_get_bitmap_pointer  | 
52  |  |  | 
53  |  | /**  | 
54  |  |  * Get current color in brush bitmap according to dest coordinates. msdn{dd183396} | 
55  |  |  *  | 
56  |  |  * @param x dest x-coordinate  | 
57  |  |  * @param y dest y-coordinate  | 
58  |  |  * @return color pointer  | 
59  |  |  */  | 
60  |  | static INLINE BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)  | 
61  | 0  | { | 
62  | 0  |   BYTE* p = NULL;  | 
63  | 0  |   UINT32 brushStyle = gdi_GetBrushStyle(hdcBrush);  | 
64  |  | 
  | 
65  | 0  |   switch (brushStyle)  | 
66  | 0  |   { | 
67  | 0  |     case GDI_BS_PATTERN:  | 
68  | 0  |     case GDI_BS_HATCHED:  | 
69  | 0  |     { | 
70  | 0  |       HGDI_BITMAP hBmpBrush = hdcBrush->brush->pattern;  | 
71  |  |       /* According to msdn{dd183396}, the system always positions a brush bitmap | 
72  |  |        * at the brush origin and copy across the client area.  | 
73  |  |        * Calculate the offset of the mapped pixel in the brush bitmap according to  | 
74  |  |        * brush origin and dest coordinates */  | 
75  | 0  |       x = (x + hBmpBrush->width - (hdcBrush->brush->nXOrg % hBmpBrush->width)) %  | 
76  | 0  |           hBmpBrush->width;  | 
77  | 0  |       y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %  | 
78  | 0  |           hBmpBrush->height;  | 
79  | 0  |       p = hBmpBrush->data + (y * hBmpBrush->scanline) +  | 
80  | 0  |           (x * FreeRDPGetBytesPerPixel(hBmpBrush->format));  | 
81  | 0  |       return p;  | 
82  | 0  |     }  | 
83  | 0  |     break;  | 
84  |  |  | 
85  | 0  |     default:  | 
86  | 0  |       break;  | 
87  | 0  |   }  | 
88  |  |  | 
89  | 0  |   p = (BYTE*)&(hdcBrush->textColor);  | 
90  | 0  |   return p;  | 
91  | 0  | } Unexecuted instantiation: bitmap.c:gdi_get_brush_pointer Unexecuted instantiation: gdi.c:gdi_get_brush_pointer Unexecuted instantiation: shape.c:gdi_get_brush_pointer  | 
92  |  |  | 
93  |  | #endif /* FREERDP_LIB_GDI_CORE_H */  |