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
|
|
|
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL BOOL gdi_bitmap_update(rdpContext* context,
|
|
|
|
const BITMAP_UPDATE* bitmapUpdate);
|
|
|
|
|
|
|
|
FREERDP_LOCAL gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height,
|
|
|
|
int bpp,
|
|
|
|
BYTE* data);
|
|
|
|
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
|
|
|
{
|
|
|
|
BYTE* p;
|
|
|
|
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdcBmp->selectedObject;
|
|
|
|
|
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
|
|
|
{
|
|
|
|
p = hBmp->data + (y * hBmp->scanline) + (x * GetBytesPerPixel(hdcBmp->format));
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_ERR(FREERDP_TAG("gdi"),
|
2016-12-14 00:47:08 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get current color in brush bitmap according to dest coordinates.\n
|
|
|
|
* @msdn{dd183396}
|
|
|
|
* @param x dest x-coordinate
|
|
|
|
* @param y dest y-coordinate
|
|
|
|
* @return color
|
|
|
|
*/
|
|
|
|
static INLINE BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
|
|
|
|
{
|
|
|
|
BYTE* p;
|
|
|
|
UINT32 brushStyle = gdi_GetBrushStyle(hdcBrush);
|
|
|
|
|
|
|
|
switch (brushStyle)
|
|
|
|
{
|
|
|
|
case GDI_BS_PATTERN:
|
|
|
|
case GDI_BS_HATCHED:
|
|
|
|
{
|
|
|
|
HGDI_BITMAP hBmpBrush = hdcBrush->brush->pattern;
|
|
|
|
/* According to @msdn{dd183396}, the system always positions a brush bitmap
|
|
|
|
* 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) + (x * GetBytesPerPixel(
|
|
|
|
hBmpBrush->format));
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = (BYTE*) & (hdcBrush->textColor);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2017-06-06 15:01:41 +03:00
|
|
|
#endif /* FREERDP_LIB_GDI_CORE_H */
|