Coverage Report

Created: 2024-09-08 06:16

/src/FreeRDP/libfreerdp/gdi/bitmap.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * FreeRDP: A Remote Desktop Protocol Implementation
3
 * GDI Bitmap Functions
4
 *
5
 * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
 * Copyright 2016 Armin Novak <armin.novak@thincast.com>
7
 * Copyright 2016 Thincast Technologies GmbH
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 *     http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21
22
#include <freerdp/config.h>
23
24
#include <stdio.h>
25
#include <string.h>
26
#include <stdlib.h>
27
28
#include <freerdp/api.h>
29
#include <freerdp/freerdp.h>
30
#include <freerdp/gdi/gdi.h>
31
#include <freerdp/codec/color.h>
32
33
#include <freerdp/gdi/region.h>
34
#include <freerdp/gdi/bitmap.h>
35
#include <freerdp/log.h>
36
#include <freerdp/gdi/shape.h>
37
38
#include "brush.h"
39
#include "clipping.h"
40
#include "../gdi/gdi.h"
41
42
#define TAG FREERDP_TAG("gdi.bitmap")
43
44
/**
45
 * Get pixel at the given coordinates. msdn{dd144909}
46
 * @param hdc device context
47
 * @param nXPos pixel x position
48
 * @param nYPos pixel y position
49
 * @return pixel color
50
 */
51
52
UINT32 gdi_GetPixel(HGDI_DC hdc, UINT32 nXPos, UINT32 nYPos)
53
0
{
54
0
  HGDI_BITMAP hBmp = (HGDI_BITMAP)hdc->selectedObject;
55
0
  BYTE* data =
56
0
      &(hBmp->data[(nYPos * hBmp->scanline) + nXPos * FreeRDPGetBytesPerPixel(hBmp->format)]);
57
0
  return FreeRDPReadColor(data, hBmp->format);
58
0
}
59
60
BYTE* gdi_GetPointer(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y)
61
0
{
62
0
  UINT32 bpp = FreeRDPGetBytesPerPixel(hBmp->format);
63
0
  return &hBmp->data[(Y * hBmp->width * bpp) + X * bpp];
64
0
}
65
66
/**
67
 * Set pixel at the given coordinates. msdn{dd145078}
68
 *
69
 * @param hBmp device context
70
 * @param X pixel x position
71
 * @param Y pixel y position
72
 * @param crColor new pixel color
73
 * @return the color written
74
 */
75
76
static INLINE UINT32 gdi_SetPixelBmp(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y, UINT32 crColor)
77
0
{
78
0
  BYTE* p = &hBmp->data[(Y * hBmp->scanline) + X * FreeRDPGetBytesPerPixel(hBmp->format)];
79
0
  FreeRDPWriteColor(p, hBmp->format, crColor);
80
0
  return crColor;
81
0
}
82
83
UINT32 gdi_SetPixel(HGDI_DC hdc, UINT32 X, UINT32 Y, UINT32 crColor)
84
0
{
85
0
  HGDI_BITMAP hBmp = (HGDI_BITMAP)hdc->selectedObject;
86
0
  return gdi_SetPixelBmp(hBmp, X, Y, crColor);
87
0
}
88
89
/**
90
 * Create a new bitmap with the given width, height, color format and pixel buffer. msdn{dd183485}
91
 *
92
 * @param nWidth width
93
 * @param nHeight height
94
 * @param format the color format used
95
 * @param data pixel buffer
96
 * @return new bitmap
97
 */
98
99
HGDI_BITMAP gdi_CreateBitmap(UINT32 nWidth, UINT32 nHeight, UINT32 format, BYTE* data)
100
0
{
101
0
  return gdi_CreateBitmapEx(nWidth, nHeight, format, 0, data, winpr_aligned_free);
102
0
}
103
104
/**
105
 * Create a new bitmap with the given width, height, color format and pixel buffer. msdn{dd183485}
106
 *
107
 * @param nWidth width
108
 * @param nHeight height
109
 * @param format the color format used
110
 * @param data pixel buffer
111
 * @param fkt_free The function used for deallocation of the buffer, NULL for none.
112
 * @return new bitmap
113
 */
114
115
HGDI_BITMAP gdi_CreateBitmapEx(UINT32 nWidth, UINT32 nHeight, UINT32 format, UINT32 stride,
116
                               BYTE* data, void (*fkt_free)(void*))
117
0
{
118
0
  HGDI_BITMAP hBitmap = (HGDI_BITMAP)calloc(1, sizeof(GDI_BITMAP));
119
120
0
  if (!hBitmap)
121
0
    return NULL;
122
123
0
  hBitmap->objectType = GDIOBJECT_BITMAP;
124
0
  hBitmap->format = format;
125
126
0
  if (stride > 0)
127
0
    hBitmap->scanline = stride;
128
0
  else
129
0
    hBitmap->scanline = nWidth * FreeRDPGetBytesPerPixel(hBitmap->format);
130
131
0
  hBitmap->width = nWidth;
132
0
  hBitmap->height = nHeight;
133
0
  hBitmap->data = data;
134
0
  hBitmap->free = fkt_free;
135
0
  return hBitmap;
136
0
}
137
138
/**
139
 * Create a new bitmap of the given width and height compatible with the current device context.
140
 * msdn{dd183488}
141
 *
142
 * @param hdc device context
143
 * @param nWidth width
144
 * @param nHeight height
145
 *
146
 * @return new bitmap
147
 */
148
149
HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, UINT32 nWidth, UINT32 nHeight)
150
0
{
151
0
  HGDI_BITMAP hBitmap = (HGDI_BITMAP)calloc(1, sizeof(GDI_BITMAP));
152
153
0
  if (!hBitmap)
154
0
    return NULL;
155
156
0
  hBitmap->objectType = GDIOBJECT_BITMAP;
157
0
  hBitmap->format = hdc->format;
158
0
  WINPR_ASSERT(nWidth <= INT32_MAX);
159
0
  hBitmap->width = (INT32)nWidth;
160
161
0
  WINPR_ASSERT(nHeight <= INT32_MAX);
162
0
  hBitmap->height = (INT32)nHeight;
163
164
0
  size_t size = 1ull * nWidth * nHeight * FreeRDPGetBytesPerPixel(hBitmap->format);
165
0
  hBitmap->data = winpr_aligned_malloc(size, 16);
166
0
  hBitmap->free = winpr_aligned_free;
167
168
0
  if (!hBitmap->data)
169
0
  {
170
0
    free(hBitmap);
171
0
    return NULL;
172
0
  }
173
174
  /* Initialize with 0xff */
175
0
  memset(hBitmap->data, 0xff, size);
176
0
  hBitmap->scanline = nWidth * FreeRDPGetBytesPerPixel(hBitmap->format);
177
0
  return hBitmap;
178
0
}
179
180
static BOOL op_not(UINT32* stack, const UINT32* stackp)
181
0
{
182
0
  if (!stack || !stackp)
183
0
    return FALSE;
184
185
0
  if (*stackp < 1)
186
0
    return FALSE;
187
188
0
  stack[(*stackp) - 1] = ~stack[(*stackp) - 1];
189
0
  return TRUE;
190
0
}
191
192
static BOOL op_and(UINT32* stack, UINT32* stackp)
193
0
{
194
0
  if (!stack || !stackp)
195
0
    return FALSE;
196
197
0
  if (*stackp < 2)
198
0
    return FALSE;
199
200
0
  (*stackp)--;
201
0
  stack[(*stackp) - 1] &= stack[(*stackp)];
202
0
  return TRUE;
203
0
}
204
205
static BOOL op_or(UINT32* stack, UINT32* stackp)
206
0
{
207
0
  if (!stack || !stackp)
208
0
    return FALSE;
209
210
0
  if (*stackp < 2)
211
0
    return FALSE;
212
213
0
  (*stackp)--;
214
0
  stack[(*stackp) - 1] |= stack[(*stackp)];
215
0
  return TRUE;
216
0
}
217
218
static BOOL op_xor(UINT32* stack, UINT32* stackp)
219
0
{
220
0
  if (!stack || !stackp)
221
0
    return FALSE;
222
223
0
  if (*stackp < 2)
224
0
    return FALSE;
225
226
0
  (*stackp)--;
227
0
  stack[(*stackp) - 1] ^= stack[(*stackp)];
228
0
  return TRUE;
229
0
}
230
231
static UINT32 process_rop(UINT32 src, UINT32 dst, UINT32 pat, const char* rop, UINT32 format)
232
0
{
233
0
  UINT32 stack[10] = { 0 };
234
0
  UINT32 stackp = 0;
235
236
0
  while (*rop != '\0')
237
0
  {
238
0
    char op = *rop++;
239
240
0
    switch (op)
241
0
    {
242
0
      case '0':
243
0
        stack[stackp++] = FreeRDPGetColor(format, 0, 0, 0, 0xFF);
244
0
        break;
245
246
0
      case '1':
247
0
        stack[stackp++] = FreeRDPGetColor(format, 0xFF, 0xFF, 0xFF, 0xFF);
248
0
        break;
249
250
0
      case 'D':
251
0
        stack[stackp++] = dst;
252
0
        break;
253
254
0
      case 'S':
255
0
        stack[stackp++] = src;
256
0
        break;
257
258
0
      case 'P':
259
0
        stack[stackp++] = pat;
260
0
        break;
261
262
0
      case 'x':
263
0
        op_xor(stack, &stackp);
264
0
        break;
265
266
0
      case 'a':
267
0
        op_and(stack, &stackp);
268
0
        break;
269
270
0
      case 'o':
271
0
        op_or(stack, &stackp);
272
0
        break;
273
274
0
      case 'n':
275
0
        op_not(stack, &stackp);
276
0
        break;
277
278
0
      default:
279
0
        break;
280
0
    }
281
0
  }
282
283
0
  return stack[0];
284
0
}
285
286
static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, INT32 nYDest,
287
                                INT32 nXSrc, INT32 nYSrc, INT32 x, INT32 y, BOOL useSrc,
288
                                BOOL usePat, UINT32 style, const char* rop,
289
                                const gdiPalette* palette)
290
0
{
291
0
  UINT32 dstColor = 0;
292
0
  UINT32 colorA = 0;
293
0
  UINT32 colorB = 0;
294
0
  UINT32 colorC = 0;
295
0
  const INT32 dstX = nXDest + x;
296
0
  const INT32 dstY = nYDest + y;
297
0
  BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, dstX, dstY);
298
299
0
  if (!dstp)
300
0
  {
301
0
    WLog_ERR(TAG, "dstp=%p", (const void*)dstp);
302
0
    return FALSE;
303
0
  }
304
305
0
  colorA = FreeRDPReadColor(dstp, hdcDest->format);
306
307
0
  if (useSrc)
308
0
  {
309
0
    const BYTE* srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc + x, nYSrc + y);
310
311
0
    if (!srcp)
312
0
    {
313
0
      WLog_ERR(TAG, "srcp=%p", (const void*)srcp);
314
0
      return FALSE;
315
0
    }
316
317
0
    colorC = FreeRDPReadColor(srcp, hdcSrc->format);
318
0
    colorC = FreeRDPConvertColor(colorC, hdcSrc->format, hdcDest->format, palette);
319
0
  }
320
321
0
  if (usePat)
322
0
  {
323
0
    switch (style)
324
0
    {
325
0
      case GDI_BS_SOLID:
326
0
        colorB = hdcDest->brush->color;
327
0
        break;
328
329
0
      case GDI_BS_HATCHED:
330
0
      case GDI_BS_PATTERN:
331
0
      {
332
0
        const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
333
334
0
        if (!patp)
335
0
        {
336
0
          WLog_ERR(TAG, "patp=%p", (const void*)patp);
337
0
          return FALSE;
338
0
        }
339
340
0
        colorB = FreeRDPReadColor(patp, hdcDest->format);
341
0
      }
342
0
      break;
343
344
0
      default:
345
0
        break;
346
0
    }
347
0
  }
348
349
0
  dstColor = process_rop(colorC, colorA, colorB, rop, hdcDest->format);
350
0
  return FreeRDPWriteColor(dstp, hdcDest->format, dstColor);
351
0
}
352
353
static BOOL adjust_src_coordinates(HGDI_DC hdcSrc, INT32 nWidth, INT32 nHeight, INT32* px,
354
                                   INT32* py)
355
0
{
356
0
  HGDI_BITMAP hSrcBmp = NULL;
357
0
  INT32 nXSrc = 0;
358
0
  INT32 nYSrc = 0;
359
360
0
  if (!hdcSrc || (nWidth < 0) || (nHeight < 0) || !px || !py)
361
0
    return FALSE;
362
363
0
  hSrcBmp = (HGDI_BITMAP)hdcSrc->selectedObject;
364
0
  nXSrc = *px;
365
0
  nYSrc = *py;
366
367
0
  if (!hSrcBmp)
368
0
    return FALSE;
369
370
0
  if (nYSrc < 0)
371
0
  {
372
0
    nYSrc = 0;
373
0
    nHeight = nHeight + nYSrc;
374
0
  }
375
376
0
  if ((nXSrc) < 0)
377
0
  {
378
0
    nXSrc = 0;
379
0
    nWidth = nWidth + nXSrc;
380
0
  }
381
382
0
  if (hSrcBmp->width < (nXSrc + nWidth))
383
0
    nXSrc = hSrcBmp->width - nWidth;
384
385
0
  if (hSrcBmp->height < (nYSrc + nHeight))
386
0
    nYSrc = hSrcBmp->height - nHeight;
387
388
0
  if ((nXSrc < 0) || (nYSrc < 0))
389
0
    return FALSE;
390
391
0
  *px = nXSrc;
392
0
  *py = nYSrc;
393
0
  return TRUE;
394
0
}
395
396
static BOOL adjust_src_dst_coordinates(HGDI_DC hdcDest, INT32* pnXSrc, INT32* pnYSrc, INT32* pnXDst,
397
                                       INT32* pnYDst, INT32* pnWidth, INT32* pnHeight)
398
0
{
399
0
  HGDI_BITMAP hDstBmp = NULL;
400
0
  volatile INT32 diffX = 0;
401
0
  volatile INT32 diffY = 0;
402
0
  volatile INT32 nXSrc = 0;
403
0
  volatile INT32 nYSrc = 0;
404
0
  volatile INT32 nXDst = 0;
405
0
  volatile INT32 nYDst = 0;
406
0
  volatile INT32 nWidth = 0;
407
0
  volatile INT32 nHeight = 0;
408
409
0
  if (!hdcDest || !pnXSrc || !pnYSrc || !pnXDst || !pnYDst || !pnWidth || !pnHeight)
410
0
    return FALSE;
411
412
0
  hDstBmp = (HGDI_BITMAP)hdcDest->selectedObject;
413
0
  nXSrc = *pnXSrc;
414
0
  nYSrc = *pnYSrc;
415
0
  nXDst = *pnXDst;
416
0
  nYDst = *pnYDst;
417
0
  nWidth = *pnWidth;
418
0
  nHeight = *pnHeight;
419
420
0
  if (!hDstBmp)
421
0
    return FALSE;
422
423
0
  if (nXDst < 0)
424
0
  {
425
0
    nXSrc -= nXDst;
426
0
    nWidth += nXDst;
427
0
    nXDst = 0;
428
0
  }
429
430
0
  if (nYDst < 0)
431
0
  {
432
0
    nYSrc -= nYDst;
433
0
    nHeight += nYDst;
434
0
    nYDst = 0;
435
0
  }
436
437
0
  diffX = hDstBmp->width - nXDst - nWidth;
438
439
0
  if (diffX < 0)
440
0
    nWidth += diffX;
441
442
0
  diffY = hDstBmp->height - nYDst - nHeight;
443
444
0
  if (diffY < 0)
445
0
    nHeight += diffY;
446
447
0
  if ((nXDst < 0) || (nYDst < 0) || (nWidth < 0) || (nHeight < 0))
448
0
  {
449
0
    nXDst = 0;
450
0
    nYDst = 0;
451
0
    nWidth = 0;
452
0
    nHeight = 0;
453
0
  }
454
455
0
  *pnXSrc = nXSrc;
456
0
  *pnYSrc = nYSrc;
457
0
  *pnXDst = nXDst;
458
0
  *pnYDst = nYDst;
459
0
  *pnWidth = nWidth;
460
0
  *pnHeight = nHeight;
461
0
  return TRUE;
462
0
}
463
464
static BOOL BitBlt_process(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nWidth, INT32 nHeight,
465
                           HGDI_DC hdcSrc, INT32 nXSrc, INT32 nYSrc, const char* rop,
466
                           const gdiPalette* palette)
467
0
{
468
0
  UINT32 style = 0;
469
0
  BOOL useSrc = FALSE;
470
0
  BOOL usePat = FALSE;
471
0
  const char* iter = rop;
472
473
0
  while (*iter != '\0')
474
0
  {
475
0
    switch (*iter++)
476
0
    {
477
0
      case 'P':
478
0
        usePat = TRUE;
479
0
        break;
480
481
0
      case 'S':
482
0
        useSrc = TRUE;
483
0
        break;
484
485
0
      default:
486
0
        break;
487
0
    }
488
0
  }
489
490
0
  if (!hdcDest)
491
0
    return FALSE;
492
493
0
  if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth, &nHeight))
494
0
    return FALSE;
495
496
0
  if (useSrc && !hdcSrc)
497
0
    return FALSE;
498
499
0
  if (useSrc)
500
0
  {
501
0
    if (!adjust_src_coordinates(hdcSrc, nWidth, nHeight, &nXSrc, &nYSrc))
502
0
      return FALSE;
503
0
  }
504
505
0
  if (usePat)
506
0
  {
507
0
    style = gdi_GetBrushStyle(hdcDest);
508
509
0
    switch (style)
510
0
    {
511
0
      case GDI_BS_SOLID:
512
0
      case GDI_BS_HATCHED:
513
0
      case GDI_BS_PATTERN:
514
0
        break;
515
516
0
      default:
517
0
        WLog_ERR(TAG, "Invalid brush!!");
518
0
        return FALSE;
519
0
    }
520
0
  }
521
522
0
  if ((nXDest > nXSrc) && (nYDest > nYSrc))
523
0
  {
524
0
    for (INT32 y = nHeight - 1; y >= 0; y--)
525
0
    {
526
0
      for (INT32 x = nWidth - 1; x >= 0; x--)
527
0
      {
528
0
        if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc,
529
0
                          usePat, style, rop, palette))
530
0
          return FALSE;
531
0
      }
532
0
    }
533
0
  }
534
0
  else if (nXDest > nXSrc)
535
0
  {
536
0
    for (INT32 y = 0; y < nHeight; y++)
537
0
    {
538
0
      for (INT32 x = nWidth - 1; x >= 0; x--)
539
0
      {
540
0
        if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc,
541
0
                          usePat, style, rop, palette))
542
0
          return FALSE;
543
0
      }
544
0
    }
545
0
  }
546
0
  else if (nYDest > nYSrc)
547
0
  {
548
0
    for (INT32 y = nHeight - 1; y >= 0; y--)
549
0
    {
550
0
      for (INT32 x = 0; x < nWidth; x++)
551
0
      {
552
0
        if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc,
553
0
                          usePat, style, rop, palette))
554
0
          return FALSE;
555
0
      }
556
0
    }
557
0
  }
558
0
  else
559
0
  {
560
0
    for (INT32 y = 0; y < nHeight; y++)
561
0
    {
562
0
      for (INT32 x = 0; x < nWidth; x++)
563
0
      {
564
0
        if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc,
565
0
                          usePat, style, rop, palette))
566
0
          return FALSE;
567
0
      }
568
0
    }
569
0
  }
570
571
0
  return TRUE;
572
0
}
573
574
/**
575
 * Perform a bit blit operation on the given pixel buffers.
576
 * msdn{dd183370}
577
 *
578
 * @param hdcDest destination device context
579
 * @param nXDest destination x1
580
 * @param nYDest destination y1
581
 * @param nWidth width
582
 * @param nHeight height
583
 * @param hdcSrc source device context
584
 * @param nXSrc source x1
585
 * @param nYSrc source y1
586
 * @param rop raster operation code
587
 * @return 0 on failure, non-zero otherwise
588
 */
589
BOOL gdi_BitBlt(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nWidth, INT32 nHeight,
590
                HGDI_DC hdcSrc, INT32 nXSrc, INT32 nYSrc, DWORD rop, const gdiPalette* palette)
591
0
{
592
0
  HGDI_BITMAP hSrcBmp = NULL;
593
0
  HGDI_BITMAP hDstBmp = NULL;
594
595
0
  if (!hdcDest)
596
0
    return FALSE;
597
598
0
  if (!gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc))
599
0
    return TRUE;
600
601
  /* Check which ROP should be performed.
602
   * Some specific ROP are used heavily and are resource intensive,
603
   * add optimized versions for these here.
604
   *
605
   * For all others fall back to the generic implementation.
606
   */
607
0
  switch (rop)
608
0
  {
609
0
    case GDI_SRCCOPY:
610
0
      if (!hdcSrc)
611
0
        return FALSE;
612
613
0
      if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth,
614
0
                                      &nHeight))
615
0
        return FALSE;
616
617
0
      if (!adjust_src_coordinates(hdcSrc, nWidth, nHeight, &nXSrc, &nYSrc))
618
0
        return FALSE;
619
620
0
      hSrcBmp = (HGDI_BITMAP)hdcSrc->selectedObject;
621
0
      hDstBmp = (HGDI_BITMAP)hdcDest->selectedObject;
622
623
0
      if (!hSrcBmp || !hDstBmp)
624
0
        return FALSE;
625
626
0
      if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline, nXDest,
627
0
                              nYDest, nWidth, nHeight, hSrcBmp->data, hSrcBmp->format,
628
0
                              hSrcBmp->scanline, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE))
629
0
        return FALSE;
630
631
0
      break;
632
633
0
    case GDI_DSTCOPY:
634
0
      hSrcBmp = (HGDI_BITMAP)hdcDest->selectedObject;
635
0
      hDstBmp = (HGDI_BITMAP)hdcDest->selectedObject;
636
637
0
      if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth,
638
0
                                      &nHeight))
639
0
        return FALSE;
640
641
0
      if (!adjust_src_coordinates(hdcDest, nWidth, nHeight, &nXSrc, &nYSrc))
642
0
        return FALSE;
643
644
0
      if (!hSrcBmp || !hDstBmp)
645
0
        return FALSE;
646
647
0
      if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline, nXDest,
648
0
                              nYDest, nWidth, nHeight, hSrcBmp->data, hSrcBmp->format,
649
0
                              hSrcBmp->scanline, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE))
650
0
        return FALSE;
651
652
0
      break;
653
654
0
    default:
655
0
      if (!BitBlt_process(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc,
656
0
                          gdi_rop_to_string(rop), palette))
657
0
        return FALSE;
658
659
0
      break;
660
0
  }
661
662
0
  if (!gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight))
663
0
    return FALSE;
664
665
0
  return TRUE;
666
0
}