2011-10-21 01:28:59 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-10-21 01:28:59 +04:00
|
|
|
* GDI Library
|
|
|
|
*
|
|
|
|
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-06-06 15:01:41 +03:00
|
|
|
#ifndef FREERDP_LIB_GDI_CORE_H
|
|
|
|
#define FREERDP_LIB_GDI_CORE_H
|
2011-10-21 01:28:59 +04:00
|
|
|
|
|
|
|
#include "graphics.h"
|
2016-10-10 12:09:06 +03:00
|
|
|
#include "brush.h"
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2016-08-10 10:12:55 +03:00
|
|
|
#include <freerdp/api.h>
|
2016-07-21 11:07:42 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
FREERDP_LOCAL BOOL gdi_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate);
|
2016-08-10 10:12:55 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
FREERDP_LOCAL gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, BYTE* data);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void gdi_bitmap_free_ex(gdiBitmap* gdi_bmp);
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2018-11-13 19:06:09 +03:00
|
|
|
static INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, INT32 x, INT32 y)
|
2016-10-10 12:09:06 +03:00
|
|
|
{
|
2024-08-27 16:51:48 +03:00
|
|
|
BYTE* p = NULL;
|
2019-11-06 17:24:51 +03:00
|
|
|
HGDI_BITMAP hBmp = (HGDI_BITMAP)hdcBmp->selectedObject;
|
2016-10-10 12:09:06 +03:00
|
|
|
|
2018-11-13 19:06:09 +03:00
|
|
|
if ((x >= 0) && (y >= 0) && (x < hBmp->width) && (y < hBmp->height))
|
2016-10-10 12:09:06 +03:00
|
|
|
{
|
2022-04-28 06:43:31 +03:00
|
|
|
p = hBmp->data + (y * hBmp->scanline) + (x * FreeRDPGetBytesPerPixel(hdcBmp->format));
|
2016-10-10 12:09:06 +03:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_ERR(FREERDP_TAG("gdi"),
|
2019-11-06 17:24:51 +03:00
|
|
|
"gdi_get_bitmap_pointer: requesting invalid pointer: (%" PRIu32 ",%" PRIu32
|
|
|
|
") in %" PRIu32 "x%" PRIu32 "",
|
2016-10-10 12:09:06 +03:00
|
|
|
x, y, hBmp->width, hBmp->height);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-04-28 00:10:49 +03:00
|
|
|
* Get current color in brush bitmap according to dest coordinates. msdn{dd183396}
|
|
|
|
*
|
2016-10-10 12:09:06 +03:00
|
|
|
* @param x dest x-coordinate
|
|
|
|
* @param y dest y-coordinate
|
2022-04-28 00:10:49 +03:00
|
|
|
* @return color pointer
|
2016-10-10 12:09:06 +03:00
|
|
|
*/
|
|
|
|
static INLINE BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
|
|
|
|
{
|
2024-08-27 16:51:48 +03:00
|
|
|
BYTE* p = NULL;
|
2016-10-10 12:09:06 +03:00
|
|
|
UINT32 brushStyle = gdi_GetBrushStyle(hdcBrush);
|
|
|
|
|
|
|
|
switch (brushStyle)
|
|
|
|
{
|
|
|
|
case GDI_BS_PATTERN:
|
|
|
|
case GDI_BS_HATCHED:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
HGDI_BITMAP hBmpBrush = hdcBrush->brush->pattern;
|
2022-12-09 16:35:03 +03:00
|
|
|
/* According to msdn{dd183396}, the system always positions a brush bitmap
|
2019-11-06 17:24:51 +03:00
|
|
|
* at the brush origin and copy across the client area.
|
|
|
|
* Calculate the offset of the mapped pixel in the brush bitmap according to
|
|
|
|
* brush origin and dest coordinates */
|
|
|
|
x = (x + hBmpBrush->width - (hdcBrush->brush->nXOrg % hBmpBrush->width)) %
|
|
|
|
hBmpBrush->width;
|
|
|
|
y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %
|
|
|
|
hBmpBrush->height;
|
|
|
|
p = hBmpBrush->data + (y * hBmpBrush->scanline) +
|
2022-04-28 06:43:31 +03:00
|
|
|
(x * FreeRDPGetBytesPerPixel(hBmpBrush->format));
|
2019-11-06 17:24:51 +03:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
break;
|
2016-10-10 12:09:06 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
p = (BYTE*)&(hdcBrush->textColor);
|
2016-10-10 12:09:06 +03:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2017-06-06 15:01:41 +03:00
|
|
|
#endif /* FREERDP_LIB_GDI_CORE_H */
|