void wf_Bitmap_Decompress(wfContext* wfc, rdpBitmap* bitmap, BYTE* data, int width, int height, int bpp, int length, BOOL compressed, int codec_id) { UINT16 size; size = width * height * (bpp / 8); if (!bitmap->data) bitmap->data = (BYTE*) _aligned_malloc(size, 16); else bitmap->data = (BYTE*) _aligned_realloc(bitmap->data, size, 16); if (compressed) { BOOL status; status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp); if (status != TRUE) { fprintf(stderr, "Bitmap Decompression Failed\n"); } } else { freerdp_image_flip(data, bitmap->data, width, height, bpp); } bitmap->compressed = FALSE; bitmap->length = size; bitmap->bpp = bpp; }
/* 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); }
void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, uint8* data, int width, int height, int bpp, int length, boolean compressed) { uint16 size; size = width * height * (bpp + 7) / 8; if (bitmap->data == NULL) bitmap->data = (uint8*) xmalloc(size); else bitmap->data = (uint8*) xrealloc(bitmap->data, size); if (compressed) { boolean status; status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp); if (status != true) { printf("Bitmap Decompression Failed\n"); } } else { freerdp_image_flip(data, bitmap->data, width, height, bpp); } bitmap->width = width; bitmap->height = height; bitmap->compressed = false; bitmap->length = size; bitmap->bpp = bpp; }
void update_read_bitmap_data(STREAM* s, BITMAP_DATA* bitmap_data) { uint8* srcData; uint16 dstSize; boolean status; uint16 bytesPerPixel; stream_read_uint16(s, bitmap_data->left); stream_read_uint16(s, bitmap_data->top); stream_read_uint16(s, bitmap_data->right); stream_read_uint16(s, bitmap_data->bottom); stream_read_uint16(s, bitmap_data->width); stream_read_uint16(s, bitmap_data->height); stream_read_uint16(s, bitmap_data->bpp); stream_read_uint16(s, bitmap_data->flags); stream_read_uint16(s, bitmap_data->length); bytesPerPixel = (bitmap_data->bpp + 7) / 8; if (bitmap_data->flags & BITMAP_COMPRESSION) { uint16 cbCompMainBodySize; uint16 cbUncompressedSize; stream_seek_uint16(s); /* cbCompFirstRowSize (2 bytes) */ stream_read_uint16(s, cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ stream_seek_uint16(s); /* cbScanWidth (2 bytes) */ stream_read_uint16(s, cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ dstSize = cbUncompressedSize; bitmap_data->length = cbCompMainBodySize; bitmap_data->data = (uint8*) xzalloc(dstSize); stream_get_mark(s, srcData); stream_seek(s, bitmap_data->length); status = bitmap_decompress(srcData, bitmap_data->data, bitmap_data->width, bitmap_data->height, bitmap_data->length, bitmap_data->bpp, bitmap_data->bpp); if (status != True) printf("bitmap decompression failed, bpp:%d\n", bitmap_data->bpp); } else { int y; int offset; int scanline; stream_get_mark(s, srcData); dstSize = bitmap_data->length; bitmap_data->data = (uint8*) xzalloc(dstSize); scanline = bitmap_data->width * (bitmap_data->bpp / 8); for (y = 0; y < bitmap_data->height; y++) { offset = (bitmap_data->height - y - 1) * scanline; stream_read(s, &bitmap_data->data[offset], scanline); } } }
void xf_gdi_bitmap_decompress(rdpUpdate* update, rdpBitmap* bitmap_data) { uint16 length; length = bitmap_data->width * bitmap_data->height * (bitmap_data->bpp / 8); if (bitmap_data->dstData == NULL) bitmap_data->dstData = (uint8*) xmalloc(length); else bitmap_data->dstData = (uint8*) xrealloc(bitmap_data->dstData, length); if (bitmap_data->compressed) { boolean status; status = bitmap_decompress(bitmap_data->srcData, bitmap_data->dstData, bitmap_data->width, bitmap_data->height, bitmap_data->length, bitmap_data->bpp, bitmap_data->bpp); if (status != True) { printf("Bitmap Decompression Failed\n"); } } else { freerdp_image_flip(bitmap_data->srcData, bitmap_data->dstData, bitmap_data->width, bitmap_data->height, bitmap_data->bpp); } bitmap_data->compressed = False; bitmap_data->length = length; }
/* Process bitmap updates */ void process_bitmap_updates(STREAM s) { uint16 num_updates; uint16 left, top, right, bottom, width, height; uint16 cx, cy, bpp, Bpp, compress, bufsize, size; uint8 *data, *bmpdata; int i; in_uint16_le(s, num_updates); for (i = 0; i < num_updates; i++) { in_uint16_le(s, left); in_uint16_le(s, top); in_uint16_le(s, right); in_uint16_le(s, bottom); in_uint16_le(s, width); in_uint16_le(s, height); in_uint16_le(s, bpp); Bpp = (bpp + 7) / 8; //Bpp = 4; in_uint16_le(s, compress); in_uint16_le(s, bufsize); cx = right - left + 1; cy = bottom - top + 1; //DEBUG(("BITMAP_UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,Bpp=%d,cmp=%d)\n", // left, top, right, bottom, width, height, Bpp, compress)); __android_log_print(ANDROID_LOG_INFO,"JNIMsg","BITMAP_UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,Bpp=%d,cmp=%d)",left, top, right, bottom, width, height, Bpp, compress); if (!compress) { int y; bmpdata = (uint8 *) xmalloc(width * height * Bpp); for (y = 0; y < height; y++) { in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)], width * Bpp); } __android_log_print(ANDROID_LOG_INFO,"JNIMsg","in if do ui_paint_bitmap"); ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); xfree(bmpdata); continue; } if (compress & 0x400) { size = bufsize; } else { in_uint8s(s, 2); /* pad */ in_uint16_le(s, size); in_uint8s(s, 4); /* line_size, final_size */ }in_uint8p(s, data, size); bmpdata = (uint8 *) xmalloc(width * height * Bpp); if (bitmap_decompress(bmpdata, width, height, data, size, Bpp)) { ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); } else { DEBUG_RDP5(("Failed to decompress data\n")); } xfree(bmpdata); } }
void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* data, int width, int height, int bpp, int length, BOOL compressed) { #else void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* data, int width, int height, int bpp, int length, BOOL compressed, int codec_id) { #endif int size = width * height * 4; #ifdef FREERDP_BITMAP_REQUIRES_ALIGNED_MALLOC bitmap->data = (UINT8*) _aligned_malloc(size, 16); #else bitmap->data = (UINT8*) malloc(size); #endif if (compressed) { #ifdef HAVE_RDPCONTEXT_CODECS rdpCodecs* codecs = context->codecs; UINT32* palette = ((rdp_freerdp_context*) context)->palette; /* Decode as interleaved if less than 32 bits per pixel */ if (bpp < 32) { freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED); interleaved_decompress(codecs->interleaved, data, length, bpp, &(bitmap->data), PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height, (BYTE*) palette); } /* Otherwise, decode as planar */ else { freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_PLANAR); planar_decompress(codecs->planar, data, length, &(bitmap->data), PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height, TRUE); } bitmap->bpp = 32; #else bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp); bitmap->bpp = bpp; #endif } else { freerdp_image_flip(data, bitmap->data, width, height, bpp); bitmap->bpp = bpp; } bitmap->compressed = FALSE; bitmap->length = size; }
void update_read_bitmap_data(STREAM* s, BITMAP_DATA* bitmap_data) { uint8* srcData; uint16 dstSize; boolean status; uint16 bytesPerPixel; stream_read_uint16(s, bitmap_data->left); stream_read_uint16(s, bitmap_data->top); stream_read_uint16(s, bitmap_data->right); stream_read_uint16(s, bitmap_data->bottom); stream_read_uint16(s, bitmap_data->width); stream_read_uint16(s, bitmap_data->height); stream_read_uint16(s, bitmap_data->bpp); stream_read_uint16(s, bitmap_data->flags); stream_read_uint16(s, bitmap_data->length); bytesPerPixel = (bitmap_data->bpp + 7) / 8; if (bitmap_data->flags & BITMAP_COMPRESSION) { uint16 cbCompMainBodySize; uint16 cbUncompressedSize; stream_seek_uint16(s); /* cbCompFirstRowSize (2 bytes) */ stream_read_uint16(s, cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ stream_seek_uint16(s); /* cbScanWidth (2 bytes) */ stream_read_uint16(s, cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ dstSize = cbUncompressedSize; bitmap_data->length = cbCompMainBodySize; } else { dstSize = bitmap_data->width * bitmap_data->height * bytesPerPixel; } stream_get_mark(s, srcData); stream_seek(s, bitmap_data->length); bitmap_data->data = (uint8*) xzalloc(dstSize); //printf("bytesPerPixel:%d, width:%d, height:%d dstSize:%d flags:0x%04X\n", // bytesPerPixel, bitmap_data->width, bitmap_data->height, dstSize, bitmap_data->flags); status = bitmap_decompress(srcData, bitmap_data->data, bitmap_data->width, bitmap_data->height, bitmap_data->length, bitmap_data->bpp, bitmap_data->bpp); if (status != True) printf("bitmap decompression failed\n"); }
void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* data, int width, int height, int bpp, int length, BOOL compressed) { #else void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* data, int width, int height, int bpp, int length, BOOL compressed, int codec_id) { #endif int size = width * height * (bpp + 7) / 8; if (bitmap->data == NULL) bitmap->data = (UINT8*) malloc(size); else bitmap->data = (UINT8*) realloc(bitmap->data, size); if (compressed) bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp); else freerdp_image_flip(data, bitmap->data, width, height, bpp); bitmap->compressed = FALSE; bitmap->length = size; bitmap->bpp = bpp; }
void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, BYTE* data, int width, int height, int bpp, int length, BOOL compressed, int codec_id) { UINT16 size; BYTE* src; BYTE* dst; int yindex; int xindex; BOOL status; RFX_MESSAGE* msg; xfContext* xfc = (xfContext*) context; size = width * height * ((bpp + 7) / 8); if (!bitmap->data) bitmap->data = (BYTE*) _aligned_malloc(size, 16); else bitmap->data = (BYTE*) _aligned_realloc(bitmap->data, size, 16); switch (codec_id) { case RDP_CODEC_ID_NSCODEC: DEBUG_WARN( "xf_Bitmap_Decompress: nsc not done\n"); break; case RDP_CODEC_ID_REMOTEFX: rfx_context_set_pixel_format(xfc->rfx, RDP_PIXEL_FORMAT_B8G8R8A8); msg = rfx_process_message(xfc->rfx, data, length); if (!msg) { DEBUG_WARN( "xf_Bitmap_Decompress: rfx Decompression Failed\n"); } else { for (yindex = 0; yindex < height; yindex++) { src = msg->tiles[0]->data + yindex * 64 * 4; dst = bitmap->data + yindex * width * 3; for (xindex = 0; xindex < width; xindex++) { *(dst++) = *(src++); *(dst++) = *(src++); *(dst++) = *(src++); src++; } } rfx_message_free(xfc->rfx, msg); } break; case RDP_CODEC_ID_JPEG: if (!jpeg_decompress(data, bitmap->data, width, height, length, bpp)) { DEBUG_WARN( "xf_Bitmap_Decompress: jpeg Decompression Failed\n"); } break; default: if (compressed) { status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp); if (!status) { DEBUG_WARN( "xf_Bitmap_Decompress: Bitmap Decompression Failed\n"); } } else { freerdp_image_flip(data, bitmap->data, width, height, bpp); } break; } bitmap->compressed = FALSE; bitmap->length = size; bitmap->bpp = bpp; }
/* Process bitmap updates */ void process_bitmap_updates(STREAM s) { uint16 num_updates; uint16 left, top, right, bottom, width, height; uint16 cx, cy, bpp, Bpp, compress, bufsize, size; uint8 *data, *bmpdata; int i; in_uint16_le(s, num_updates); for (i = 0; i < num_updates; i++) { in_uint16_le(s, left); in_uint16_le(s, top); in_uint16_le(s, right); in_uint16_le(s, bottom); in_uint16_le(s, width); in_uint16_le(s, height); in_uint16_le(s, bpp); Bpp = (bpp + 7) / 8; in_uint16_le(s, compress); in_uint16_le(s, bufsize); cx = right - left + 1; cy = bottom - top + 1; DEBUG(("BITMAP_UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,Bpp=%d,cmp=%d)\n", left, top, right, bottom, width, height, Bpp, compress)); /* Server may limit bpp - this is how we find out */ if (g_server_bpp != bpp) { warning("Server limited colour depth to %d bits\n", bpp); g_server_bpp = bpp; } if (!compress) { int y; bmpdata = (uint8 *) xmalloc(width * height * Bpp); for (y = 0; y < height; y++) { in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)], width * Bpp); } ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); xfree(bmpdata); continue; } if (compress & 0x400) { size = bufsize; } else { in_uint8s(s, 2); /* pad */ in_uint16_le(s, size); in_uint8s(s, 4); /* line_size, final_size */ } in_uint8p(s, data, size); bmpdata = (uint8 *) xmalloc(width * height * Bpp); if (bitmap_decompress(bmpdata, width, height, data, size, Bpp)) { ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); } else { DEBUG_RDP5(("Failed to decompress data\n")); } xfree(bmpdata); } }
/* Process bitmap updates */ void process_bitmap_updates(RDPCLIENT * This, STREAM s) { uint16 num_updates; uint16 left, top, right, bottom, width, height; uint16 cx, cy, bpp, Bpp, compress, bufsize, size; uint8 *data, *bmpdata; int i; in_uint16_le(s, num_updates); for (i = 0; i < num_updates; i++) { in_uint16_le(s, left); in_uint16_le(s, top); in_uint16_le(s, right); in_uint16_le(s, bottom); in_uint16_le(s, width); in_uint16_le(s, height); in_uint16_le(s, bpp); Bpp = (bpp + 7) / 8; in_uint16_le(s, compress); in_uint16_le(s, bufsize); cx = right - left + 1; cy = bottom - top + 1; DEBUG(("BITMAP_UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,Bpp=%d,cmp=%d)\n", left, top, right, bottom, width, height, Bpp, compress)); if (!compress) { #if 0 int y; bmpdata = (uint8 *) xmalloc(width * height * Bpp); for (y = 0; y < height; y++) { in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)], width * Bpp); } ui_paint_bitmap(This, left, top, cx, cy, width, height, bmpdata); xfree(bmpdata); #else in_uint8p(s, bmpdata, width * height * Bpp); ui_paint_bitmap(This, left, top, cx, cy, width, height, bmpdata); #endif continue; } if (compress & 0x400) { size = bufsize; } else { in_uint8s(s, 2); /* pad */ in_uint16_le(s, size); in_uint8s(s, 4); /* line_size, final_size */ } in_uint8p(s, data, size); bmpdata = (uint8 *) malloc(width * height * Bpp); if(bmpdata == NULL) return; if (bitmap_decompress(bmpdata, width, height, data, size, Bpp)) { ui_paint_bitmap(This, left, top, cx, cy, width, height, bmpdata); } else { DEBUG_RDP5(("Failed to decompress data\n")); } free(bmpdata); } }
void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, BYTE* data, int width, int height, int bpp, int length, BOOL compressed, int codecId) { BOOL status; UINT16 size; BYTE* src; BYTE* dst; int yindex; int xindex; rdpGdi* gdi; RFX_MESSAGE* msg; size = width * height * ((bpp + 7) / 8); if (!bitmap->data) bitmap->data = (BYTE*) malloc(size); else bitmap->data = (BYTE*) realloc(bitmap->data, size); switch (codecId) { case RDP_CODEC_ID_NSCODEC: gdi = context->gdi; nsc_process_message(gdi->nsc_context, bpp, width, height, data, length); freerdp_image_flip(((NSC_CONTEXT*) gdi->nsc_context)->BitmapData, bitmap->data, width, height, bpp); break; case RDP_CODEC_ID_REMOTEFX: gdi = context->gdi; rfx_context_set_pixel_format(gdi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); msg = rfx_process_message(gdi->rfx_context, data, length); if (!msg) { fprintf(stderr, "gdi_Bitmap_Decompress: rfx Decompression Failed\n"); } else { for (yindex = 0; yindex < height; yindex++) { src = msg->tiles[0]->data + yindex * 64 * 4; dst = bitmap->data + yindex * width * 3; for (xindex = 0; xindex < width; xindex++) { *(dst++) = *(src++); *(dst++) = *(src++); *(dst++) = *(src++); src++; } } rfx_message_free(gdi->rfx_context, msg); } break; case RDP_CODEC_ID_JPEG: #ifdef WITH_JPEG if (!jpeg_decompress(data, bitmap->data, width, height, length, bpp)) { fprintf(stderr, "gdi_Bitmap_Decompress: jpeg Decompression Failed\n"); } #endif break; default: if (compressed) { status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp); if (!status) { fprintf(stderr, "gdi_Bitmap_Decompress: Bitmap Decompression Failed\n"); } } else { freerdp_image_flip(data, bitmap->data, width, height, bpp); } break; } bitmap->width = width; bitmap->height = height; bitmap->compressed = FALSE; bitmap->length = size; bitmap->bpp = bpp; }
void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* data, int width, int height, int bpp, int length, BOOL compressed) { #else void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* data, int width, int height, int bpp, int length, BOOL compressed, int codec_id) { #endif int size = width * height * 4; #ifdef FREERDP_BITMAP_REQUIRES_ALIGNED_MALLOC /* Free pre-existing data, if any (might be reused) */ if (bitmap->data != NULL) _aligned_free(bitmap->data); /* Allocate new data */ bitmap->data = (UINT8*) _aligned_malloc(size, 16); #else /* Free pre-existing data, if any (might be reused) */ free(bitmap->data); /* Allocate new data */ bitmap->data = (UINT8*) malloc(size); #endif if (compressed) { #ifdef HAVE_RDPCONTEXT_CODECS rdpCodecs* codecs = context->codecs; /* Decode as interleaved if less than 32 bits per pixel */ if (bpp < 32) { freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED); #ifdef INTERLEAVED_DECOMPRESS_TAKES_PALETTE interleaved_decompress(codecs->interleaved, data, length, bpp, &(bitmap->data), PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height, (BYTE*) ((rdp_freerdp_context*) context)->palette); bitmap->bpp = 32; #else interleaved_decompress(codecs->interleaved, data, length, bpp, &(bitmap->data), PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height); bitmap->bpp = bpp; #endif } /* Otherwise, decode as planar */ else { freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_PLANAR); #ifdef PLANAR_DECOMPRESS_CAN_FLIP planar_decompress(codecs->planar, data, length, &(bitmap->data), PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height, TRUE); bitmap->bpp = 32; #else planar_decompress(codecs->planar, data, length, &(bitmap->data), PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height); bitmap->bpp = bpp; #endif } #else bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp); bitmap->bpp = bpp; #endif } else { freerdp_image_flip(data, bitmap->data, width, height, bpp); bitmap->bpp = bpp; } bitmap->compressed = FALSE; bitmap->length = size; }