Blame libfreerdp/gdi/gdi.h

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