forked from dahall/Vanara
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWinGdi.Bitmap.cs
2695 lines (2602 loc) · 151 KB
/
WinGdi.Bitmap.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Gdi32
{
/// <summary>Flags for CreateDIBitmap.</summary>
[PInvokeData("wingdi.h", MSDNShortId = "e9a5b525-a6b6-4309-9e53-69d274b85783")]
[Flags]
public enum CBM
{
/// <summary>
/// If this flag is set, the system uses the data pointed to by the lpbInit and lpbmi parameters to initialize the bitmap bits.
/// </summary>
CBM_INIT = 4
}
/// <summary>Specifies the type of color values in DIB functions.</summary>
[PInvokeData("Wingdi.h", MSDNShortId = "dd183494")]
public enum DIBColorMode : int
{
/// <summary>The BITMAPINFO structure contains an array of literal RGB values.</summary>
DIB_RGB_COLORS = 0,
/// <summary>
/// The bmiColors member of the BITMAPINFO structure is an array of 16-bit indexes into the logical palette of the device context
/// specified by hdc.
/// </summary>
DIB_PAL_COLORS = 1
}
/// <summary>The type of fill operation to be performed.</summary>
[PInvokeData("wingdi.h", MSDNShortId = "b996d47d-5aaf-4b13-8643-209744e5a04b")]
public enum FloodFillType : uint
{
/// <summary>
/// The fill area is bounded by the color specified by the crColor parameter. This style is identical to the filling performed by
/// the FloodFill function.
/// </summary>
FLOODFILLBORDER,
/// <summary>
/// The fill area is defined by the color that is specified by crColor. Filling continues outward in all directions as long as
/// the color is encountered. This style is useful for filling areas with multicolored boundaries.
/// </summary>
FLOODFILLSURFACE
}
/// <summary>Flags for <see cref="GradientFill"/>.</summary>
[PInvokeData("wingdi.h", MSDNShortId = "c88c1137-5690-4139-9d10-90d036e8f31c")]
public enum GradientFillMode : uint
{
/// <summary>
/// In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the
/// TRIVERTEX structure) for the left and right edges. GDI interpolates the color from the left to right edge and fills the interior.
/// </summary>
GRADIENT_FILL_RECT_H = 0x00000000,
/// <summary>
/// In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the
/// TRIVERTEX structure) for the top and bottom edges. GDI interpolates the color from the top to bottom edge and fills the interior.
/// </summary>
GRADIENT_FILL_RECT_V = 0x00000001,
/// <summary>
/// In this mode, an array of TRIVERTEX structures is passed to GDI along with a list of array indexes that describe separate
/// triangles. GDI performs linear interpolation between triangle vertices and fills the interior. Drawing is done directly in
/// 24- and 32-bpp modes. Dithering is performed in 16-, 8-, 4-, and 1-bpp mode.
/// </summary>
GRADIENT_FILL_TRIANGLE = 0x00000002,
/// <summary>Undocumented.</summary>
GRADIENT_FILL_OP_FLAG = 0x000000ff,
}
/// <summary>
/// Defines how the color data for the source rectangle is to be combined with the color data for the destination rectangle to
/// achieve the final color when using the <see cref="BitBlt"/> function.
/// </summary>
[PInvokeData("Wingdi.h", MSDNShortId = "dd183370")]
public enum RasterOperationMode
{
/// <summary>Copies the source rectangle directly to the destination rectangle.</summary>
SRCCOPY = 0x00CC0020,
/// <summary>Combines the colors of the source and destination rectangles by using the Boolean OR operator.</summary>
SRCPAINT = 0x00EE0086,
/// <summary>Combines the colors of the source and destination rectangles by using the Boolean AND operator.</summary>
SRCAND = 0x008800C6,
/// <summary>Combines the colors of the source and destination rectangles by using the Boolean XOR operator.</summary>
SRCINVERT = 0x00660046,
/// <summary>
/// Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator.
/// </summary>
SRCERASE = 0x00440328,
/// <summary></summary>
NOTSRCCOPY = 0x00330008,
/// <summary>Copies the inverted source rectangle to the destination.</summary>
NOTSRCERASE = 0x001100A6,
/// <summary>
/// Merges the colors of the source rectangle with the brush currently selected in hdcDest, by using the Boolean AND operator.
/// </summary>
MERGECOPY = 0x00C000CA,
/// <summary>
/// Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator.
/// </summary>
MERGEPAINT = 0x00BB0226,
/// <summary>Copies the brush currently selected in hdcDest, into the destination bitmap.</summary>
PATCOPY = 0x00F00021,
/// <summary>
/// Combines the colors of the brush currently selected in hdcDest, with the colors of the inverted source rectangle by using the
/// Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the
/// Boolean OR operator.
/// </summary>
PATPAINT = 0x00FB0A09,
/// <summary>
/// Combines the colors of the brush currently selected in hdcDest, with the colors of the destination rectangle by using the
/// Boolean XOR operator.
/// </summary>
PATINVERT = 0x005A0049,
/// <summary>Inverts the destination rectangle.</summary>
DSTINVERT = 0x00550009,
/// <summary>
/// Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the
/// default physical palette.)
/// </summary>
BLACKNESS = 0x00000042,
/// <summary>
/// Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the
/// default physical palette.)
/// </summary>
WHITENESS = 0x00FF0062,
/// <summary>Prevents the bitmap from being mirrored.</summary>
NOMIRRORBITMAP = -2147483648,
/// <summary>
/// Includes any windows that are layered on top of your window in the resulting image.By default, the image only contains your
/// window.Note that this generally cannot be used for printing device contexts.
/// </summary>
CAPTUREBLT = 0x40000000
}
/// <summary>Stretching mode.</summary>
[PInvokeData("wingdi.h", MSDNShortId = "a4408e28-d7ac-44e9-905d-efa75c60e503")]
public enum StretchMode : uint
{
/// <summary>
/// Performs a Boolean AND operation using the color values for the eliminated and existing pixels. If the bitmap is a monochrome
/// bitmap, this mode preserves black pixels at the expense of white pixels.
/// </summary>
BLACKONWHITE = 1,
/// <summary>
/// Performs a Boolean OR operation using the color values for the eliminated and existing pixels. If the bitmap is a monochrome
/// bitmap, this mode preserves white pixels at the expense of black pixels.
/// </summary>
WHITEONBLACK = 2,
/// <summary>Deletes the pixels. This mode deletes all eliminated lines of pixels without trying to preserve their information.</summary>
COLORONCOLOR = 3,
/// <summary>
/// Maps pixels from the source rectangle into blocks of pixels in the destination rectangle. The average color over the
/// destination block of pixels approximates the color of the source pixels.
/// </summary>
HALFTONE = 4,
/// <summary>Same as BLACKONWHITE.</summary>
STRETCH_ANDSCANS = BLACKONWHITE,
/// <summary>Same as WHITEONBLACK.</summary>
STRETCH_ORSCANS = WHITEONBLACK,
/// <summary>Same as COLORONCOLOR.</summary>
STRETCH_DELETESCANS = COLORONCOLOR,
/// <summary>Same as HALFTONE.</summary>
STRETCH_HALFTONE = HALFTONE,
}
/// <summary>The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels.</summary>
/// <param name="hdcDest">A handle to the destination device context.</param>
/// <param name="nXOriginDest">The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.</param>
/// <param name="nYOriginDest">The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.</param>
/// <param name="nWidthDest">The width, in logical units, of the destination rectangle.</param>
/// <param name="nHeightDest">The height, in logical units, of the destination rectangle.</param>
/// <param name="hdcSrc">A handle to the source device context.</param>
/// <param name="nXOriginSrc">The x-coordinate, in logical units, of the upper-left corner of the source rectangle.</param>
/// <param name="nYOriginSrc">The y-coordinate, in logical units, of the upper-left corner of the source rectangle.</param>
/// <param name="nWidthSrc">The width, in logical units, of the source rectangle.</param>
/// <param name="nHeightSrc">The height, in logical units, of the source rectangle.</param>
/// <param name="blendFunction">
/// The alpha-blending function for source and destination bitmaps, a global alpha value to be applied to the entire source bitmap,
/// and format information for the source bitmap. The source and destination blend functions are currently limited to AC_SRC_OVER.
/// </param>
/// <returns>If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE.</returns>
/// <remarks>
/// If the source rectangle and destination rectangle are not the same size, the source bitmap is stretched to match the destination
/// rectangle. If the SetStretchBltMode function is used, the iStretchMode value is automatically converted to COLORONCOLOR for this
/// function (that is, BLACKONWHITE, WHITEONBLACK, and HALFTONE are changed to COLORONCOLOR).
/// <para>
/// The destination coordinates are transformed by using the transformation currently specified for the destination device context.
/// The source coordinates are transformed by using the transformation currently specified for the source device context.
/// </para>
/// <para>An error occurs (and the function returns FALSE) if the source device context identifies an enhanced metafile device context.</para>
/// <para>
/// If destination and source bitmaps do not have the same color format, AlphaBlend converts the source bitmap to match the
/// destination bitmap.
/// </para>
/// <para>
/// AlphaBlend does not support mirroring. If either the width or height of the source or destination is negative, this call will fail.
/// </para>
/// <para>
/// When rendering to a printer, first call GetDeviceCaps with SHADEBLENDCAPS to determine if the printer supports blending with
/// AlphaBlend. Note that, for a display DC, all blending operations are supported and these flags represent whether the operations
/// are accelerated.
/// </para>
/// <para>
/// If the source and destination are the same surface that is, they are both the screen or the same memory bitmap and the source and
/// destination rectangles overlap, an error occurs and the function returns FALSE.
/// </para>
/// <para>
/// The source rectangle must lie completely within the source surface, otherwise an error occurs and the function returns FALSE.
/// </para>
/// <para>AlphaBlend fails if the width or height of the source or destination is negative.</para>
/// <para>
/// The SourceConstantAlpha member of BLENDFUNCTION specifies an alpha transparency value to be used on the entire source bitmap. The
/// SourceConstantAlpha value is combined with any per-pixel alpha values. If SourceConstantAlpha is 0, it is assumed that the image
/// is transparent. Set the SourceConstantAlpha value to 255 (which indicates that the image is opaque) when you only want to use
/// per-pixel alpha values.
/// </para>
/// </remarks>
[DllImport(Lib.Gdi32, SetLastError = true, EntryPoint = "GdiAlphaBlend")]
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd183351")]
public static extern bool AlphaBlend(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction);
/// <summary>
/// The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified
/// source device context into a destination device context.
/// </summary>
/// <param name="hdc">A handle to the destination device context.</param>
/// <param name="nXDest">The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.</param>
/// <param name="nYDest">The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.</param>
/// <param name="nWidth">The width, in logical units, of the destination rectangle.</param>
/// <param name="nHeight">The height, in logical units, of the destination rectangle.</param>
/// <param name="hdcSrc">A handle to the source device context.</param>
/// <param name="nXSrc">The x-coordinate, in logical units, of the upper-left corner of the source rectangle.</param>
/// <param name="nYSrc">The y-coordinate, in logical units, of the upper-left corner of the source rectangle.</param>
/// <param name="dwRop">
/// A raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for
/// the destination rectangle to achieve the final color.
/// </param>
/// <returns>
/// If the function succeeds, the return value is nonzero.
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// BitBlt only does clipping on the destination DC.
/// <para>
/// If a rotation or shear transformation is in effect in the source device context, BitBlt returns an error. If other
/// transformations exist in the source device context (and a matching transformation is not in effect in the destination device
/// context), the rectangle in the destination device context is stretched, compressed, or rotated, as necessary.
/// </para>
/// <para>
/// If the color formats of the source and destination device contexts do not match, the BitBlt function converts the source color
/// format to match the destination format.
/// </para>
/// <para>
/// When an enhanced metafile is being recorded, an error occurs if the source device context identifies an enhanced-metafile device context.
/// </para>
/// <para>
/// Not all devices support the BitBlt function. For more information, see the RC_BITBLT raster capability entry in the GetDeviceCaps
/// function as well as the following functions: MaskBlt, PlgBlt, and StretchBlt.
/// </para>
/// <para>
/// BitBlt returns an error if the source and destination device contexts represent different devices. To transfer data between DCs
/// for different devices, convert the memory bitmap to a DIB by calling GetDIBits. To display the DIB to the second device, call
/// SetDIBits or StretchDIBits.
/// </para>
/// <para>ICM: No color management is performed when blits occur.</para>
/// </remarks>
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd183370")]
public static extern bool BitBlt(HDC hdc, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, RasterOperationMode dwRop);
/// <summary>
/// The <c>CreateBitmap</c> function creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel).
/// </summary>
/// <param name="nWidth">The bitmap width, in pixels.</param>
/// <param name="nHeight">The bitmap height, in pixels.</param>
/// <param name="nPlanes">The number of color planes used by the device.</param>
/// <param name="nBitCount">The number of bits required to identify the color of a single pixel.</param>
/// <param name="lpBits">
/// A pointer to an array of color data used to set the colors in a rectangle of pixels. Each scan line in the rectangle must be word
/// aligned (scan lines that are not word aligned must be padded with zeros). If this parameter is <c>NULL</c>, the contents of the
/// new bitmap is undefined.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to a bitmap.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// <para>This function can return the following value.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_BITMAP</term>
/// <term>The calculated size of the bitmap is less than zero.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>The <c>CreateBitmap</c> function creates a device-dependent bitmap.</para>
/// <para>
/// After a bitmap is created, it can be selected into a device context by calling the SelectObject function. However, the bitmap can
/// only be selected into a device context if the bitmap and the DC have the same format.
/// </para>
/// <para>
/// The <c>CreateBitmap</c> function can be used to create color bitmaps. However, for performance reasons applications should use
/// <c>CreateBitmap</c> to create monochrome bitmaps and CreateCompatibleBitmap to create color bitmaps. Whenever a color bitmap
/// returned from <c>CreateBitmap</c> is selected into a device context, the system checks that the bitmap matches the format of the
/// device context it is being selected into. Because <c>CreateCompatibleBitmap</c> takes a device context, it returns a bitmap that
/// has the same format as the specified device context. Thus, subsequent calls to SelectObject are faster with a color bitmap from
/// <c>CreateCompatibleBitmap</c> than with a color bitmap returned from <c>CreateBitmap</c>.
/// </para>
/// <para>
/// If the bitmap is monochrome, zeros represent the foreground color and ones represent the background color for the destination
/// device context.
/// </para>
/// <para>
/// If an application sets the nWidth or nHeight parameters to zero, <c>CreateBitmap</c> returns the handle to a 1-by-1 pixel,
/// monochrome bitmap.
/// </para>
/// <para>When you no longer need the bitmap, call the DeleteObject function to delete it.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createbitmap HBITMAP CreateBitmap( int nWidth, int nHeight,
// UINT nPlanes, UINT nBitCount, const VOID *lpBits );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "b52e1baf-6a81-44bc-a061-4d42e6f4ed64")]
public static extern SafeHBITMAP CreateBitmap(int nWidth, int nHeight, uint nPlanes, uint nBitCount, [In, Optional] IntPtr lpBits);
/// <summary>
/// The <c>CreateBitmap</c> function creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel).
/// </summary>
/// <param name="nWidth">The bitmap width, in pixels.</param>
/// <param name="nHeight">The bitmap height, in pixels.</param>
/// <param name="nPlanes">The number of color planes used by the device.</param>
/// <param name="nBitCount">The number of bits required to identify the color of a single pixel.</param>
/// <param name="lpBits">
/// A pointer to an array of color data used to set the colors in a rectangle of pixels. Each scan line in the rectangle must be word
/// aligned (scan lines that are not word aligned must be padded with zeros). If this parameter is <c>NULL</c>, the contents of the
/// new bitmap is undefined.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to a bitmap.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// <para>This function can return the following value.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_BITMAP</term>
/// <term>The calculated size of the bitmap is less than zero.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>The <c>CreateBitmap</c> function creates a device-dependent bitmap.</para>
/// <para>
/// After a bitmap is created, it can be selected into a device context by calling the SelectObject function. However, the bitmap can
/// only be selected into a device context if the bitmap and the DC have the same format.
/// </para>
/// <para>
/// The <c>CreateBitmap</c> function can be used to create color bitmaps. However, for performance reasons applications should use
/// <c>CreateBitmap</c> to create monochrome bitmaps and CreateCompatibleBitmap to create color bitmaps. Whenever a color bitmap
/// returned from <c>CreateBitmap</c> is selected into a device context, the system checks that the bitmap matches the format of the
/// device context it is being selected into. Because <c>CreateCompatibleBitmap</c> takes a device context, it returns a bitmap that
/// has the same format as the specified device context. Thus, subsequent calls to SelectObject are faster with a color bitmap from
/// <c>CreateCompatibleBitmap</c> than with a color bitmap returned from <c>CreateBitmap</c>.
/// </para>
/// <para>
/// If the bitmap is monochrome, zeros represent the foreground color and ones represent the background color for the destination
/// device context.
/// </para>
/// <para>
/// If an application sets the nWidth or nHeight parameters to zero, <c>CreateBitmap</c> returns the handle to a 1-by-1 pixel,
/// monochrome bitmap.
/// </para>
/// <para>When you no longer need the bitmap, call the DeleteObject function to delete it.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createbitmap HBITMAP CreateBitmap( int nWidth, int nHeight,
// UINT nPlanes, UINT nBitCount, const VOID *lpBits );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "b52e1baf-6a81-44bc-a061-4d42e6f4ed64")]
public static extern SafeHBITMAP CreateBitmap(int nWidth, int nHeight, uint nPlanes, uint nBitCount, [In, Optional] byte[] lpBits);
/// <summary>
/// The <c>CreateBitmapIndirect</c> function creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel).
/// </summary>
/// <param name="pbm">
/// A pointer to a BITMAP structure that contains information about the bitmap. If an application sets the <c>bmWidth</c> or
/// <c>bmHeight</c> members to zero, <c>CreateBitmapIndirect</c> returns the handle to a 1-by-1 pixel, monochrome bitmap.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to the bitmap.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// <para>This function can return the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_PARAMETER</term>
/// <term>One or more of the input parameters is invalid.</term>
/// </item>
/// <item>
/// <term>ERROR_NOT_ENOUGH_MEMORY</term>
/// <term>The bitmap is too big for memory to be allocated.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>The <c>CreateBitmapIndirect</c> function creates a device-dependent bitmap.</para>
/// <para>
/// After a bitmap is created, it can be selected into a device context by calling the SelectObject function. However, the bitmap can
/// only be selected into a device context if the bitmap and the DC have the same format.
/// </para>
/// <para>
/// While the <c>CreateBitmapIndirect</c> function can be used to create color bitmaps, for performance reasons applications should
/// use <c>CreateBitmapIndirect</c> to create monochrome bitmaps and CreateCompatibleBitmap to create color bitmaps. Whenever a color
/// bitmap from <c>CreateBitmapIndirect</c> is selected into a device context, the system must ensure that the bitmap matches the
/// format of the device context it is being selected into. Because <c>CreateCompatibleBitmap</c> takes a device context, it returns
/// a bitmap that has the same format as the specified device context. Thus, subsequent calls to SelectObject are faster with a color
/// bitmap from <c>CreateCompatibleBitmap</c> than with a color bitmap returned from <c>CreateBitmapIndirect</c>.
/// </para>
/// <para>
/// If the bitmap is monochrome, zeros represent the foreground color and ones represent the background color for the destination
/// device context.
/// </para>
/// <para>When you no longer need the bitmap, call the DeleteObject function to delete it.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createbitmapindirect HBITMAP CreateBitmapIndirect( const
// BITMAP *pbm );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "79f73e28-4ee3-472d-9a20-3ffe7cf2a6b5")]
public static extern SafeHBITMAP CreateBitmapIndirect(in BITMAP pbm);
/// <summary>
/// The <c>CreateCompatibleBitmap</c> function creates a bitmap compatible with the device that is associated with the specified
/// device context.
/// </summary>
/// <param name="hdc">A handle to a device context.</param>
/// <param name="cx">The bitmap width, in pixels.</param>
/// <param name="cy">The bitmap height, in pixels.</param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to the compatible bitmap (DDB).</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>
/// The color format of the bitmap created by the <c>CreateCompatibleBitmap</c> function matches the color format of the device
/// identified by the hdc parameter. This bitmap can be selected into any memory device context that is compatible with the original device.
/// </para>
/// <para>
/// Because memory device contexts allow both color and monochrome bitmaps, the format of the bitmap returned by the
/// <c>CreateCompatibleBitmap</c> function differs when the specified device context is a memory device context. However, a
/// compatible bitmap that was created for a nonmemory device context always possesses the same color format and uses the same color
/// palette as the specified device context.
/// </para>
/// <para>
/// Note: When a memory device context is created, it initially has a 1-by-1 monochrome bitmap selected into it. If this memory
/// device context is used in <c>CreateCompatibleBitmap</c>, the bitmap that is created is a monochrome bitmap. To create a color
/// bitmap, use the <c>HDC</c> that was used to create the memory device context, as shown in the following code:
/// </para>
/// <para>
/// If an application sets the nWidth or nHeight parameters to zero, <c>CreateCompatibleBitmap</c> returns the handle to a 1-by-1
/// pixel, monochrome bitmap.
/// </para>
/// <para>
/// If a DIB section, which is a bitmap created by the CreateDIBSection function, is selected into the device context identified by
/// the hdc parameter, <c>CreateCompatibleBitmap</c> creates a DIB section.
/// </para>
/// <para>When you no longer need the bitmap, call the DeleteObject function to delete it.</para>
/// <para>Examples</para>
/// <para>For an example, see Scaling an Image.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatiblebitmap HBITMAP CreateCompatibleBitmap( HDC
// hdc, int cx, int cy );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "d2866beb-ff7a-4390-8651-e7bf458ddf88")]
public static extern SafeHBITMAP CreateCompatibleBitmap(HDC hdc, int cx, int cy);
/// <summary>
/// The <c>CreateDIBitmap</c> function creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits.
/// </summary>
/// <param name="hdc">A handle to a device context.</param>
/// <param name="pbmih">
/// <para>A pointer to a bitmap information header structure, BITMAPV5HEADER.</para>
/// <para>
/// If fdwInit is CBM_INIT, the function uses the bitmap information header structure to obtain the desired width and height of the
/// bitmap as well as other information. Note that a positive value for the height indicates a bottom-up DIB while a negative value
/// for the height indicates a top-down DIB. Calling <c>CreateDIBitmap</c> with fdwInit as CBM_INIT is equivalent to calling the
/// CreateCompatibleBitmap function to create a DDB in the format of the device and then calling the SetDIBits function to translate
/// the DIB bits to the DDB.
/// </para>
/// </param>
/// <param name="flInit">
/// <para>Specifies how the system initializes the bitmap bits. The following value is defined.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>CBM_INIT</term>
/// <term>
/// If this flag is set, the system uses the data pointed to by the lpbInit and lpbmi parameters to initialize the bitmap bits. If
/// this flag is clear, the data pointed to by those parameters is not used.
/// </term>
/// </item>
/// </list>
/// <para>If fdwInit is zero, the system does not initialize the bitmap bits.</para>
/// </param>
/// <param name="pjBits">
/// A pointer to an array of bytes containing the initial bitmap data. The format of the data depends on the <c>biBitCount</c> member
/// of the BITMAPINFO structure to which the lpbmi parameter points.
/// </param>
/// <param name="pbmi">
/// A pointer to a BITMAPINFO structure that describes the dimensions and color format of the array pointed to by the lpbInit parameter.
/// </param>
/// <param name="iUsage">
/// <para>
/// Specifies whether the <c>bmiColors</c> member of the BITMAPINFO structure was initialized and, if so, whether <c>bmiColors</c>
/// contains explicit red, green, blue (RGB) values or palette indexes. The fuUsage parameter must be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>
/// A color table is provided and consists of an array of 16-bit indexes into the logical palette of the device context into which
/// the bitmap is to be selected.
/// </term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>A color table is provided and contains literal RGB values.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to the compatible bitmap.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>
/// The DDB that is created will be whatever bit depth your reference DC is. To create a bitmap that is of different bit depth, use CreateDIBSection.
/// </para>
/// <para>
/// For a device to reach optimal bitmap-drawing speed, specify fdwInit as CBM_INIT. Then, use the same color depth DIB as the video
/// mode. When the video is running 4- or 8-bpp, use DIB_PAL_COLORS.
/// </para>
/// <para>The CBM_CREATDIB flag for the fdwInit parameter is no longer supported.</para>
/// <para>When you no longer need the bitmap, call the DeleteObject function to delete it.</para>
/// <para>
/// <c>ICM:</c> No color management is performed. The contents of the resulting bitmap are not color matched after the bitmap has
/// been created.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibitmap HBITMAP CreateDIBitmap( HDC hdc, const
// BITMAPINFOHEADER *pbmih, DWORD flInit, const VOID *pjBits, const BITMAPINFO *pbmi, UINT iUsage );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "e9a5b525-a6b6-4309-9e53-69d274b85783")]
public static extern SafeHBITMAP CreateDIBitmap(HDC hdc, in BITMAPINFOHEADER pbmih, CBM flInit, [In, Optional] byte[] pjBits, in BITMAPINFO pbmi, DIBColorMode iUsage);
/// <summary>
/// The <c>CreateDIBitmap</c> function creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits.
/// </summary>
/// <param name="hdc">A handle to a device context.</param>
/// <param name="pbmih">
/// <para>A pointer to a bitmap information header structure, BITMAPV5HEADER.</para>
/// <para>
/// If fdwInit is CBM_INIT, the function uses the bitmap information header structure to obtain the desired width and height of the
/// bitmap as well as other information. Note that a positive value for the height indicates a bottom-up DIB while a negative value
/// for the height indicates a top-down DIB. Calling <c>CreateDIBitmap</c> with fdwInit as CBM_INIT is equivalent to calling the
/// CreateCompatibleBitmap function to create a DDB in the format of the device and then calling the SetDIBits function to translate
/// the DIB bits to the DDB.
/// </para>
/// </param>
/// <param name="flInit">
/// <para>Specifies how the system initializes the bitmap bits. The following value is defined.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>CBM_INIT</term>
/// <term>
/// If this flag is set, the system uses the data pointed to by the lpbInit and lpbmi parameters to initialize the bitmap bits. If
/// this flag is clear, the data pointed to by those parameters is not used.
/// </term>
/// </item>
/// </list>
/// <para>If fdwInit is zero, the system does not initialize the bitmap bits.</para>
/// </param>
/// <param name="pjBits">
/// A pointer to an array of bytes containing the initial bitmap data. The format of the data depends on the <c>biBitCount</c> member
/// of the BITMAPINFO structure to which the lpbmi parameter points.
/// </param>
/// <param name="pbmi">
/// A pointer to a BITMAPINFO structure that describes the dimensions and color format of the array pointed to by the lpbInit parameter.
/// </param>
/// <param name="iUsage">
/// <para>
/// Specifies whether the <c>bmiColors</c> member of the BITMAPINFO structure was initialized and, if so, whether <c>bmiColors</c>
/// contains explicit red, green, blue (RGB) values or palette indexes. The fuUsage parameter must be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>
/// A color table is provided and consists of an array of 16-bit indexes into the logical palette of the device context into which
/// the bitmap is to be selected.
/// </term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>A color table is provided and contains literal RGB values.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to the compatible bitmap.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>
/// The DDB that is created will be whatever bit depth your reference DC is. To create a bitmap that is of different bit depth, use CreateDIBSection.
/// </para>
/// <para>
/// For a device to reach optimal bitmap-drawing speed, specify fdwInit as CBM_INIT. Then, use the same color depth DIB as the video
/// mode. When the video is running 4- or 8-bpp, use DIB_PAL_COLORS.
/// </para>
/// <para>The CBM_CREATDIB flag for the fdwInit parameter is no longer supported.</para>
/// <para>When you no longer need the bitmap, call the DeleteObject function to delete it.</para>
/// <para>
/// <c>ICM:</c> No color management is performed. The contents of the resulting bitmap are not color matched after the bitmap has
/// been created.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibitmap HBITMAP CreateDIBitmap( HDC hdc, const
// BITMAPINFOHEADER *pbmih, DWORD flInit, const VOID *pjBits, const BITMAPINFO *pbmi, UINT iUsage );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "e9a5b525-a6b6-4309-9e53-69d274b85783")]
public static extern SafeHBITMAP CreateDIBitmap(HDC hdc, [In, Optional] IntPtr pbmih, CBM flInit, [In, Optional] byte[] pjBits, [In, Optional] SafeBITMAPINFO pbmi, DIBColorMode iUsage);
/// <summary>
/// The <c>CreateDIBSection</c> function creates a DIB that applications can write to directly. The function gives you a pointer to
/// the location of the bitmap bit values. You can supply a handle to a file-mapping object that the function will use to create the
/// bitmap, or you can let the system allocate the memory for the bitmap.
/// </summary>
/// <param name="hdc">
/// A handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this device context's logical palette
/// to initialize the DIB colors.
/// </param>
/// <param name="pbmi">
/// A pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including the bitmap dimensions and colors.
/// </param>
/// <param name="usage">
/// <para>
/// The type of data contained in the <c>bmiColors</c> array member of the BITMAPINFO structure pointed to by pbmi (either logical
/// palette indexes or literal RGB values). The following values are defined.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>The bmiColors member is an array of 16-bit indexes into the logical palette of the device context specified by hdc.</term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>The BITMAPINFO structure contains an array of literal RGB values.</term>
/// </item>
/// </list>
/// </param>
/// <param name="ppvBits">A pointer to a variable that receives a pointer to the location of the DIB bit values.</param>
/// <param name="hSection">
/// <para>A handle to a file-mapping object that the function will use to create the DIB. This parameter can be <c>NULL</c>.</para>
/// <para>
/// If hSection is not <c>NULL</c>, it must be a handle to a file-mapping object created by calling the CreateFileMapping function
/// with the PAGE_READWRITE or PAGE_WRITECOPY flag. Read-only DIB sections are not supported. Handles created by other means will
/// cause <c>CreateDIBSection</c> to fail.
/// </para>
/// <para>
/// If hSection is not <c>NULL</c>, the <c>CreateDIBSection</c> function locates the bitmap bit values at offset dwOffset in the
/// file-mapping object referred to by hSection. An application can later retrieve the hSection handle by calling the GetObject
/// function with the <c>HBITMAP</c> returned by <c>CreateDIBSection</c>.
/// </para>
/// <para>
/// If hSection is <c>NULL</c>, the system allocates memory for the DIB. In this case, the <c>CreateDIBSection</c> function ignores
/// the dwOffset parameter. An application cannot later obtain a handle to this memory. The <c>dshSection</c> member of the
/// DIBSECTION structure filled in by calling the GetObject function will be <c>NULL</c>.
/// </para>
/// </param>
/// <param name="offset">
/// The offset from the beginning of the file-mapping object referenced by hSection where storage for the bitmap bit values is to
/// begin. This value is ignored if hSection is <c>NULL</c>. The bitmap bit values are aligned on doubleword boundaries, so dwOffset
/// must be a multiple of the size of a <c>DWORD</c>.
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is a handle to the newly created DIB, and *ppvBits points to the bitmap bit values.
/// </para>
/// <para>If the function fails, the return value is <c>NULL</c>, and *ppvBits is <c>NULL</c>.</para>
/// <para>This function can return the following value.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_PARAMETER</term>
/// <term>One or more of the input parameters is invalid.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// As noted above, if hSection is <c>NULL</c>, the system allocates memory for the DIB. The system closes the handle to that memory
/// when you later delete the DIB by calling the DeleteObject function. If hSection is not <c>NULL</c>, you must close the hSection
/// memory handle yourself after calling <c>DeleteObject</c> to delete the bitmap.
/// </para>
/// <para>You cannot paste a DIB section from one application into another application.</para>
/// <para>
/// <c>CreateDIBSection</c> does not use the BITMAPINFOHEADER parameters biXPelsPerMeter or biYPelsPerMeter and will not provide
/// resolution information in the BITMAPINFO structure.
/// </para>
/// <para>
/// You need to guarantee that the GDI subsystem has completed any drawing to a bitmap created by <c>CreateDIBSection</c> before you
/// draw to the bitmap yourself. Access to the bitmap must be synchronized. Do this by calling the GdiFlush function. This applies to
/// any use of the pointer to the bitmap bit values, including passing the pointer in calls to functions such as SetDIBits.
/// </para>
/// <para><c>ICM:</c> No color management is done.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibsection HBITMAP CreateDIBSection( HDC hdc, const
// BITMAPINFO *pbmi, UINT usage, VOID **ppvBits, HANDLE hSection, DWORD offset );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "9276ec84-2860-42be-a9f8-d4efb8d25eec")]
public static extern SafeHBITMAP CreateDIBSection([In, Optional] HDC hdc, in BITMAPINFO pbmi, DIBColorMode usage, out IntPtr ppvBits, [In, Optional] HSECTION hSection, [In, Optional] uint offset);
/// <summary>
/// The <c>CreateDIBSection</c> function creates a DIB that applications can write to directly. The function gives you a pointer to
/// the location of the bitmap bit values. You can supply a handle to a file-mapping object that the function will use to create the
/// bitmap, or you can let the system allocate the memory for the bitmap.
/// </summary>
/// <param name="hdc">
/// A handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this device context's logical palette
/// to initialize the DIB colors.
/// </param>
/// <param name="pbmi">
/// A pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including the bitmap dimensions and colors.
/// </param>
/// <param name="usage">
/// <para>
/// The type of data contained in the <c>bmiColors</c> array member of the BITMAPINFO structure pointed to by pbmi (either logical
/// palette indexes or literal RGB values). The following values are defined.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>The bmiColors member is an array of 16-bit indexes into the logical palette of the device context specified by hdc.</term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>The BITMAPINFO structure contains an array of literal RGB values.</term>
/// </item>
/// </list>
/// </param>
/// <param name="ppvBits">A pointer to a variable that receives a pointer to the location of the DIB bit values.</param>
/// <param name="hSection">
/// <para>A handle to a file-mapping object that the function will use to create the DIB. This parameter can be <c>NULL</c>.</para>
/// <para>
/// If hSection is not <c>NULL</c>, it must be a handle to a file-mapping object created by calling the CreateFileMapping function
/// with the PAGE_READWRITE or PAGE_WRITECOPY flag. Read-only DIB sections are not supported. Handles created by other means will
/// cause <c>CreateDIBSection</c> to fail.
/// </para>
/// <para>
/// If hSection is not <c>NULL</c>, the <c>CreateDIBSection</c> function locates the bitmap bit values at offset dwOffset in the
/// file-mapping object referred to by hSection. An application can later retrieve the hSection handle by calling the GetObject
/// function with the <c>HBITMAP</c> returned by <c>CreateDIBSection</c>.
/// </para>
/// <para>
/// If hSection is <c>NULL</c>, the system allocates memory for the DIB. In this case, the <c>CreateDIBSection</c> function ignores
/// the dwOffset parameter. An application cannot later obtain a handle to this memory. The <c>dshSection</c> member of the
/// DIBSECTION structure filled in by calling the GetObject function will be <c>NULL</c>.
/// </para>
/// </param>
/// <param name="offset">
/// The offset from the beginning of the file-mapping object referenced by hSection where storage for the bitmap bit values is to
/// begin. This value is ignored if hSection is <c>NULL</c>. The bitmap bit values are aligned on doubleword boundaries, so dwOffset
/// must be a multiple of the size of a <c>DWORD</c>.
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is a handle to the newly created DIB, and *ppvBits points to the bitmap bit values.
/// </para>
/// <para>If the function fails, the return value is <c>NULL</c>, and *ppvBits is <c>NULL</c>.</para>
/// <para>This function can return the following value.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_PARAMETER</term>
/// <term>One or more of the input parameters is invalid.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// As noted above, if hSection is <c>NULL</c>, the system allocates memory for the DIB. The system closes the handle to that memory
/// when you later delete the DIB by calling the DeleteObject function. If hSection is not <c>NULL</c>, you must close the hSection
/// memory handle yourself after calling <c>DeleteObject</c> to delete the bitmap.
/// </para>
/// <para>You cannot paste a DIB section from one application into another application.</para>
/// <para>
/// <c>CreateDIBSection</c> does not use the BITMAPINFOHEADER parameters biXPelsPerMeter or biYPelsPerMeter and will not provide
/// resolution information in the BITMAPINFO structure.
/// </para>
/// <para>
/// You need to guarantee that the GDI subsystem has completed any drawing to a bitmap created by <c>CreateDIBSection</c> before you
/// draw to the bitmap yourself. Access to the bitmap must be synchronized. Do this by calling the GdiFlush function. This applies to
/// any use of the pointer to the bitmap bit values, including passing the pointer in calls to functions such as SetDIBits.
/// </para>
/// <para><c>ICM:</c> No color management is done.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibsection HBITMAP CreateDIBSection( HDC hdc, const
// BITMAPINFO *pbmi, UINT usage, VOID **ppvBits, HANDLE hSection, DWORD offset );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "9276ec84-2860-42be-a9f8-d4efb8d25eec")]
public static extern SafeHBITMAP CreateDIBSection([In, Optional] HDC hdc, [In] SafeBITMAPINFO pbmi, DIBColorMode usage, out IntPtr ppvBits, [In, Optional] HSECTION hSection, [In, Optional] uint offset);
/// <summary>
/// <para>
/// The <c>CreateDiscardableBitmap</c> function creates a discardable bitmap that is compatible with the specified device. The bitmap
/// has the same bits-per-pixel format and the same color palette as the device. An application can select this bitmap as the current
/// bitmap for a memory device that is compatible with the specified device.
/// </para>
/// <para>
/// <c>Note</c> This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the
/// CreateCompatibleBitmap function.
/// </para>
/// </summary>
/// <param name="hdc">A handle to a device context.</param>
/// <param name="cx">The width, in pixels, of the bitmap.</param>
/// <param name="cy">The height, in pixels, of the bitmap.</param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to the compatible bitmap (DDB).</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>When you no longer need the bitmap, call the DeleteObject function to delete it.</remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-creatediscardablebitmap HBITMAP CreateDiscardableBitmap( HDC
// hdc, int cx, int cy );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "79168baf-26ea-4d24-b75c-d0658a56892c")]
public static extern SafeHBITMAP CreateDiscardableBitmap(HDC hdc, int cx, int cy);
/// <summary>The <c>ExtFloodFill</c> function fills an area of the display surface with the current brush.</summary>
/// <param name="hdc">A handle to a device context.</param>
/// <param name="x">The x-coordinate, in logical units, of the point where filling is to start.</param>
/// <param name="y">The y-coordinate, in logical units, of the point where filling is to start.</param>
/// <param name="color">
/// The color of the boundary or of the area to be filled. The interpretation of crColor depends on the value of the fuFillType
/// parameter. To create a COLORREF color value, use the RGB macro.
/// </param>
/// <param name="type">
/// <para>The type of fill operation to be performed. This parameter must be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>FLOODFILLBORDER</term>
/// <term>
/// The fill area is bounded by the color specified by the crColor parameter. This style is identical to the filling performed by the
/// FloodFill function.
/// </term>
/// </item>
/// <item>
/// <term>FLOODFILLSURFACE</term>
/// <term>
/// The fill area is defined by the color that is specified by crColor. Filling continues outward in all directions as long as the
/// color is encountered. This style is useful for filling areas with multicolored boundaries.
/// </term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The following are some of the reasons this function might fail:</para>
/// <list type="bullet">
/// <item>
/// <term>The filling could not be completed.</term>
/// </item>
/// <item>
/// <term>The specified point has the boundary color specified by the crColor parameter (if FLOODFILLBORDER was requested).</term>
/// </item>
/// <item>
/// <term>The specified point does not have the color specified by crColor (if FLOODFILLSURFACE was requested).</term>
/// </item>
/// <item>
/// <term>The point is outside the clipping regionthat is, it is not visible on the device.</term>
/// </item>
/// </list>
/// <para>
/// If the fuFillType parameter is FLOODFILLBORDER, the system assumes that the area to be filled is completely bounded by the color
/// specified by the crColor parameter. The function begins filling at the point specified by the nXStart and nYStart parameters and
/// continues in all directions until it reaches the boundary.
/// </para>
/// <para>
/// If fuFillType is FLOODFILLSURFACE, the system assumes that the area to be filled is a single color. The function begins to fill
/// the area at the point specified by nXStart and nYStart and continues in all directions, filling all adjacent regions containing
/// the color specified by crColor.
/// </para>
/// <para>
/// Only memory device contexts and devices that support raster-display operations support the <c>ExtFloodFill</c> function. To
/// determine whether a device supports this technology, use the GetDeviceCaps function.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see "Adding Lines and Graphs to a Menu" in Using Menus.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-extfloodfill BOOL ExtFloodFill( HDC hdc, int x, int y,
// COLORREF color, UINT type );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "b996d47d-5aaf-4b13-8643-209744e5a04b")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ExtFloodFill(HDC hdc, int x, int y, COLORREF color, FloodFillType type);
/// <summary>
/// <para>
/// The <c>FloodFill</c> function fills an area of the display surface with the current brush. The area is assumed to be bounded as
/// specified by the crFill parameter.
/// </para>
/// <para>
/// <c>Note</c> The <c>FloodFill</c> function is included only for compatibility with 16-bit versions of Windows. Applications should
/// use the ExtFloodFill function with FLOODFILLBORDER specified.
/// </para>
/// </summary>
/// <param name="hdc">A handle to a device context.</param>
/// <param name="x">The x-coordinate, in logical units, of the point where filling is to start.</param>
/// <param name="y">The y-coordinate, in logical units, of the point where filling is to start.</param>
/// <param name="color">The color of the boundary or the area to be filled. To create a COLORREF color value, use the RGB macro.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The following are reasons this function might fail:</para>
/// <list type="bullet">