Coverage Report

Created: 2023-09-25 06:56

/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
  hBitmap->width = nWidth;
159
0
  hBitmap->height = nHeight;
160
0
  hBitmap->data = winpr_aligned_malloc(
161
0
      1ull * nWidth * nHeight * FreeRDPGetBytesPerPixel(hBitmap->format), 16);
162
0
  hBitmap->free = winpr_aligned_free;
163
164
0
  if (!hBitmap->data)
165
0
  {
166
0
    free(hBitmap);
167
0
    return NULL;
168
0
  }
169
170
0
  hBitmap->scanline = nWidth * FreeRDPGetBytesPerPixel(hBitmap->format);
171
0
  return hBitmap;
172
0
}
173
174
static BOOL op_not(UINT32* stack, UINT32* stackp)
175
0
{
176
0
  if (!stack || !stackp)
177
0
    return FALSE;
178
179
0
  if (*stackp < 1)
180
0
    return FALSE;
181
182
0
  stack[(*stackp) - 1] = ~stack[(*stackp) - 1];
183
0
  return TRUE;
184
0
}
185
186
static BOOL op_and(UINT32* stack, UINT32* stackp)
187
0
{
188
0
  if (!stack || !stackp)
189
0
    return FALSE;
190
191
0
  if (*stackp < 2)
192
0
    return FALSE;
193
194
0
  (*stackp)--;
195
0
  stack[(*stackp) - 1] &= stack[(*stackp)];
196
0
  return TRUE;
197
0
}
198
199
static BOOL op_or(UINT32* stack, UINT32* stackp)
200
0
{
201
0
  if (!stack || !stackp)
202
0
    return FALSE;
203
204
0
  if (*stackp < 2)
205
0
    return FALSE;
206
207
0
  (*stackp)--;
208
0
  stack[(*stackp) - 1] |= stack[(*stackp)];
209
0
  return TRUE;
210
0
}
211
212
static BOOL op_xor(UINT32* stack, UINT32* stackp)
213
0
{
214
0
  if (!stack || !stackp)
215
0
    return FALSE;
216
217
0
  if (*stackp < 2)
218
0
    return FALSE;
219
220
0
  (*stackp)--;
221
0
  stack[(*stackp) - 1] ^= stack[(*stackp)];
222
0
  return TRUE;
223
0
}
224
225
static UINT32 process_rop(UINT32 src, UINT32 dst, UINT32 pat, const char* rop, UINT32 format)
226
0
{
227
0
  UINT32 stack[10] = { 0 };
228
0
  UINT32 stackp = 0;
229
230
0
  while (*rop != '\0')
231
0
  {
232
0
    char op = *rop++;
233
234
0
    switch (op)
235
0
    {
236
0
      case '0':
237
0
        stack[stackp++] = FreeRDPGetColor(format, 0, 0, 0, 0xFF);
238
0
        break;
239
240
0
      case '1':
241
0
        stack[stackp++] = FreeRDPGetColor(format, 0xFF, 0xFF, 0xFF, 0xFF);
242
0
        break;
243
244
0
      case 'D':
245
0
        stack[stackp++] = dst;
246
0
        break;
247
248
0
      case 'S':
249
0
        stack[stackp++] = src;
250
0
        break;
251
252
0
      case 'P':
253
0
        stack[stackp++] = pat;
254
0
        break;
255
256
0
      case 'x':
257
0
        op_xor(stack, &stackp);
258
0
        break;
259
260
0
      case 'a':
261
0
        op_and(stack, &stackp);
262
0
        break;
263
264
0
      case 'o':
265
0
        op_or(stack, &stackp);
266
0
        break;
267
268
0
      case 'n':
269
0
        op_not(stack, &stackp);
270
0
        break;
271
272
0
      default:
273
0
        break;
274
0
    }
275
0
  }
276
277
0
  return stack[0];
278
0
}
279
280
static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, INT32 nYDest,
281
                                INT32 nXSrc, INT32 nYSrc, INT32 x, INT32 y, BOOL useSrc,
282
                                BOOL usePat, UINT32 style, const char* rop,
283
                                const gdiPalette* palette)
284
0
{
285
0
  UINT32 dstColor;
286
0
  UINT32 colorA;
287
0
  UINT32 colorB = 0;
288
0
  UINT32 colorC = 0;
289
0
  const INT32 dstX = nXDest + x;
290
0
  const INT32 dstY = nYDest + y;
291
0
  BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, dstX, dstY);
292
293
0
  if (!dstp)
294
0
  {
295
0
    WLog_ERR(TAG, "dstp=%p", (const void*)dstp);
296
0
    return FALSE;
297
0
  }
298
299
0
  colorA = FreeRDPReadColor(dstp, hdcDest->format);
300
301
0
  if (useSrc)
302
0
  {
303
0
    const BYTE* srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc + x, nYSrc + y);
304
305
0
    if (!srcp)
306
0
    {
307
0
      WLog_ERR(TAG, "srcp=%p", (const void*)srcp);
308
0
      return FALSE;
309
0
    }
310
311
0
    colorC = FreeRDPReadColor(srcp, hdcSrc->format);
312
0
    colorC = FreeRDPConvertColor(colorC, hdcSrc->format, hdcDest->format, palette);
313
0
  }
314
315
0
  if (usePat)
316
0
  {
317
0
    switch (style)
318
0
    {
319
0
      case GDI_BS_SOLID:
320
0
        colorB = hdcDest->brush->color;
321
0
        break;
322
323
0
      case GDI_BS_HATCHED:
324
0
      case GDI_BS_PATTERN:
325
0
      {
326
0
        const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
327
328
0
        if (!patp)
329
0
        {
330
0
          WLog_ERR(TAG, "patp=%p", (const void*)patp);
331
0
          return FALSE;
332
0
        }
333
334
0
        colorB = FreeRDPReadColor(patp, hdcDest->format);
335
0
      }
336
0
      break;
337
338
0
      default:
339
0
        break;
340
0
    }
341
0
  }
342
343
0
  dstColor = process_rop(colorC, colorA, colorB, rop, hdcDest->format);
344
0
  return FreeRDPWriteColor(dstp, hdcDest->format, dstColor);
345
0
}
346
347
static BOOL adjust_src_coordinates(HGDI_DC hdcSrc, INT32 nWidth, INT32 nHeight, INT32* px,
348
                                   INT32* py)
349
0
{
350
0
  HGDI_BITMAP hSrcBmp;
351
0
  INT32 nXSrc, nYSrc;
352
353
0
  if (!hdcSrc || (nWidth < 0) || (nHeight < 0) || !px || !py)
354
0
    return FALSE;
355
356
0
  hSrcBmp = (HGDI_BITMAP)hdcSrc->selectedObject;
357
0
  nXSrc = *px;
358
0
  nYSrc = *py;
359
360
0
  if (!hSrcBmp)
361
0
    return FALSE;
362
363
0
  if (nYSrc < 0)
364
0
  {
365
0
    nYSrc = 0;
366
0
    nHeight = nHeight + nYSrc;
367
0
  }
368
369
0
  if ((nXSrc) < 0)
370
0
  {
371
0
    nXSrc = 0;
372
0
    nWidth = nWidth + nXSrc;
373
0
  }
374
375
0
  if (hSrcBmp->width < (nXSrc + nWidth))
376
0
    nXSrc = hSrcBmp->width - nWidth;
377
378
0
  if (hSrcBmp->height < (nYSrc + nHeight))
379
0
    nYSrc = hSrcBmp->height - nHeight;
380
381
0
  if ((nXSrc < 0) || (nYSrc < 0))
382
0
    return FALSE;
383
384
0
  *px = nXSrc;
385
0
  *py = nYSrc;
386
0
  return TRUE;
387
0
}
388
389
static BOOL adjust_src_dst_coordinates(HGDI_DC hdcDest, INT32* pnXSrc, INT32* pnYSrc, INT32* pnXDst,
390
                                       INT32* pnYDst, INT32* pnWidth, INT32* pnHeight)
391
0
{
392
0
  HGDI_BITMAP hDstBmp;
393
0
  volatile INT32 diffX, diffY;
394
0
  volatile INT32 nXSrc, nYSrc;
395
0
  volatile INT32 nXDst, nYDst, nWidth, nHeight;
396
397
0
  if (!hdcDest || !pnXSrc || !pnYSrc || !pnXDst || !pnYDst || !pnWidth || !pnHeight)
398
0
    return FALSE;
399
400
0
  hDstBmp = (HGDI_BITMAP)hdcDest->selectedObject;
401
0
  nXSrc = *pnXSrc;
402
0
  nYSrc = *pnYSrc;
403
0
  nXDst = *pnXDst;
404
0
  nYDst = *pnYDst;
405
0
  nWidth = *pnWidth;
406
0
  nHeight = *pnHeight;
407
408
0
  if (!hDstBmp)
409
0
    return FALSE;
410
411
0
  if (nXDst < 0)
412
0
  {
413
0
    nXSrc -= nXDst;
414
0
    nWidth += nXDst;
415
0
    nXDst = 0;
416
0
  }
417
418
0
  if (nYDst < 0)
419
0
  {
420
0
    nYSrc -= nYDst;
421
0
    nHeight += nYDst;
422
0
    nYDst = 0;
423
0
  }
424
425
0
  diffX = hDstBmp->width - nXDst - nWidth;
426
427
0
  if (diffX < 0)
428
0
    nWidth += diffX;
429
430
0
  diffY = hDstBmp->height - nYDst - nHeight;
431
432
0
  if (diffY < 0)
433
0
    nHeight += diffY;
434
435
0
  if ((nXDst < 0) || (nYDst < 0) || (nWidth < 0) || (nHeight < 0))
436
0
  {
437
0
    nXDst = 0;
438
0
    nYDst = 0;
439
0
    nWidth = 0;
440
0
    nHeight = 0;
441
0
  }
442
443
0
  *pnXSrc = nXSrc;
444
0
  *pnYSrc = nYSrc;
445
0
  *pnXDst = nXDst;
446
0
  *pnYDst = nYDst;
447
0
  *pnWidth = nWidth;
448
0
  *pnHeight = nHeight;
449
0
  return TRUE;
450
0
}
451
452
static BOOL BitBlt_process(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nWidth, INT32 nHeight,
453
                           HGDI_DC hdcSrc, INT32 nXSrc, INT32 nYSrc, const char* rop,
454
                           const gdiPalette* palette)
455
0
{
456
0
  INT32 x, y;
457
0
  UINT32 style = 0;
458
0
  BOOL useSrc = FALSE;
459
0
  BOOL usePat = FALSE;
460
0
  const char* iter = rop;
461
462
0
  while (*iter != '\0')
463
0
  {
464
0
    switch (*iter++)
465
0
    {
466
0
      case 'P':
467
0
        usePat = TRUE;
468
0
        break;
469
470
0
      case 'S':
471
0
        useSrc = TRUE;
472
0
        break;
473
474
0
      default:
475
0
        break;
476
0
    }
477
0
  }
478
479
0
  if (!hdcDest)
480
0
    return FALSE;
481
482
0
  if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth, &nHeight))
483
0
    return FALSE;
484
485
0
  if (useSrc && !hdcSrc)
486
0
    return FALSE;
487
488
0
  if (useSrc)
489
0
  {
490
0
    if (!adjust_src_coordinates(hdcSrc, nWidth, nHeight, &nXSrc, &nYSrc))
491
0
      return FALSE;
492
0
  }
493
494
0
  if (usePat)
495
0
  {
496
0
    style = gdi_GetBrushStyle(hdcDest);
497
498
0
    switch (style)
499
0
    {
500
0
      case GDI_BS_SOLID:
501
0
      case GDI_BS_HATCHED:
502
0
      case GDI_BS_PATTERN:
503
0
        break;
504
505
0
      default:
506
0
        WLog_ERR(TAG, "Invalid brush!!");
507
0
        return FALSE;
508
0
    }
509
0
  }
510
511
0
  if ((nXDest > nXSrc) && (nYDest > nYSrc))
512
0
  {
513
0
    for (y = nHeight - 1; y >= 0; y--)
514
0
    {
515
0
      for (x = nWidth - 1; x >= 0; x--)
516
0
      {
517
0
        if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc,
518
0
                          usePat, style, rop, palette))
519
0
          return FALSE;
520
0
      }
521
0
    }
522
0
  }
523
0
  else if (nXDest > nXSrc)
524
0
  {
525
0
    for (y = 0; y < nHeight; y++)
526
0
    {
527
0
      for (x = nWidth - 1; x >= 0; x--)
528
0
      {
529
0
        if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc,
530
0
                          usePat, style, rop, palette))
531
0
          return FALSE;
532
0
      }
533
0
    }
534
0
  }
535
0
  else if (nYDest > nYSrc)
536
0
  {
537
0
    for (y = nHeight - 1; y >= 0; y--)
538
0
    {
539
0
      for (x = 0; x < nWidth; x++)
540
0
      {
541
0
        if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc,
542
0
                          usePat, style, rop, palette))
543
0
          return FALSE;
544
0
      }
545
0
    }
546
0
  }
547
0
  else
548
0
  {
549
0
    for (y = 0; y < nHeight; y++)
550
0
    {
551
0
      for (x = 0; x < nWidth; x++)
552
0
      {
553
0
        if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc,
554
0
                          usePat, style, rop, palette))
555
0
          return FALSE;
556
0
      }
557
0
    }
558
0
  }
559
560
0
  return TRUE;
561
0
}
562
563
/**
564
 * Perform a bit blit operation on the given pixel buffers.
565
 * msdn{dd183370}
566
 *
567
 * @param hdcDest destination device context
568
 * @param nXDest destination x1
569
 * @param nYDest destination y1
570
 * @param nWidth width
571
 * @param nHeight height
572
 * @param hdcSrc source device context
573
 * @param nXSrc source x1
574
 * @param nYSrc source y1
575
 * @param rop raster operation code
576
 * @return 0 on failure, non-zero otherwise
577
 */
578
BOOL gdi_BitBlt(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nWidth, INT32 nHeight,
579
                HGDI_DC hdcSrc, INT32 nXSrc, INT32 nYSrc, DWORD rop, const gdiPalette* palette)
580
0
{
581
0
  HGDI_BITMAP hSrcBmp, hDstBmp;
582
583
0
  if (!hdcDest)
584
0
    return FALSE;
585
586
0
  if (!gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc))
587
0
    return TRUE;
588
589
  /* Check which ROP should be performed.
590
   * Some specific ROP are used heavily and are resource intensive,
591
   * add optimized versions for these here.
592
   *
593
   * For all others fall back to the generic implementation.
594
   */
595
0
  switch (rop)
596
0
  {
597
0
    case GDI_SRCCOPY:
598
0
      if (!hdcSrc)
599
0
        return FALSE;
600
601
0
      if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth,
602
0
                                      &nHeight))
603
0
        return FALSE;
604
605
0
      if (!adjust_src_coordinates(hdcSrc, nWidth, nHeight, &nXSrc, &nYSrc))
606
0
        return FALSE;
607
608
0
      hSrcBmp = (HGDI_BITMAP)hdcSrc->selectedObject;
609
0
      hDstBmp = (HGDI_BITMAP)hdcDest->selectedObject;
610
611
0
      if (!hSrcBmp || !hDstBmp)
612
0
        return FALSE;
613
614
0
      if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline, nXDest,
615
0
                              nYDest, nWidth, nHeight, hSrcBmp->data, hSrcBmp->format,
616
0
                              hSrcBmp->scanline, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE))
617
0
        return FALSE;
618
619
0
      break;
620
621
0
    case GDI_DSTCOPY:
622
0
      hSrcBmp = (HGDI_BITMAP)hdcDest->selectedObject;
623
0
      hDstBmp = (HGDI_BITMAP)hdcDest->selectedObject;
624
625
0
      if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth,
626
0
                                      &nHeight))
627
0
        return FALSE;
628
629
0
      if (!adjust_src_coordinates(hdcDest, nWidth, nHeight, &nXSrc, &nYSrc))
630
0
        return FALSE;
631
632
0
      if (!hSrcBmp || !hDstBmp)
633
0
        return FALSE;
634
635
0
      if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline, nXDest,
636
0
                              nYDest, nWidth, nHeight, hSrcBmp->data, hSrcBmp->format,
637
0
                              hSrcBmp->scanline, nXSrc, nYSrc, palette, FREERDP_FLIP_NONE))
638
0
        return FALSE;
639
640
0
      break;
641
642
0
    default:
643
0
      if (!BitBlt_process(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc,
644
0
                          gdi_rop_to_string(rop), palette))
645
0
        return FALSE;
646
647
0
      break;
648
0
  }
649
650
0
  if (!gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight))
651
0
    return FALSE;
652
653
0
  return TRUE;
654
0
}