示例#1
0
文件: orders.c 项目: z0x010/rdesktop
/* Process a bitmap cache order */
static void
process_bmpcache(STREAM s)
{
	HBITMAP bitmap;
	uint16 cache_idx, size;
	uint8 cache_id, width, height, bpp;
	uint8 *data, *bmpdata;

	in_uint8(s, cache_id);
	in_uint8s(s, 1);	/* pad */
	in_uint8(s, width);
	in_uint8(s, height);
	in_uint8(s, bpp);
	in_uint8s(s, 2);	/* bufsize */
	in_uint16_le(s, cache_idx);
	in_uint8s(s, 2);	/* pad */
	in_uint16_le(s, size);
	in_uint8s(s, 4);	/* row_size, final_size */
	in_uint8p(s, data, size);

	DEBUG(("BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", width, height, cache_id, cache_idx));

	bmpdata = xmalloc(width * height);

	if (bitmap_decompress(bmpdata, width, height, data, size))
	{
		bitmap = ui_create_bitmap(width, height, bmpdata);
		cache_put_bitmap(cache_id, cache_idx, bitmap);
	}

	xfree(bmpdata);
}
示例#2
0
文件: orders.c 项目: z0x010/rdesktop
/* Process a raw bitmap cache order */
static void
process_raw_bmpcache(STREAM s)
{
	HBITMAP bitmap;
	uint16 cache_idx, bufsize;
	uint8 cache_id, width, height, bpp;
	uint8 *data, *inverted;
	int y;

	in_uint8(s, cache_id);
	in_uint8s(s, 1);	/* pad */
	in_uint8(s, width);
	in_uint8(s, height);
	in_uint8(s, bpp);
	in_uint16_le(s, bufsize);
	in_uint16_le(s, cache_idx);
	in_uint8p(s, data, bufsize);

	DEBUG(("RAW_BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", width, height, cache_id, cache_idx));
	inverted = xmalloc(width * height);
	for (y = 0; y < height; y++)
	{
		memcpy(&inverted[(height - y - 1) * width], &data[y * width], width);
	}

	bitmap = ui_create_bitmap(width, height, inverted);
	xfree(inverted);
	cache_put_bitmap(cache_id, cache_idx, bitmap);
}
示例#3
0
/* Load a bitmap from the persistent cache */
BOOL
pstcache_load_bitmap(RDPCLIENT * This, uint8 cache_id, uint16 cache_idx)
{
	uint8 *celldata;
	int fd;
	CELLHEADER cellhdr;
	HBITMAP bitmap;

	if (!This->bitmap_cache_persist_enable)
		return False;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	fd = This->pstcache_fd[cache_id];
	rd_lseek_file(fd, cache_idx * (This->pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
	celldata = (uint8 *) malloc(cellhdr.length);

	if(celldata == NULL)
		return False;

	rd_read_file(fd, celldata, cellhdr.length);

	bitmap = ui_create_bitmap(This, cellhdr.width, cellhdr.height, celldata);
	DEBUG(("Load bitmap from disk: id=%d, idx=%d, bmp=0x%x)\n", cache_id, cache_idx, bitmap));
	cache_put_bitmap(This, cache_id, cache_idx, bitmap);

	free(celldata);
	return True;
}
示例#4
0
/* Load a bitmap from the persistent cache */
RDCBOOL
pstcache_load_bitmap(rdcConnection conn, uint8 cache_id, uint16 cache_idx)
{
	uint8 *celldata;
	int fd;
	CELLHEADER cellhdr;
	HBITMAP bitmap;

	if (!conn->bitmapCachePersist)
		return False;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	fd = conn->pstcacheFd[cache_id];
	rd_lseek_file(fd, cache_idx * (conn->pstcacheBpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
	celldata = (uint8 *) xmalloc(cellhdr.length);
	rd_read_file(fd, celldata, cellhdr.length);

	bitmap = ui_create_bitmap(conn, cellhdr.width, cellhdr.height, celldata);
	DEBUG(("Load bitmap from disk: id=%d, idx=%d, bmp=0x%x)\n", cache_id, cache_idx, bitmap));
	cache_put_bitmap(conn, cache_id, cache_idx, bitmap);

	xfree(celldata);
	return True;
}
示例#5
0
文件: pstcache.c 项目: alama/freerdp
/* Load a bitmap from the persistent cache */
RD_BOOL
pstcache_load_bitmap(rdpPcache * pcache, uint8 cache_id, uint16 cache_idx)
{
	uint8 *celldata;
	int fd;
	CELLHEADER cellhdr;
	RD_HBITMAP bitmap;

	if (!(pcache->rdp->settings->bitmap_cache_persist_enable))
		return False;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	fd = pcache->pstcache_fd[cache_id];
	rd_lseek_file(fd, cache_idx *
			(pcache->pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
	celldata = (uint8 *) xmalloc(cellhdr.length);
	rd_read_file(fd, celldata, cellhdr.length);

	bitmap = ui_create_bitmap(pcache->rdp->inst, cellhdr.width, cellhdr.height, celldata);
	DEBUG("Load bitmap from disk: id=%d, idx=%d, bmp=0x%x)\n", cache_id, cache_idx,
	       (unsigned int) bitmap);
	cache_put_bitmap(pcache->rdp->cache, cache_id, cache_idx, bitmap);

	xfree(celldata);
	return True;
}
示例#6
0
/* Load a bitmap from the persistent cache */
RD_BOOL
pstcache_load_bitmap(uint8 cache_id, uint16 cache_idx)
{
	uint8 *celldata;
	int fd;
	CELLHEADER cellhdr;
	RD_HBITMAP bitmap;

	if (!g_bitmap_cache_persist_enable)
		return False;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	fd = g_pstcache_fd[cache_id];
	rd_lseek_file(fd, cache_idx * (g_pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
	celldata = (uint8 *) xmalloc(cellhdr.length);
	rd_read_file(fd, celldata, cellhdr.length);

	bitmap = ui_create_bitmap(cellhdr.width, cellhdr.height, celldata);
	logger(Core, Debug, "pstcache_load_bitmap(), load bitmap from disk: id=%d, idx=%d, bmp=%p)",
	       cache_id, cache_idx, bitmap);
	cache_put_bitmap(cache_id, cache_idx, bitmap);

	xfree(celldata);
	return True;
}