for (index = 0; index < bitmapUpdate->number; index++)
{
- const BITMAP_DATA* bitmapData = &(bitmapUpdate->rectangles[index]);
- rdpBitmap* bmp = Bitmap_Alloc(context);
-
- if (!bmp)
- return FALSE;
-
- Bitmap_SetRectangle(bmp, bitmapData->destLeft, bitmapData->destTop,
- bitmapData->destRight, bitmapData->destBottom);
-
- if (!bmp->Decompress(context, bmp, bitmapData->bitmapDataStream,
- bitmapData->width, bitmapData->height,
- bitmapData->bitsPerPixel, bitmapData->bitmapLength,
- bitmapData->compressed, RDP_CODEC_ID_NONE))
+ const BITMAP_DATA* bitmap = &(bitmapUpdate->rectangles[index]);
+ UINT32 nXSrc = 0;
+ UINT32 nYSrc = 0;
+ UINT32 nXDst = bitmap->destLeft;
+ UINT32 nYDst = bitmap->destTop;
+ UINT32 nWidth = MIN(bitmap->destRight,
+ gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
+ UINT32 nHeight = MIN(bitmap->destBottom,
+ gdi->height - 1) - bitmap->destTop + 1; /* clip height */
+ const BYTE* pSrcData = bitmap->bitmapDataStream;
+ UINT32 SrcSize = bitmap->bitmapLength;
+ BOOL compressed = bitmap->compressed;
+ UINT32 bitsPerPixel = bitmap->bitsPerPixel;
+
+ if (compressed)
{
- bmp->Free(context, bmp);
+ if (bitsPerPixel < 32)
+ {
+ if (!interleaved_decompress(codecs->interleaved,
+ pSrcData, SrcSize,
+ bitmap->width, bitmap->height,
+ bitsPerPixel,
+ gdi->primary_buffer,
+ gdi->primary->hdc->format,
+ gdi->stride, nXDst, nYDst,
+ nWidth, nHeight,
+ &gdi->palette))
return FALSE;
}
-
- if (!bmp->New(context, bmp))
+ else
{
- bmp->Free(context, bmp);
+ if (!planar_decompress(codecs->planar, pSrcData,
+ SrcSize, bitmap->width, bitmap->height,
+ gdi->primary_buffer,
+ gdi->primary->hdc->format,
+ gdi->stride,
+ nXDst, nYDst, nWidth, nHeight, TRUE))
return FALSE;
}
-
- if (!bmp->Paint(context, bmp))
+ }
+ else
{
- bmp->Free(context, bmp);
+ UINT32 SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
+ UINT32 nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
+
+ if (!freerdp_image_copy(gdi->primary_buffer, gdi->primary->hdc->format,
+ gdi->stride,
+ nXDst, nYDst, nWidth, nHeight,
+ pSrcData, SrcFormat, nSrcStep,
+ nXSrc, nYSrc, &gdi->palette))
return FALSE;
}
- bmp->Free(context, bmp);
-
- if (!gdi_InvalidateRegion(gdi->primary->hdc, bmp->left, bmp->top,
- bmp->width, bmp->height))
+ if (!gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst,
+ nWidth, nHeight))
return FALSE;
}