Fixed color ordering for GDI.
authorArmin Novak <armin.novak@gmail.com>
Tue, 19 Apr 2016 19:30:28 +0000 (21:30 +0200)
committerArmin Novak <armin.novak@thincast.com>
Thu, 6 Oct 2016 11:42:59 +0000 (13:42 +0200)
client/X11/xf_client.c
include/freerdp/codec/planar.h
libfreerdp/cache/bitmap.c
libfreerdp/codec/include/bitmap.c
libfreerdp/codec/interleaved.c
libfreerdp/codec/planar.c
libfreerdp/core/graphics.c
libfreerdp/gdi/bitmap.c
libfreerdp/gdi/graphics.c

index 2556b09..7bd8c06 100644 (file)
@@ -152,7 +152,7 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
                {
                        XSetRegion(xfc->display, xfc->gc, reg1);
                        XFillRectangle(xfc->display, xfc->window->handle, xfc->gc, 0, 0,
-                                      xfc->window->width, xfc->window->height);
+                                          xfc->window->width, xfc->window->height);
                        XSetClipMask(xfc->display, xfc->gc, None);
                }
 
@@ -162,9 +162,9 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
        picFormat = XRenderFindVisualFormat(xfc->display, xfc->visual);
        pa.subwindow_mode = IncludeInferiors;
        primaryPicture = XRenderCreatePicture(xfc->display, xfc->primary, picFormat,
-                                             CPSubwindowMode, &pa);
+                                                 CPSubwindowMode, &pa);
        windowPicture = XRenderCreatePicture(xfc->display, xfc->window->handle,
-                                            picFormat, CPSubwindowMode, &pa);
+                                                picFormat, CPSubwindowMode, &pa);
        XRenderSetPictureFilter(xfc->display, primaryPicture, FilterBilinear, 0, 0);
        transform.matrix[0][0] = XDoubleToFixed(xScalingFactor);
        transform.matrix[0][1] = XDoubleToFixed(0.0);
@@ -192,8 +192,8 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
 BOOL xf_picture_transform_required(xfContext* xfc)
 {
        if (xfc->offset_x || xfc->offset_y ||
-           xfc->scaledWidth != xfc->sessionWidth ||
-           xfc->scaledHeight != xfc->sessionHeight)
+               xfc->scaledWidth != xfc->sessionWidth ||
+               xfc->scaledHeight != xfc->sessionHeight)
        {
                return TRUE;
        }
@@ -256,7 +256,7 @@ static BOOL xf_desktop_resize(rdpContext* context)
        if (!xfc->fullscreen)
        {
                xf_ResizeDesktopWindow(xfc, xfc->window, settings->DesktopWidth,
-                                      settings->DesktopHeight);
+                                          settings->DesktopHeight);
        }
        else
        {
@@ -275,7 +275,7 @@ static BOOL xf_desktop_resize(rdpContext* context)
                XSetFillStyle(xfc->display, xfc->gc, FillSolid);
                XSetForeground(xfc->display, xfc->gc, 0);
                XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0, xfc->window->width,
-                              xfc->window->height);
+                                  xfc->window->height);
        }
 
        return TRUE;
@@ -552,7 +552,7 @@ BOOL xf_create_window(xfContext* xfc)
                else
                {
                        windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(settings->ServerHostname)
-                                            + sizeof(":00000"));
+                                                + sizeof(":00000"));
                        sprintf(windowTitle, "FreeRDP: %s:%i", settings->ServerHostname,
                                settings->ServerPort);
                }
@@ -599,7 +599,7 @@ BOOL xf_create_window(xfContext* xfc)
 
        if (!xfc->primary)
                xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, xfc->sessionWidth,
-                                            xfc->sessionHeight, xfc->depth);
+                                                xfc->sessionHeight, xfc->depth);
 
        xfc->drawing = xfc->primary;
 
@@ -614,7 +614,7 @@ BOOL xf_create_window(xfContext* xfc)
        XSetFillStyle(xfc->display, xfc->gc, FillSolid);
        XSetForeground(xfc->display, xfc->gc, BlackPixelOfScreen(xfc->screen));
        XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, xfc->sessionWidth,
-                      xfc->sessionHeight);
+                          xfc->sessionHeight);
        XFlush(xfc->display);
 
        if (!xfc->image)
@@ -726,7 +726,7 @@ void xf_toggle_control(xfContext* xfc)
  * @return 0 on success, otherwise a Win32 error code
  */
 UINT xf_encomsp_participant_created(EncomspClientContext* context,
-                                   ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
+                                       ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
 {
        return CHANNEL_RC_OK;
 }
@@ -822,7 +822,7 @@ BOOL xf_get_pixmap_info(xfContext* xfc)
        }
 
        vis = XGetVisualInfo(xfc->display, VisualClassMask | VisualScreenMask,
-                            &template, &vi_count);
+                                &template, &vi_count);
 
        if (!vis)
        {
@@ -912,7 +912,7 @@ void xf_check_extensions(xfContext* context)
        int xkb_minor = XkbMinorVersion;
 
        if (XkbLibraryVersion(&xkb_major, &xkb_minor)
-           && XkbQueryExtension(context->display, &xkb_opcode, &xkb_event,
+               && XkbQueryExtension(context->display, &xkb_opcode, &xkb_event,
                                 &xkb_error, &xkb_major, &xkb_minor))
        {
                context->xkbAvailable = TRUE;
@@ -970,7 +970,7 @@ static void xf_get_x11_button_map(xfContext* xfc, unsigned char* x11_map)
                                for (i = 0; i < num_devices; ++i)
                                {
                                        if ((devices2[i].use == XISlavePointer) &&
-                                           (strncmp(devices2[i].name, TEST_PTR_STR, TEST_PTR_LEN) != 0))
+                                               (strncmp(devices2[i].name, TEST_PTR_STR, TEST_PTR_LEN) != 0))
                                        {
                                                xid = devices2[i].deviceid;
                                                break;
@@ -990,7 +990,7 @@ static void xf_get_x11_button_map(xfContext* xfc, unsigned char* x11_map)
                                for (i = 0; i < num_devices; ++i)
                                {
                                        if ((devices1[i].use == IsXExtensionPointer) &&
-                                           (strncmp(devices1[i].name, TEST_PTR_STR, TEST_PTR_LEN) != 0))
+                                               (strncmp(devices1[i].name, TEST_PTR_STR, TEST_PTR_LEN) != 0))
                                        {
                                                xid = devices1[i].id;
                                                break;
@@ -1129,7 +1129,7 @@ BOOL xf_pre_connect(freerdp* instance)
        PubSub_SubscribeChannelConnected(instance->context->pubSub,
                                         (pChannelConnectedEventHandler) xf_OnChannelConnectedEventHandler);
        PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
-                                           (pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler);
+                                               (pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler);
 
        if (!freerdp_client_load_addins(channels, instance->settings))
                return FALSE;
@@ -1188,7 +1188,7 @@ BOOL xf_pre_connect(freerdp* instance)
         * we run the session in the /smart-sizing dimensions scaled to full screen
         */
        if (settings->Fullscreen && settings->SmartSizing &&
-           settings->SmartSizingWidth && settings->SmartSizingHeight)
+               settings->SmartSizingWidth && settings->SmartSizingHeight)
        {
                settings->DesktopWidth = settings->SmartSizingWidth;
                settings->DesktopHeight = settings->SmartSizingHeight;
@@ -1496,7 +1496,7 @@ void* xf_client_thread(void* param)
                if (!status)
                {
                        if (freerdp_get_last_error(instance->context) ==
-                           FREERDP_ERROR_AUTHENTICATION_FAILED)
+                               FREERDP_ERROR_AUTHENTICATION_FAILED)
                                exit_code = XF_EXIT_AUTH_FAILURE;
                        else
                                exit_code = XF_EXIT_CONN_FAILED;
@@ -1513,7 +1513,7 @@ void* xf_client_thread(void* param)
                exit_code = freerdp_error_info(instance);
 
                if (freerdp_get_last_error(instance->context) ==
-                   FREERDP_ERROR_AUTHENTICATION_FAILED)
+                       FREERDP_ERROR_AUTHENTICATION_FAILED)
                        exit_code = XF_EXIT_AUTH_FAILURE;
                else
                        exit_code = XF_EXIT_CONN_FAILED;
@@ -1636,8 +1636,8 @@ disconnect:
 DWORD xf_exit_code_from_disconnect_reason(DWORD reason)
 {
        if (reason == 0 || (reason >= XF_EXIT_PARSE_ARGUMENTS
-                           && reason <= XF_EXIT_AUTH_FAILURE))
-                   return reason;
+                               && reason <= XF_EXIT_AUTH_FAILURE))
+                       return reason;
        /* License error set */
        else if (reason >= 0x100 && reason <= 0x10A)
                         reason -= 0x100 + XF_EXIT_LICENSE_INTERNAL;
@@ -1682,10 +1682,10 @@ static void xf_ZoomingChangeEventHandler(rdpContext* context,
                return;
 
        if (w < 10)
-                   w = 10;
+                       w = 10;
 
        if (h < 10)
-                   h = 10;
+                       h = 10;
 
        if (w == xfc->scaledWidth && h == xfc->scaledHeight)
                return;
@@ -1808,9 +1808,9 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
                                  (pTerminateEventHandler) xf_TerminateEventHandler);
 #ifdef WITH_XRENDER
        PubSub_SubscribeZoomingChange(context->pubSub,
-                                     (pZoomingChangeEventHandler) xf_ZoomingChangeEventHandler);
+                                         (pZoomingChangeEventHandler) xf_ZoomingChangeEventHandler);
        PubSub_SubscribePanningChange(context->pubSub,
-                                     (pPanningChangeEventHandler) xf_PanningChangeEventHandler);
+                                         (pPanningChangeEventHandler) xf_PanningChangeEventHandler);
 #endif
        xfc->UseXThreads = TRUE;
        //xfc->debug = TRUE;
@@ -1859,7 +1859,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        xfc->_NET_WM_NAME = XInternAtom(xfc->display, "_NET_WM_NAME", False);
        xfc->_NET_WM_PID = XInternAtom(xfc->display, "_NET_WM_PID", False);
        xfc->_NET_WM_WINDOW_TYPE = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE",
-                                              False);
+                                                  False);
        xfc->_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(xfc->display,
                "_NET_WM_WINDOW_TYPE_NORMAL", False);
        xfc->_NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(xfc->display,
@@ -1875,7 +1875,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        xfc->_NET_WM_STATE_SKIP_PAGER = XInternAtom(xfc->display,
                "_NET_WM_STATE_SKIP_PAGER", False);
        xfc->_NET_WM_MOVERESIZE = XInternAtom(xfc->display, "_NET_WM_MOVERESIZE",
-                                             False);
+                                                 False);
        xfc->_NET_MOVERESIZE_WINDOW = XInternAtom(xfc->display,
                "_NET_MOVERESIZE_WINDOW", False);
        xfc->UTF8_STRING = XInternAtom(xfc->display, "UTF8_STRING", FALSE);
@@ -1902,13 +1902,13 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        xfc->format = PIXEL_FORMAT_RGBX32;
 
        if (xfc->depth == 32)
-               xfc->format = (!xfc->invert) ? PIXEL_FORMAT_RGBA32 : PIXEL_FORMAT_BGRA32;
+               xfc->format = (xfc->invert) ? PIXEL_FORMAT_RGBA32 : PIXEL_FORMAT_BGRA32;
        else if (xfc->depth == 24)
-               xfc->format = (!xfc->invert) ? PIXEL_FORMAT_RGBX32 : PIXEL_FORMAT_BGRX32;
+               xfc->format = (xfc->invert) ? PIXEL_FORMAT_RGBX32 : PIXEL_FORMAT_BGRX32;
        else if (xfc->depth == 16)
-               xfc->format = (!xfc->invert) ? PIXEL_FORMAT_RGB16 : PIXEL_FORMAT_BGR16;
+               xfc->format = (xfc->invert) ? PIXEL_FORMAT_RGB16 : PIXEL_FORMAT_BGR16;
        else if (xfc->depth == 15)
-               xfc->format = (!xfc->invert) ? PIXEL_FORMAT_RGB16 : PIXEL_FORMAT_BGR16;
+               xfc->format = (xfc->invert) ? PIXEL_FORMAT_RGB16 : PIXEL_FORMAT_BGR16;
        else
                xfc->format = PIXEL_FORMAT_RGBX32;
 
index ba0d6cd..0b0a21f 100644 (file)
@@ -129,7 +129,7 @@ FREERDP_API void freerdp_bitmap_planar_context_free(
 FREERDP_API INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
                                     const BYTE* pSrcData, UINT32 SrcSize,
                                     BYTE* pDstData, UINT32 DstFormat,
-                                    INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+                                    UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
                                     UINT32 nWidth, UINT32 nHeight, BOOL vFlip);
 
 #ifdef __cplusplus
index 0740a8e..ee2a452 100644 (file)
@@ -163,7 +163,7 @@ static BOOL update_gdi_cache_bitmap_v2(rdpContext* context,
 
        prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV2->cacheId, cacheBitmapV2->cacheIndex);
 
-       if (bitmap->New(context, bitmap))
+       if (!bitmap->New(context, bitmap))
                return FALSE;
 
        if (prevBitmap)
@@ -199,7 +199,7 @@ static BOOL update_gdi_cache_bitmap_v3(rdpContext* context,
                        bitmapData->bpp, bitmapData->length, compressed,
                        bitmapData->codecID);
 
-       if (bitmap->New(context, bitmap))
+       if (!bitmap->New(context, bitmap))
                return FALSE;
 
        prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV3->cacheId, cacheBitmapV3->cacheIndex);
@@ -251,9 +251,11 @@ static BOOL update_gdi_bitmap_update(rdpContext* context,
                        bitmap->Free(context, bitmap);
 
                reused = TRUE;
-               bitmap->New(context, bitmap);
+               if (!bitmap->New(context, bitmap))
+                       return FALSE;
 
-               bitmap->Paint(context, bitmap);
+               if (!bitmap->Paint(context, bitmap))
+                       return FALSE;
        }
        return TRUE;
 }
index 5e5951e..7625b3a 100644 (file)
@@ -25,7 +25,7 @@
  * Write a foreground/background image to a destination buffer.
  */
 static BYTE* WRITEFGBGIMAGE(BYTE* pbDest, UINT32 rowDelta,
-       BYTE bitmask, PIXEL fgPel, UINT32 cBits)
+    BYTE bitmask, PIXEL fgPel, INT32 cBits)
 {
        PIXEL xorPixel;
 
index 329987c..e8370d3 100644 (file)
@@ -267,14 +267,14 @@ INT32 interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
        if (!interleaved)
                return -1;
 
-       if (nDstStep < 0)
+       if (nDstStep <= 0)
                nDstStep = nWidth * dstBytesPerPixel;
 
        switch(bpp)
        {
        case 24:
                scanline = nWidth * 3;
-               SrcFormat = PIXEL_FORMAT_RGB24_VF;
+               SrcFormat = PIXEL_FORMAT_BGR24_VF;
                break;
        case 16:
                scanline = nWidth * 2;
index 46d328a..7c491ad 100644 (file)
@@ -279,7 +279,7 @@ static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
 INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
                        const BYTE* pSrcData, UINT32 SrcSize,
                        BYTE* pDstData, UINT32 DstFormat,
-                       INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+                       UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
                        UINT32 nWidth, UINT32 nHeight, BOOL vFlip)
 {
        BOOL cs;
@@ -309,7 +309,7 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
        dstBitsPerPixel = GetBitsPerPixel(DstFormat);
        dstBytesPerPixel = GetBytesPerPixel(DstFormat);
 
-       if (nDstStep < 0)
+       if (nDstStep <= 0)
                nDstStep = nWidth * GetBytesPerPixel(DstFormat);
 
        srcp = pSrcData;
@@ -489,29 +489,29 @@ INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
                        if (alpha)
                        {
                                status = planar_decompress_plane_rle(planes[3], rleSizes[3],
-                                                                    pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
+                                                                        pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
                                                                         vFlip); /* AlphaPlane */
                                status = planar_decompress_plane_rle(planes[0], rleSizes[0],
-                                                                    pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+                                                                        pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
                                                                         vFlip); /* RedPlane */
                                status = planar_decompress_plane_rle(planes[1], rleSizes[1],
-                                                                    pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+                                                                        pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
                                                                         vFlip); /* GreenPlane */
                                status = planar_decompress_plane_rle(planes[2], rleSizes[2],
-                                                                    pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+                                                                        pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
                                                                         vFlip); /* BluePlane */
                                srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3];
                        }
                        else /* NoAlpha */
                        {
                                status = planar_decompress_plane_rle(planes[0], rleSizes[0],
-                                                                    pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+                                                                        pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
                                                                         vFlip); /* RedPlane */
                                status = planar_decompress_plane_rle(planes[1], rleSizes[1],
-                                                                    pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+                                                                        pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
                                                                         vFlip); /* GreenPlane */
                                status = planar_decompress_plane_rle(planes[2], rleSizes[2],
-                                                                    pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+                                                                        pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
                                                                         vFlip); /* BluePlane */
                                srcp += rleSizes[0] + rleSizes[1] + rleSizes[2];
                        }
@@ -1163,7 +1163,7 @@ BOOL freerdp_bitmap_planar_context_reset(
 }
 
 BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(
-    DWORD flags, UINT32 maxWidth, UINT32 maxHeight)
+       DWORD flags, UINT32 maxWidth, UINT32 maxHeight)
 {
        BITMAP_PLANAR_CONTEXT* context;
        context = (BITMAP_PLANAR_CONTEXT*) calloc(1, sizeof(BITMAP_PLANAR_CONTEXT));
index 8074fcc..01cdd02 100644 (file)
@@ -151,7 +151,7 @@ BOOL Pointer_SetDefault(rdpContext* context)
 BOOL Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
 {
        return IFCALLRESULT(TRUE, context->graphics->Pointer_Prototype->SetPosition,
-                           context, x, y);
+                               context, x, y);
 }
 
 void graphics_register_pointer(rdpGraphics* graphics, rdpPointer* pointer)
@@ -192,7 +192,7 @@ BOOL Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y)
 }
 
 BOOL Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height,
-                    UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant)
+                        UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant)
 {
        return context->graphics->Glyph_Prototype->BeginDraw(context, x, y, width,
                height, bgcolor, fgcolor, fOpRedundant);
index 684fb8b..5ec1dab 100644 (file)
@@ -185,7 +185,7 @@ static BOOL BitBlt_SRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                return TRUE;
 
        if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
-           !gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc))
+               !gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc))
        {
                for (y = 0; y < nHeight; y++)
                {
@@ -228,8 +228,8 @@ static BOOL BitBlt_SRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 }
 
 static BOOL BitBlt_NOTSRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
-                             UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
-                             UINT32 nXSrc, UINT32 nYSrc)
+                                 UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+                                 UINT32 nXSrc, UINT32 nYSrc)
 {
        UINT32 x, y;
 
@@ -243,7 +243,7 @@ static BOOL BitBlt_NOTSRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        const BYTE* srcp = gdi_get_bitmap_pointer(
                                                   hdcSrc, nXSrc + x, nYSrc + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                            hdcDest, nXDest + x, nYDest + y);
+                                                hdcDest, nXDest + x, nYDest + y);
 
                        if (srcp && dstp)
                        {
@@ -259,8 +259,8 @@ static BOOL BitBlt_NOTSRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 }
 
 static BOOL BitBlt_SRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
-                           UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
-                           UINT32 nXSrc, UINT32 nYSrc)
+                               UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+                               UINT32 nXSrc, UINT32 nYSrc)
 {
        UINT32 x, y;
 
@@ -274,7 +274,7 @@ static BOOL BitBlt_SRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        const BYTE* srcp = gdi_get_bitmap_pointer(
                                                   hdcSrc, nXSrc + x, nYSrc + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                            hdcDest, nXDest + x, nYDest + y);
+                                                hdcDest, nXDest + x, nYDest + y);
 
                        if (srcp && dstp)
                        {
@@ -293,8 +293,8 @@ static BOOL BitBlt_SRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 }
 
 static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
-                              UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
-                              UINT32 nXSrc, UINT32 nYSrc)
+                                  UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+                                  UINT32 nXSrc, UINT32 nYSrc)
 {
        UINT32 x, y;
 
@@ -308,7 +308,7 @@ static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        const BYTE* srcp = gdi_get_bitmap_pointer(
                                                   hdcSrc, nXSrc + x, nYSrc + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                            hdcDest, nXDest + x, nYDest + y);
+                                                hdcDest, nXDest + x, nYDest + y);
 
                        if (srcp && dstp)
                        {
@@ -317,7 +317,7 @@ static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
 
                                colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, NULL);
+                                                         hdcDest->format, NULL);
 
                                color = ~colorA & ~colorB;
                                WriteColor(dstp, hdcDest->format, color);
@@ -329,8 +329,8 @@ static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 }
 
 static BOOL BitBlt_SRCINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
-                            UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
-                            UINT32 nXSrc, UINT32 nYSrc)
+                                UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+                                UINT32 nXSrc, UINT32 nYSrc)
 {
        UINT32 x, y;
 
@@ -344,7 +344,7 @@ static BOOL BitBlt_SRCINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        const BYTE* srcp = gdi_get_bitmap_pointer(
                                                   hdcSrc, nXSrc + x, nYSrc + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                            hdcDest, nXDest + x, nYDest + y);
+                                                hdcDest, nXDest + x, nYDest + y);
 
                        if (srcp && dstp)
                        {
@@ -353,7 +353,7 @@ static BOOL BitBlt_SRCINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
 
                                colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, NULL);
+                                                         hdcDest->format, NULL);
 
                                color = colorA ^ colorB;
                                WriteColor(dstp, hdcDest->format, color);
@@ -380,7 +380,7 @@ static BOOL BitBlt_SRCAND(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        const BYTE* srcp = gdi_get_bitmap_pointer(
                                                   hdcSrc, nXSrc + x, nYSrc + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                            hdcDest, nXDest + x, nYDest + y);
+                                                hdcDest, nXDest + x, nYDest + y);
 
                        if (srcp && dstp)
                        {
@@ -389,7 +389,7 @@ static BOOL BitBlt_SRCAND(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
 
                                colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, NULL);
+                                                         hdcDest->format, NULL);
 
                                color = colorA & colorB;
                                WriteColor(dstp, hdcDest->format, color);
@@ -401,8 +401,8 @@ static BOOL BitBlt_SRCAND(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 }
 
 static BOOL BitBlt_SRCPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
-                           UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
-                           UINT32 nXSrc, UINT32 nYSrc)
+                               UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+                               UINT32 nXSrc, UINT32 nYSrc)
 {
        UINT32 x, y;
 
@@ -416,7 +416,7 @@ static BOOL BitBlt_SRCPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        const BYTE* srcp = gdi_get_bitmap_pointer(
                                                   hdcSrc, nXSrc + x, nYSrc + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                            hdcDest, nXDest + x, nYDest + y);
+                                                hdcDest, nXDest + x, nYDest + y);
 
                        if (srcp && dstp)
                        {
@@ -425,7 +425,7 @@ static BOOL BitBlt_SRCPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
 
                                colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, NULL);
+                                                         hdcDest->format, NULL);
 
                                color = colorA | colorB;
                                WriteColor(dstp, hdcDest->format, color);
@@ -456,7 +456,7 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        const BYTE* srcp = gdi_get_bitmap_pointer(
                                                   hdcSrc, nXSrc + x, nYSrc + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                            hdcDest, nXDest + x, nYDest + y);
+                                                hdcDest, nXDest + x, nYDest + y);
 
                        if (srcp && dstp)
                        {
@@ -465,7 +465,7 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
 
                                colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, NULL);
+                                                         hdcDest->format, NULL);
 
                                color = (colorA & color) | (~colorA & colorB);
                                WriteColor(dstp, hdcDest->format, color);
@@ -497,7 +497,7 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                const BYTE* srcp = gdi_get_bitmap_pointer(
                                                           hdcSrc, nXSrc + x, nYSrc + y);
                                BYTE* dstp = gdi_get_bitmap_pointer(
-                                                    hdcDest, nXDest + x, nYDest + y);
+                                                        hdcDest, nXDest + x, nYDest + y);
 
                                if (srcp && dstp)
                                {
@@ -506,7 +506,7 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                        UINT32 colorB = ReadColor(dstp, hdcDest->format);
 
                                        colorA = ConvertColor(colorA, hdcSrc->format,
-                                                             hdcDest->format, NULL);
+                                                                 hdcDest->format, NULL);
 
                                        color = (colorA & colorB) | (~colorA & colorC);
                                        WriteColor(dstp, hdcDest->format, color);
@@ -525,7 +525,7 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                const BYTE* patp = gdi_get_brush_pointer(
                                                           hdcDest, nXDest + x, nYDest + y);
                                BYTE* dstp = gdi_get_bitmap_pointer(
-                                                    hdcDest, nXDest + x, nYDest + y);
+                                                        hdcDest, nXDest + x, nYDest + y);
 
                                if (srcp && dstp)
                                {
@@ -535,7 +535,7 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                        UINT32 colorC = ReadColor(patp, hdcDest->format);
 
                                        colorA = ConvertColor(colorA, hdcSrc->format,
-                                                             hdcDest->format, NULL);
+                                                                 hdcDest->format, NULL);
 
                                        color = (colorA & colorB) | (~colorA & colorC);
                                        WriteColor(dstp, hdcDest->format, color);
@@ -568,7 +568,7 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                const BYTE* srcp = gdi_get_bitmap_pointer(
                                                           hdcSrc, nXSrc + x, nYSrc + y);
                                BYTE* dstp = gdi_get_bitmap_pointer(
-                                                    hdcDest, nXDest + x, nYDest + y);
+                                                        hdcDest, nXDest + x, nYDest + y);
 
                                if (srcp && dstp)
                                {
@@ -577,7 +577,7 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                        UINT32 colorB = ReadColor(dstp, hdcDest->format);
 
                                        colorA = ConvertColor(colorA, hdcSrc->format,
-                                                             hdcDest->format, NULL);
+                                                                 hdcDest->format, NULL);
 
                                        colorD = colorA ^ (color & (colorB ^ colorA));
                                        WriteColor(dstp, hdcDest->format, color);
@@ -596,7 +596,7 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                const BYTE* patp = gdi_get_brush_pointer(
                                                           hdcDest, nXDest + x, nYDest + y);
                                BYTE* dstp = gdi_get_bitmap_pointer(
-                                                    hdcDest, nXDest + x, nYDest + y);
+                                                        hdcDest, nXDest + x, nYDest + y);
 
                                if (srcp && dstp)
                                {
@@ -606,7 +606,7 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                        UINT32 color = ReadColor(patp, hdcDest->format);
 
                                        colorA = ConvertColor(colorA, hdcSrc->format,
-                                                             hdcDest->format, NULL);
+                                                                 hdcDest->format, NULL);
 
                                        colorD = colorA ^ (color & (colorB ^ colorA));
                                        WriteColor(dstp, hdcDest->format, color);
@@ -642,7 +642,7 @@ static BOOL BitBlt_SPna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(patp, hdcDest->format);
 
                                colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, NULL);
+                                                         hdcDest->format, NULL);
                                color = colorA & ~colorB;
                                WriteColor(dstp, hdcDest->format, color);
                        }
@@ -666,9 +666,9 @@ static BOOL BitBlt_DSna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                for (x = 0; x < nWidth; x++)
                {
                        const BYTE* srcp = gdi_get_bitmap_pointer(
-                                      hdcSrc, nXSrc + x, nYSrc + y);
+                                          hdcSrc, nXSrc + x, nYSrc + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                      hdcDest, nXDest + x, nYDest + y);
+                                          hdcDest, nXDest + x, nYDest + y);
                        if (srcp && dstp)
                        {
                                UINT32 color;
@@ -676,7 +676,7 @@ static BOOL BitBlt_DSna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
 
                                colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, NULL);
+                                                         hdcDest->format, NULL);
 
                                color = ~colorA & colorB;
                                WriteColor(dstp, hdcDest->format, color);
@@ -690,8 +690,8 @@ static BOOL BitBlt_DSna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 
 
 static BOOL BitBlt_MERGECOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
-                            UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
-                            UINT32 nXSrc, UINT32 nYSrc)
+                                UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+                                UINT32 nXSrc, UINT32 nYSrc)
 {
        UINT32 x, y;
 
@@ -707,7 +707,7 @@ static BOOL BitBlt_MERGECOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        const BYTE* patp = gdi_get_brush_pointer(
                                                   hdcDest, nXDest + x, nYDest + y);
                        BYTE* dstp = gdi_get_bitmap_pointer(
-                                            hdcDest, nXDest + x, nYDest + y);
+                                                hdcDest, nXDest + x, nYDest + y);
 
                        if (srcp && patp && dstp)
                        {
@@ -716,7 +716,7 @@ static BOOL BitBlt_MERGECOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(patp, hdcDest->format);
 
                                colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, NULL);
+                                                         hdcDest->format, NULL);
                                color = colorA & colorB;
                                WriteColor(dstp, hdcDest->format, color);
                        }
@@ -727,8 +727,8 @@ static BOOL BitBlt_MERGECOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 }
 
 static BOOL BitBlt_MERGEPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
-                             UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
-                             UINT32 nXSrc, UINT32 nYSrc)
+                                 UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+                                 UINT32 nXSrc, UINT32 nYSrc)
 {
        UINT32 x, y;
 
index f85a115..553edc1 100644 (file)
@@ -39,7 +39,7 @@
 /* Bitmap Class */
 
 HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
-                              UINT32 SrcFormat, BYTE* data)
+                                                         UINT32 SrcFormat, BYTE* data)
 {
        UINT32 nSrcStep;
        UINT32 nDstStep;
@@ -55,7 +55,7 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
        pSrcData = data;
        nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
        freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0,
-                          nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0, gdi->palette);
+                                          nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0, gdi->palette);
        bitmap = gdi_CreateBitmap(nWidth, nHeight, gdi->dstFormat, pDstData);
        return bitmap;
 }
@@ -72,49 +72,15 @@ static BOOL gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
 
        if (!bitmap->data)
                gdi_bitmap->bitmap = gdi_CreateCompatibleBitmap(
-                                        gdi->hdc, bitmap->width,
-                                        bitmap->height);
+                                                                gdi->hdc, bitmap->width,
+                                                                bitmap->height);
        else
        {
-               UINT32 format;
-
-               switch (bitmap->bpp)
-               {
-                       case 32:
-                               format = PIXEL_FORMAT_RGBX32;
-                               break;
-
-                       case 24:
-                               format = PIXEL_FORMAT_RGB24;
-                               break;
-
-                       case 16:
-                               format = PIXEL_FORMAT_RGB16;
-                               break;
-
-                       case 15:
-                               format = PIXEL_FORMAT_RGB15;
-                               break;
-
-                       case 8:
-                               format = PIXEL_FORMAT_RGB8;
-                               break;
-
-                       case 4:
-                               format = PIXEL_FORMAT_A4;
-                               break;
-
-                       case 1:
-                               format = PIXEL_FORMAT_MONO;
-                               break;
-
-                       default:
-                               return FALSE;
-               }
+               UINT32 format = bitmap->format;
 
                gdi_bitmap->bitmap = gdi_create_bitmap(gdi, bitmap->width,
-                                                      bitmap->height,
-                                                      format, bitmap->data);
+                                                                                          bitmap->height,
+                                                                                          format, bitmap->data);
        }
 
        if (!gdi_bitmap->bitmap)
@@ -147,13 +113,13 @@ static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
        width = bitmap->right - bitmap->left + 1;
        height = bitmap->bottom - bitmap->top + 1;
        return gdi_BitBlt(context->gdi->primary->hdc, bitmap->left, bitmap->top,
-                         width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY);
+                                         width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY);
 }
 
 static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
-                                  const BYTE* data, UINT32 width, UINT32 height,
-                                  UINT32 bpp, UINT32 length, BOOL compressed,
-                                  UINT32 codecId)
+                                                                 const BYTE* data, UINT32 width, UINT32 height,
+                                                                 UINT32 bpp, UINT32 length, BOOL compressed,
+                                                                 UINT32 codecId)
 {
        int status;
        UINT16 size;
@@ -175,11 +141,11 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
                if (bpp < 32)
                {
                        status = interleaved_decompress(gdi->codecs->interleaved,
-                                                       pSrcData, SrcSize,
-                                                       bpp,
-                                                       pDstData, gdi->dstFormat,
-                                                       -1, 0, 0, width, height,
-                                                       gdi->palette);
+                                                                                       pSrcData, SrcSize,
+                                                                                       bpp,
+                                                                                       pDstData, gdi->dstFormat,
+                                                                                       0, 0, 0, width, height,
+                                                                                       gdi->palette);
                }
                else
                {
@@ -195,19 +161,20 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
        }
        else
        {
-               SrcFormat = gdi_get_pixel_format(bpp, TRUE);
-               status = freerdp_image_copy(pDstData, gdi->dstFormat, -1, 0, 0,
-                                           width, height, pSrcData, SrcFormat, -1, 0, 0, gdi->palette);
+               SrcFormat = gdi_get_pixel_format(bpp, FALSE);
+               status = freerdp_image_copy(pDstData, gdi->dstFormat, 0, 0, 0,
+                                                                       width, height, pSrcData, SrcFormat,
+                                                                       0, 0, 0, gdi->palette);
        }
 
        bitmap->compressed = FALSE;
        bitmap->length = size;
-       bitmap->bpp = GetBitsPerPixel(gdi->dstFormat);
+       bitmap->format = gdi->dstFormat;
        return TRUE;
 }
 
 static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
-                                  BOOL primary)
+                                                                 BOOL primary)
 {
        rdpGdi* gdi = context->gdi;
 
@@ -240,7 +207,7 @@ static BOOL gdi_Glyph_New(rdpContext* context, rdpGlyph* glyph)
        }
 
        gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
-                                            data);
+                                                                                data);
 
        if (!gdi_glyph->bitmap)
        {
@@ -269,18 +236,18 @@ static void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
 }
 
 static BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x,
-                           UINT32 y)
+                                                  UINT32 y)
 {
        gdiGlyph* gdi_glyph;
        rdpGdi* gdi = context->gdi;
        gdi_glyph = (gdiGlyph*) glyph;
        return gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width,
-                         gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, GDI_DSPDxax);
+                                         gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, GDI_DSPDxax);
 }
 
 static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
-                                UINT32 width, UINT32 height, UINT32 bgcolor,
-                                UINT32 fgcolor, BOOL fOpRedundant)
+                                                               UINT32 width, UINT32 height, UINT32 bgcolor,
+                                                               UINT32 fgcolor, BOOL fOpRedundant)
 {
        GDI_RECT rect;
        HGDI_BRUSH brush;
@@ -303,18 +270,17 @@ out:
 }
 
 static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
-                              UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
+                                                         UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
 {
        rdpGdi* gdi = context->gdi;
        UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
        bgcolor = ConvertColor(bgcolor, SrcFormat,
-                              gdi->dstFormat, gdi->palette);
+                                                  gdi->dstFormat, gdi->palette);
        gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
        return TRUE;
 }
 
 /* Graphics Module */
-
 BOOL gdi_register_graphics(rdpGraphics* graphics)
 {
        rdpBitmap* bitmap;