Пример #1
0
void rf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
{
#ifdef RF_BITMAP
	UINT8* data;
	Pixmap pixmap;
	XImage* image;
	rfContext* rfi = (rfContext*) context;

	XSetFunction(rfi->display, rfi->gc, GXcopy);
	pixmap = XCreatePixmap(rfi->display, rfi->drawable, bitmap->width, bitmap->height, rfi->depth);

	if (bitmap->data != NULL)
	{
		data = freerdp_image_convert(bitmap->data, NULL,
				bitmap->width, bitmap->height, rfi->srcBpp, rfi->bpp, rfi->clrconv);

		if (bitmap->ephemeral != TRUE)
		{
			image = XCreateImage(rfi->display, rfi->visual, rfi->depth,
				ZPixmap, 0, (char*) data, bitmap->width, bitmap->height, rfi->scanline_pad, 0);

			XPutImage(rfi->display, pixmap, rfi->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height);
			XFree(image);

			if (data != bitmap->data) && (data != NULL)
				free(data);
		}
Пример #2
0
HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, uint8* data)
{
	HDC hdc;
	int negHeight;
	HBITMAP bitmap;
	BITMAPINFO bmi;
	uint8* cdata = NULL;

	/**
	 * See: http://msdn.microsoft.com/en-us/library/dd183376
	 * if biHeight is positive, the bitmap is bottom-up
	 * if biHeight is negative, the bitmap is top-down
	 * Since we get top-down bitmaps, let's keep it that way
	 */

	negHeight = (height < 0) ? height : height * (-1);

	hdc = GetDC(NULL);
	bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
	bmi.bmiHeader.biWidth = width;
	bmi.bmiHeader.biHeight = negHeight;
	bmi.bmiHeader.biPlanes = 1;
	bmi.bmiHeader.biBitCount = 24;
	bmi.bmiHeader.biCompression = BI_RGB;
	bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &cdata, NULL, 0);

	if (data != NULL)
		freerdp_image_convert(data, cdata, width, height, bpp, 24, wfi->clrconv);

	ReleaseDC(NULL, hdc);
	GdiFlush();

	return bitmap;
}
Пример #3
0
void xf_gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap)
{
	int i;
	int x, y;
	int w, h;
	uint8* data;
	XImage* image;
	rdpBitmap* bmp;
	xfInfo* xfi = GET_XFI(update);

	for (i = 0; i < bitmap->number; i++)
	{
		bmp = &bitmap->bitmaps[i];

		data = freerdp_image_convert(bmp->dstData, NULL, bmp->width, bmp->height, bmp->bpp, xfi->bpp, xfi->clrconv);

		image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
				ZPixmap, 0, (char*) data, bmp->width, bmp->height, xfi->scanline_pad, 0);

		x = bmp->left;
		y = bmp->top;
		w = bmp->right - bmp->left + 1;
		h = bmp->bottom - bmp->top + 1;

		XPutImage(xfi->display, xfi->primary, xfi->gc, image, 0, 0, x, y, w, h);

		if (xfi->remote_app != True)
			XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w, h, x, y);

		gdi_InvalidateRegion(xfi->hdc, x, y, w, h);
	}
}
Пример #4
0
void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) {

    /* Convert image data if present */
    if (bitmap->data != NULL) {

        /* Get client data */
        guac_client* client = ((rdp_freerdp_context*) context)->client;
        rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;

        /* Convert image data to 32-bit RGB */
        unsigned char* image_buffer = freerdp_image_convert(bitmap->data, NULL,
                bitmap->width, bitmap->height,
                client_data->settings.color_depth,
                32, ((rdp_freerdp_context*) context)->clrconv);

        /* Free existing image, if any */
        if (image_buffer != bitmap->data)
            free(bitmap->data);

        /* Store converted image in bitmap */
        bitmap->data = image_buffer;

    }

    /* No corresponding layer yet - caching is deferred. */
    ((guac_rdp_bitmap*) bitmap)->layer = NULL;

    /* Start at zero usage */
    ((guac_rdp_bitmap*) bitmap)->used = 0;

}
Пример #5
0
void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) {

    /* Convert image data if present */
    if (bitmap->data != NULL && bitmap->bpp != 32) {

        /* Convert image data to 32-bit RGB */
        unsigned char* image_buffer = freerdp_image_convert(bitmap->data, NULL,
                bitmap->width, bitmap->height,
                guac_rdp_get_depth(context->instance),
                32, ((rdp_freerdp_context*) context)->clrconv);

        /* Free existing image, if any */
        if (image_buffer != bitmap->data) {
#ifdef FREERDP_BITMAP_REQUIRES_ALIGNED_MALLOC
            _aligned_free(bitmap->data);
#else
            free(bitmap->data);
#endif
        }

        /* Store converted image in bitmap */
        bitmap->data = image_buffer;

    }

    /* No corresponding surface yet - caching is deferred. */
    ((guac_rdp_bitmap*) bitmap)->buffer = NULL;
    ((guac_rdp_bitmap*) bitmap)->surface = NULL;

    /* Start at zero usage */
    ((guac_rdp_bitmap*) bitmap)->used = 0;

}
Пример #6
0
Pixmap xf_brush_new(xfInfo* xfi, int width, int height, int bpp, BYTE* data)
{
	Pixmap bitmap;
	BYTE* cdata;
	XImage* image;

	bitmap = XCreatePixmap(xfi->display, xfi->drawable, width, height, xfi->depth);

	if (data != NULL)
	{
		GC gc;

		cdata = freerdp_image_convert(data, NULL, width, height, bpp, xfi->bpp, xfi->clrconv);

		image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
						ZPixmap, 0, (char*) cdata, width, height, xfi->scanline_pad, 0);

		gc = XCreateGC(xfi->display, xfi->drawable, 0, NULL);
		XPutImage(xfi->display, bitmap, gc, image, 0, 0, 0, 0, width, height);
		XFree(image);

		if (cdata != data)
			free(cdata);

		XFreeGC(xfi->display, gc);
	}

	return bitmap;
}
Пример #7
0
void xf_bitmap_new(rdpUpdate* update, xfBitmap* bitmap)
{
	uint8* cdata;
	XImage* image;
	rdpBitmap* _bitmap;
	xfInfo* xfi = GET_XFI(update);

	_bitmap = (rdpBitmap*) &bitmap->bitmap;
	bitmap->pixmap = XCreatePixmap(xfi->display, xfi->drawable, _bitmap->width, _bitmap->height, xfi->depth);

	if (_bitmap->dstData != NULL)
	{
		cdata = freerdp_image_convert(_bitmap->dstData, NULL,
				_bitmap->width, _bitmap->height, _bitmap->bpp, xfi->bpp, xfi->clrconv);

		image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
				ZPixmap, 0, (char*) cdata, _bitmap->width, _bitmap->height, xfi->scanline_pad, 0);

		XPutImage(xfi->display, bitmap->pixmap, xfi->gc, image, 0, 0, 0, 0, _bitmap->width, _bitmap->height);
		XFree(image);

		if (cdata != _bitmap->dstData)
			xfree(cdata);
	}
}
Пример #8
0
HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, int width, int height, int bpp, uint8* data)
{
	uint8* bmpData;
	HGDI_BITMAP bitmap;

	bmpData = freerdp_image_convert(data, NULL, width, height, gdi->srcBpp, bpp, gdi->clrconv);
	bitmap = gdi_CreateBitmap(width, height, gdi->dstBpp, bmpData);

	return bitmap;
}
Пример #9
0
void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
{
	BYTE* data;
	Pixmap pixmap;
	XImage* image;
	xfContext* xfc = (xfContext*) context;

	xf_lock_x11(xfc, FALSE);

	XSetFunction(xfc->display, xfc->gc, GXcopy);
	pixmap = XCreatePixmap(xfc->display, xfc->drawable, bitmap->width, bitmap->height, xfc->depth);

	if (bitmap->data)
	{
		data = freerdp_image_convert(bitmap->data, NULL,
				bitmap->width, bitmap->height, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);

		if (bitmap->ephemeral != TRUE)
		{
			image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
				ZPixmap, 0, (char*) data, bitmap->width, bitmap->height, xfc->scanline_pad, 0);

			XPutImage(xfc->display, pixmap, xfc->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height);
			XFree(image);

			if (data != bitmap->data)
				_aligned_free(data);
		}
		else
		{
			if (data != bitmap->data)
				_aligned_free(bitmap->data);

			bitmap->data = data;
		}
	}

	((xfBitmap*) bitmap)->pixmap = pixmap;

	xf_unlock_x11(xfc, FALSE);
}
Пример #10
0
Pixmap xf_bitmap_new(xfInfo* xfi, int width, int height, int bpp, uint8* data)
{
	Pixmap bitmap;
	uint8* cdata;
	XImage* image;

	bitmap = XCreatePixmap(xfi->display, xfi->drawable, width, height, xfi->bpp);

	cdata = freerdp_image_convert(data, NULL, width, height, bpp, xfi->bpp, xfi->clrconv);

	image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
			ZPixmap, 0, (char *) cdata, width, height, xfi->scanline_pad, 0);

	XPutImage(xfi->display, bitmap, xfi->gc, image, 0, 0, 0, 0, width, height);
	XFree(image);

	if (cdata != data)
		xfree(cdata);

	return bitmap;
}
Пример #11
0
void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
{
	uint8* data;
	Pixmap pixmap;
	XImage* image;
	xfInfo* xfi = ((xfContext*) context)->xfi;

	XSetFunction(xfi->display, xfi->gc, GXcopy);
	pixmap = XCreatePixmap(xfi->display, xfi->drawable, bitmap->width, bitmap->height, xfi->depth);

	if (bitmap->data != NULL)
	{
		data = freerdp_image_convert(bitmap->data, NULL,
				bitmap->width, bitmap->height, bitmap->bpp, xfi->bpp, xfi->clrconv);

		if (bitmap->ephemeral != true)
		{
			image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
				ZPixmap, 0, (char*) data, bitmap->width, bitmap->height, xfi->scanline_pad, 0);

			XPutImage(xfi->display, pixmap, xfi->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height);
			XFree(image);

			if (data != bitmap->data)
				xfree(data);
		}
		else
		{
			if (data != bitmap->data)
				xfree(bitmap->data);
			
			bitmap->data = data;
		}
	}

	((xfBitmap*) bitmap)->pixmap = pixmap;
}
Пример #12
0
void wf_gdi_surface_bits(wfContext* wfc, SURFACE_BITS_COMMAND* surface_bits_command)
{
	int i, j;
	int tx, ty;
	char* tile_bitmap;
	RFX_MESSAGE* message;
	BITMAPINFO bitmap_info;

	RFX_CONTEXT* rfx_context = (RFX_CONTEXT*) wfc->rfx_context;
	NSC_CONTEXT* nsc_context = (NSC_CONTEXT*) wfc->nsc_context;

	tile_bitmap = (char*) malloc(32);
	ZeroMemory(tile_bitmap, 32);

	if (surface_bits_command->codecID == RDP_CODEC_ID_REMOTEFX)
	{
		message = rfx_process_message(rfx_context, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);

		/* blit each tile */
		for (i = 0; i < message->numTiles; i++)
		{
			tx = message->tiles[i]->x + surface_bits_command->destLeft;
			ty = message->tiles[i]->y + surface_bits_command->destTop;

			freerdp_image_convert(message->tiles[i]->data, wfc->tile->pdata, 64, 64, 32, 32, wfc->clrconv);

			for (j = 0; j < message->numRects; j++)
			{
				wf_set_clip_rgn(wfc,
					surface_bits_command->destLeft + message->rects[j].x,
					surface_bits_command->destTop + message->rects[j].y,
					message->rects[j].width, message->rects[j].height);

				BitBlt(wfc->primary->hdc, tx, ty, 64, 64, wfc->tile->hdc, 0, 0, SRCCOPY);
			}
		}

		wf_set_null_clip_rgn(wfc);

		/* invalidate regions */
		for (i = 0; i < message->numRects; i++)
		{
			tx = surface_bits_command->destLeft + message->rects[i].x;
			ty = surface_bits_command->destTop + message->rects[i].y;
			wf_invalidate_region(wfc, tx, ty, message->rects[i].width, message->rects[i].height);
		}

		rfx_message_free(rfx_context, message);
	}
	else if (surface_bits_command->codecID == RDP_CODEC_ID_NSCODEC)
	{
		nsc_process_message(nsc_context, surface_bits_command->bpp, surface_bits_command->width, surface_bits_command->height,
			surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);
		ZeroMemory(&bitmap_info, sizeof(bitmap_info));
		bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		bitmap_info.bmiHeader.biWidth = surface_bits_command->width;
		bitmap_info.bmiHeader.biHeight = surface_bits_command->height;
		bitmap_info.bmiHeader.biPlanes = 1;
		bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
		bitmap_info.bmiHeader.biCompression = BI_RGB;
		SetDIBitsToDevice(wfc->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
			surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
			nsc_context->BitmapData, &bitmap_info, DIB_RGB_COLORS);
		wf_invalidate_region(wfc, surface_bits_command->destLeft, surface_bits_command->destTop,
			surface_bits_command->width, surface_bits_command->height);
	}
	else if (surface_bits_command->codecID == RDP_CODEC_ID_NONE)
	{
		ZeroMemory(&bitmap_info, sizeof(bitmap_info));
		bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		bitmap_info.bmiHeader.biWidth = surface_bits_command->width;
		bitmap_info.bmiHeader.biHeight = surface_bits_command->height;
		bitmap_info.bmiHeader.biPlanes = 1;
		bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
		bitmap_info.bmiHeader.biCompression = BI_RGB;
		SetDIBitsToDevice(wfc->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
			surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
			surface_bits_command->bitmapData, &bitmap_info, DIB_RGB_COLORS);
		wf_invalidate_region(wfc, surface_bits_command->destLeft, surface_bits_command->destTop,
			surface_bits_command->width, surface_bits_command->height);
	}
	else
	{
		fprintf(stderr, "Unsupported codecID %d\n", surface_bits_command->codecID);
	}

	if (tile_bitmap != NULL)
		free(tile_bitmap);
}
Пример #13
0
int TestGdiLine(int argc, char* argv[])
{
	HGDI_DC hdc;
	HGDI_PEN pen;
	BYTE* data;
	HGDI_BITMAP hBmp;
	HGDI_BITMAP hBmp_LineTo_1;
	HGDI_BITMAP hBmp_LineTo_2;
	HGDI_BITMAP hBmp_LineTo_3;
	HGDI_BITMAP hBmp_LineTo_4;
	HGDI_BITMAP hBmp_LineTo_5;
	HGDI_BITMAP hBmp_LineTo_6;
	HGDI_BITMAP hBmp_LineTo_7;
	HGDI_BITMAP hBmp_LineTo_8;
	HGDI_BITMAP hBmp_LineTo_9;
	HGDI_BITMAP hBmp_LineTo_10;
	HGDI_BITMAP hBmp_LineTo_11;
	HGDI_BITMAP hBmp_LineTo_R2_BLACK;
	HGDI_BITMAP hBmp_LineTo_R2_NOTMERGEPEN;
	HGDI_BITMAP hBmp_LineTo_R2_MASKNOTPEN;
	HGDI_BITMAP hBmp_LineTo_R2_NOTCOPYPEN;
	HGDI_BITMAP hBmp_LineTo_R2_MASKPENNOT;
	HGDI_BITMAP hBmp_LineTo_R2_NOT;
	HGDI_BITMAP hBmp_LineTo_R2_XORPEN;
	HGDI_BITMAP hBmp_LineTo_R2_NOTMASKPEN;
	HGDI_BITMAP hBmp_LineTo_R2_MASKPEN;
	HGDI_BITMAP hBmp_LineTo_R2_NOTXORPEN;
	HGDI_BITMAP hBmp_LineTo_R2_NOP;
	HGDI_BITMAP hBmp_LineTo_R2_MERGENOTPEN;
	HGDI_BITMAP hBmp_LineTo_R2_COPYPEN;
	HGDI_BITMAP hBmp_LineTo_R2_MERGEPENNOT;
	HGDI_BITMAP hBmp_LineTo_R2_MERGEPEN;
	HGDI_BITMAP hBmp_LineTo_R2_WHITE;
	rdpPalette* hPalette;
	HCLRCONV clrconv;
	int bitsPerPixel = 8;
	int bytesPerPixel = 1;

	hdc = gdi_GetDC();
	hdc->bitsPerPixel = bitsPerPixel;
	hdc->bytesPerPixel = bytesPerPixel;
	gdi_SetNullClipRgn(hdc);

	pen = gdi_CreatePen(1, 1, 0);
	gdi_SelectObject(hdc, (HGDIOBJECT) pen);

	hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16);
	gdi_SelectObject(hdc, (HGDIOBJECT) hBmp);

	hPalette = (rdpPalette*) gdi_GetSystemPalette();

	clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
	clrconv->alpha = 1;
	clrconv->invert = 0;
	clrconv->palette = hPalette;

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_1, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_1 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_2, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_2 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_3, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_3 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_4, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_4 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_5, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_5 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_5, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_5 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_6, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_6 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_7, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_7 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_8, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_8 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_9, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_9 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_10, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_10 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_11, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_11 = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_BLACK, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_BLACK = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTMERGEPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOTMERGEPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKNOTPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MASKNOTPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTCOPYPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOTCOPYPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKPENNOT, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MASKPENNOT = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOT, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOT = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_XORPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_XORPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTMASKPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOTMASKPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MASKPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTXORPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOTXORPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOP, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_NOP = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGENOTPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MERGENOTPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_COPYPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_COPYPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGEPENNOT, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MERGEPENNOT = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGEPEN, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_MERGEPEN = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_WHITE, NULL, 16, 16, 8, bitsPerPixel, clrconv);
	hBmp_LineTo_R2_WHITE = gdi_CreateBitmap(16, 16, bitsPerPixel, data);

	/* Test Case 1: (0,0) -> (15, 15) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_LineTo(hdc, 15, 15);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_1, "Case 1") < 0)
		return -1;

	/* Test Case 2: (15,15) -> (0,0) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 15, 15, NULL);
	gdi_LineTo(hdc, 0, 0);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_2, "Case 2") < 0)
		return -1;

	/* Test Case 3: (15,0) -> (0,15) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 15, 0, NULL);
	gdi_LineTo(hdc, 0, 15);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_3, "Case 3") < 0)
		return -1;

	/* Test Case 4: (0,15) -> (15,0) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 0, 15, NULL);
	gdi_LineTo(hdc, 15, 0);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_4, "Case 4") < 0)
		return -1;

	/* Test Case 5: (0,8) -> (15,8) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 0, 8, NULL);
	gdi_LineTo(hdc, 15, 8);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_5, "Case 5") < 0)
		return -1;

	/* Test Case 6: (15,8) -> (0,8) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 15, 8, NULL);
	gdi_LineTo(hdc, 0, 8);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_6, "Case 6") < 0)
		return -1;

	/* Test Case 7: (8,0) -> (8,15) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 8, 0, NULL);
	gdi_LineTo(hdc, 8, 15);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_7, "Case 7") < 0)
		return -1;

	/* Test Case 8: (8,15) -> (8,0) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 8, 15, NULL);
	gdi_LineTo(hdc, 8, 0);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_8, "Case 8") < 0)
		return -1;

	/* Test Case 9: (4,4) -> (12,12) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 4, 4, NULL);
	gdi_LineTo(hdc, 12, 12);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_9, "Case 9") < 0)
		return -1;

	/* Test Case 10: (12,12) -> (4,4) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_MoveToEx(hdc, 12, 12, NULL);
	gdi_LineTo(hdc, 4, 4);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_10, "Case 10") < 0)
		return -1;

	/* Test Case 11: (0,0) -> (+10,+10) */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_LineTo(hdc, 16 + 10, 16 + 10);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_11, "Case 11") < 0)
		return -1;

	/* Test Case 12: (0,0) -> (16,16), R2_BLACK */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_BLACK);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_BLACK, "Case 12") < 0)
		return -1;

	/* Test Case 13: (0,0) -> (16,16), R2_NOTMERGEPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOTMERGEPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTMERGEPEN, "Case 13") < 0)
		return -1;

	/* Test Case 14: (0,0) -> (16,16), R2_MASKNOTPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MASKNOTPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKNOTPEN, "Case 14") < 0)
		return -1;

	/* Test Case 15: (0,0) -> (16,16), R2_NOTCOPYPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOTCOPYPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTCOPYPEN, "Case 15") < 0)
		return -1;

	/* Test Case 16: (0,0) -> (16,16), R2_MASKPENNOT */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MASKPENNOT);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKPENNOT, "Case 16") < 0)
		return -1;

	/* Test Case 17: (0,0) -> (16,16), R2_NOT */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOT);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOT, "Case 17") < 0)
		return -1;

	/* Test Case 18: (0,0) -> (16,16), R2_XORPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_XORPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_XORPEN, "Case 18") < 0)
		return -1;

	/* Test Case 19: (0,0) -> (16,16), R2_NOTMASKPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOTMASKPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTMASKPEN, "Case 19") < 0)
		return -1;

	/* Test Case 20: (0,0) -> (16,16), R2_MASKPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MASKPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKPEN, "Case 20") < 0)
		return -1;

	/* Test Case 21: (0,0) -> (16,16), R2_NOTXORPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOTXORPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTXORPEN, "Case 21") < 0)
		return -1;

	/* Test Case 22: (0,0) -> (16,16), R2_NOP */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_NOP);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOP, "Case 22") < 0)
		return -1;

	/* Test Case 23: (0,0) -> (16,16), R2_MERGENOTPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MERGENOTPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGENOTPEN, "Case 23") < 0)
		return -1;

	/* Test Case 24: (0,0) -> (16,16), R2_COPYPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_COPYPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_COPYPEN, "Case 24") < 0)
		return -1;

	/* Test Case 25: (0,0) -> (16,16), R2_MERGEPENNOT */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MERGEPENNOT);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGEPENNOT, "Case 25") < 0)
		return -1;

	/* Test Case 26: (0,0) -> (16,16), R2_MERGEPEN */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_MERGEPEN);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGEPEN, "Case 26") < 0)
		return -1;

	/* Test Case 27: (0,0) -> (16,16), R2_WHITE */
	gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS);
	gdi_SetClipRgn(hdc, 0, 0, 16, 16);
	gdi_MoveToEx(hdc, 0, 0, NULL);
	gdi_SetROP2(hdc, GDI_R2_WHITE);
	gdi_LineTo(hdc, 16, 16);

	if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_WHITE, "Case 27") < 0)
		return -1;

	return 0;
}
Пример #14
0
void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits_command)
{
	int i, j;
	int tx, ty;
	char* tile_bitmap;
	RFX_MESSAGE* message;
	wfInfo* wfi = ((wfContext*) context)->wfi;

	RFX_CONTEXT* rfx_context = (RFX_CONTEXT*) wfi->rfx_context;
	NSC_CONTEXT* nsc_context = (NSC_CONTEXT*) wfi->nsc_context;

	tile_bitmap = (char*) xzalloc(32);

	if (surface_bits_command->codecID == CODEC_ID_REMOTEFX)
	{
		RECTANGLE_16 dest_rect;

		dest_rect.left = surface_bits_command->destLeft;
		dest_rect.top = surface_bits_command->destTop;
		dest_rect.right = surface_bits_command->destRight;
		dest_rect.bottom = surface_bits_command->destBottom;

		message = rfx_process_message(rfx_context, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength, &dest_rect);

		/* blit each tile */
		for (i = 0; i < message->num_tiles; i++)
		{
			tx = message->tiles[i]->x + surface_bits_command->destLeft;
			ty = message->tiles[i]->y + surface_bits_command->destTop;

			freerdp_image_convert(message->tiles[i]->data, wfi->tile->pdata, 64, 64, 32, 32, wfi->clrconv);

			for (j = 0; j < message->num_rects; j++)
			{
				wf_set_clip_rgn(wfi,
					surface_bits_command->destLeft + message->rects[j].x,
					surface_bits_command->destTop + message->rects[j].y,
					message->rects[j].width, message->rects[j].height);

				BitBlt(wfi->primary->hdc, tx, ty, 64, 64, wfi->tile->hdc, 0, 0, SRCCOPY);
			}
		}

		wf_set_null_clip_rgn(wfi);

		/* invalidate regions */
		for (i = 0; i < message->num_rects; i++)
		{
			tx = surface_bits_command->destLeft + message->rects[i].x;
			ty = surface_bits_command->destTop + message->rects[i].y;
			wf_invalidate_region(wfi, tx, ty, message->rects[i].width, message->rects[i].height);
		}

		rfx_message_free(rfx_context, message);
	}
	else if (surface_bits_command->codecID == CODEC_ID_NSCODEC)
	{
		nsc_process_message(nsc_context, surface_bits_command->bpp, surface_bits_command->width, surface_bits_command->height,
			surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);
		wfi->image->_bitmap.width = surface_bits_command->width;
		wfi->image->_bitmap.height = surface_bits_command->height;
		wfi->image->_bitmap.bpp = surface_bits_command->bpp;
		wfi->image->_bitmap.data = (uint8*) xrealloc(wfi->image->_bitmap.data, wfi->image->_bitmap.width * wfi->image->_bitmap.height * 4);
		freerdp_image_flip(nsc_context->bmpdata, wfi->image->_bitmap.data, wfi->image->_bitmap.width, wfi->image->_bitmap.height, 32);
		BitBlt(wfi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop, surface_bits_command->width, surface_bits_command->height, wfi->image->hdc, 0, 0, GDI_SRCCOPY);
	} 
	else if (surface_bits_command->codecID == CODEC_ID_NONE)
	{
		wfi->image->_bitmap.width = surface_bits_command->width;
		wfi->image->_bitmap.height = surface_bits_command->height;
		wfi->image->_bitmap.bpp = surface_bits_command->bpp;

		wfi->image->_bitmap.data = (uint8*) xrealloc(wfi->image->_bitmap.data,
				wfi->image->_bitmap.width * wfi->image->_bitmap.height * 4);

		if ((surface_bits_command->bpp != 32) || (wfi->clrconv->alpha == true))
		{
			uint8* temp_image;

			freerdp_image_convert(surface_bits_command->bitmapData, wfi->image->_bitmap.data,
				wfi->image->_bitmap.width, wfi->image->_bitmap.height,
				wfi->image->_bitmap.bpp, 32, wfi->clrconv);

			surface_bits_command->bpp = 32;
			surface_bits_command->bitmapData = wfi->image->_bitmap.data;

			temp_image = (uint8*) xmalloc(wfi->image->_bitmap.width * wfi->image->_bitmap.height * 4);
			freerdp_image_flip(wfi->image->_bitmap.data, temp_image, wfi->image->_bitmap.width, wfi->image->_bitmap.height, 32);
			xfree(wfi->image->_bitmap.data);
			wfi->image->_bitmap.data = temp_image;
		}
		else
		{
			freerdp_image_flip(surface_bits_command->bitmapData, wfi->image->_bitmap.data,
					wfi->image->_bitmap.width, wfi->image->_bitmap.height, 32);
		}

		BitBlt(wfi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
				surface_bits_command->width, surface_bits_command->height, wfi->image->hdc, 0, 0, SRCCOPY);
	}
	else
	{
		printf("Unsupported codecID %d\n", surface_bits_command->codecID);
	}

	if (tile_bitmap != NULL)
		xfree(tile_bitmap);
}