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