using System;
using System.Drawing;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Gdi32
{
[PInvokeData("Wingdi.h")]
public const int LF_FACESIZE = 32;
/// The background mode used by the function.
[PInvokeData("Wingdi.h", MSDNShortId = "dd162965")]
public enum BackgroundMode
{
/// Indicates that on return, the has failed.
ERROR = 0,
/// Background remains untouched.
TRANSPARENT = 1,
/// Background is filled with the current background color before the text, hatched brush, or pen is drawn.
OPAQUE = 2,
}
/// Brush style used by .
[PInvokeData("wingdi.h", MSDNShortId = "ded2c7a4-2248-4d01-95c6-ab4050719094")]
public enum BrushStyle : uint
{
///
/// A pattern brush defined by a device-independent bitmap (DIB) specification. If lbStyle is BS_DIBPATTERN, the lbHatch member
/// contains a handle to a packed DIB. For more information, see discussion in lbHatch.
///
BS_DIBPATTERN = 5,
/// See BS_DIBPATTERN.
BS_DIBPATTERN8X8 = 8,
///
/// A pattern brush defined by a device-independent bitmap (DIB) specification. If lbStyle is BS_DIBPATTERNPT, the lbHatch member
/// contains a pointer to a packed DIB. For more information, see discussion in lbHatch.
///
BS_DIBPATTERNPT = 6,
/// Hatched brush.
BS_HATCHED = 2,
/// Hollow brush.
BS_HOLLOW = 1,
/// Not supported.
BS_INDEXED = 4,
/// Not supported.
BS_MONOPATTERN = 9,
/// Same as BS_HOLLOW.
BS_NULL = 1,
/// Pattern brush defined by a memory bitmap.
BS_PATTERN = 3,
/// See BS_PATTERN.
BS_PATTERN8X8 = 7,
/// Solid brush.
BS_SOLID = 0
}
/// The DC layout used by the function.
[PInvokeData("Wingdi.h", MSDNShortId = "dd162979")]
public enum DCLayout
{
/// Indicates that on return, the has failed.
GDI_ERROR = -1,
/// Sets the default horizontal layout to be right to left.
LAYOUT_RTL = 1,
/// Sets the default horizontal layout to be bottom to top.
LAYOUT_BTT = 2,
/// Sets the default horizontal layout to be vertical before horizontal.
LAYOUT_VBH = 4,
/// Disables any reflection during BitBlt and StretchBlt operations.
LAYOUT_BITMAPORIENTATIONPRESERVED = 8,
}
/// Values used by the function.
public enum DeviceCap
{
/// Device driver version
DRIVERVERSION = 0,
/// Device classification
TECHNOLOGY = 2,
/// Horizontal size in millimeters
HORZSIZE = 4,
/// Vertical size in millimeters
VERTSIZE = 6,
/// Horizontal width in pixels
HORZRES = 8,
/// Vertical height in pixels
VERTRES = 10,
/// Number of bits per pixel
BITSPIXEL = 12,
/// Number of planes
PLANES = 14,
/// Number of brushes the device has
NUMBRUSHES = 16,
/// Number of pens the device has
NUMPENS = 18,
/// Number of markers the device has
NUMMARKERS = 20,
/// Number of fonts the device has
NUMFONTS = 22,
/// Number of colors the device supports
NUMCOLORS = 24,
/// Size required for device descriptor
PDEVICESIZE = 26,
/// Curve capabilities
CURVECAPS = 28,
/// Line capabilities
LINECAPS = 30,
/// Polygonal capabilities
POLYGONALCAPS = 32,
/// Text capabilities
TEXTCAPS = 34,
/// Clipping capabilities
CLIPCAPS = 36,
/// Bitblt capabilities
RASTERCAPS = 38,
/// Length of the X leg
ASPECTX = 40,
/// Length of the Y leg
ASPECTY = 42,
/// Length of the hypotenuse
ASPECTXY = 44,
/// Shading and Blending caps
SHADEBLENDCAPS = 45,
/// Logical pixels inch in X
LOGPIXELSX = 88,
/// Logical pixels inch in Y
LOGPIXELSY = 90,
/// Number of entries in physical palette
SIZEPALETTE = 104,
/// Number of reserved entries in palette
NUMRESERVED = 106,
/// Actual color resolution
COLORRES = 108,
// Printing related DeviceCaps. These replace the appropriate Escapes
/// Physical Width in device units
PHYSICALWIDTH = 110,
/// Physical Height in device units
PHYSICALHEIGHT = 111,
/// Physical Printable Area x margin
PHYSICALOFFSETX = 112,
/// Physical Printable Area y margin
PHYSICALOFFSETY = 113,
/// Scaling factor x
SCALINGFACTORX = 114,
/// Scaling factor y
SCALINGFACTORY = 115,
/// Current vertical refresh rate of the display device (for displays only) in Hz
VREFRESH = 116,
/// Vertical height of entire desktop in pixels
DESKTOPVERTRES = 117,
/// Horizontal width of entire desktop in pixels
DESKTOPHORZRES = 118,
/// Preferred blt alignment
BLTALIGNMENT = 119
}
/// Hatch style used by .
[PInvokeData("wingdi.h", MSDNShortId = "ded2c7a4-2248-4d01-95c6-ab4050719094")]
public enum HatchStyle : uint
{
/// A 45-degree upward, left-to-right hatch
HS_BDIAGONAL = 3,
/// Horizontal and vertical cross-hatch
HS_CROSS = 4,
/// 45-degree crosshatch
HS_DIAGCROSS = 5,
/// A 45-degree downward, left-to-right hatch
HS_FDIAGONAL = 2,
/// Horizontal hatch
HS_HORIZONTAL = 0,
/// Vertical hatch
HS_VERTICAL = 1
}
///
/// 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 function.
///
[PInvokeData("Wingdi.h", MSDNShortId = "dd183370")]
public enum RasterOperationMode
{
/// Copies the source rectangle directly to the destination rectangle.
SRCCOPY = 0x00CC0020,
/// Combines the colors of the source and destination rectangles by using the Boolean OR operator.
SRCPAINT = 0x00EE0086,
/// Combines the colors of the source and destination rectangles by using the Boolean AND operator.
SRCAND = 0x008800C6,
/// Combines the colors of the source and destination rectangles by using the Boolean XOR operator.
SRCINVERT = 0x00660046,
///
/// Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator.
///
SRCERASE = 0x00440328,
///
NOTSRCCOPY = 0x00330008,
/// Copies the inverted source rectangle to the destination.
NOTSRCERASE = 0x001100A6,
///
/// Merges the colors of the source rectangle with the brush currently selected in hdcDest, by using the Boolean AND operator.
///
MERGECOPY = 0x00C000CA,
///
/// Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator.
///
MERGEPAINT = 0x00BB0226,
/// Copies the brush currently selected in hdcDest, into the destination bitmap.
PATCOPY = 0x00F00021,
///
/// 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.
///
PATPAINT = 0x00FB0A09,
///
/// Combines the colors of the brush currently selected in hdcDest, with the colors of the destination rectangle by using the
/// Boolean XOR operator.
///
PATINVERT = 0x005A0049,
/// Inverts the destination rectangle.
DSTINVERT = 0x00550009,
///
/// Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the
/// default physical palette.)
///
BLACKNESS = 0x00000042,
///
/// Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the
/// default physical palette.)
///
WHITENESS = 0x00FF0062,
/// Prevents the bitmap from being mirrored.
NOMIRRORBITMAP = -2147483648,
///
/// 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.
///
CAPTUREBLT = 0x40000000
}
/// The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels.
/// A handle to the destination device context.
/// The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
/// The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
/// The width, in logical units, of the destination rectangle.
/// The height, in logical units, of the destination rectangle.
/// A handle to the source device context.
/// The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
/// The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
/// The width, in logical units, of the source rectangle.
/// The height, in logical units, of the source rectangle.
///
/// 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.
///
/// If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE.
///
/// 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).
///
/// 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.
///
/// An error occurs (and the function returns FALSE) if the source device context identifies an enhanced metafile device context.
///
/// If destination and source bitmaps do not have the same color format, AlphaBlend converts the source bitmap to match the
/// destination bitmap.
///
///
/// AlphaBlend does not support mirroring. If either the width or height of the source or destination is negative, this call will fail.
///
///
/// 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.
///
///
/// 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.
///
///
/// The source rectangle must lie completely within the source surface, otherwise an error occurs and the function returns FALSE.
///
/// AlphaBlend fails if the width or height of the source or destination is negative.
///
/// 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.
///
///
[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);
///
/// 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.
///
/// A handle to the destination device context.
/// The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
/// The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
/// The width, in logical units, of the destination rectangle.
/// The height, in logical units, of the destination rectangle.
/// A handle to the source device context.
/// The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
/// The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
///
/// 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.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// BitBlt only does clipping on the destination DC.
///
/// 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.
///
///
/// 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.
///
///
/// When an enhanced metafile is being recorded, an error occurs if the source device context identifies an enhanced-metafile device context.
///
///
/// 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.
///
///
/// 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.
///
/// ICM: No color management is performed when blits occur.
///
[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);
/// The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
///
/// A handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen.
///
///
/// If the function succeeds, the return value is the handle to a memory DC.
/// If the function fails, the return value is NULL.
///
///
/// A memory DC exists only in memory. When the memory DC is created, its display surface is exactly one monochrome pixel wide and
/// one monochrome pixel high. Before an application can use a memory DC for drawing operations, it must select a bitmap of the
/// correct width and height into the DC. To select a bitmap into a DC, use the CreateCompatibleBitmap function, specifying the
/// height, width, and color organization required.
///
/// When a memory DC is created, all attributes are set to normal default values. The memory DC can be used as a normal DC. You can
/// set the attributes; obtain the current settings of its attributes; and select pens, brushes, and regions.
///
///
/// The CreateCompatibleDC function can only be used with devices that support raster operations. An application can determine
/// whether a device supports these operations by calling the GetDeviceCaps function.
///
///
/// When you no longer need the memory DC, call the DeleteDC function. We recommend that you call DeleteDC to delete the DC. However,
/// you can also call DeleteObject with the HDC to delete the DC.
///
///
/// If hdc is NULL, the thread that calls CreateCompatibleDC owns the HDC that is created. When this thread is destroyed, the HDC is
/// no longer valid. Thus, if you create the HDC and pass it to another thread, then exit the first thread, the second thread will
/// not be able to use the HDC.
///
///
/// ICM: If the DC that is passed to this function is enabled for Image Color Management (ICM), the DC created by the function is
/// ICM-enabled. The source and destination color spaces are specified in the DC.
///
///
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd183489")]
public static extern SafeHDC CreateCompatibleDC(HDC hDC);
/// The DeleteDC function deletes the specified device context (DC).
/// A handle to the device context.
/// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
///
/// An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC
/// function to free the DC.
///
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
[System.Security.SecurityCritical]
[PInvokeData("Wingdi.h", MSDNShortId = "dd183533")]
public static extern bool DeleteDC(HDC hdc);
///
/// The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated
/// with the object. After the object is deleted, the specified handle is no longer valid.
///
/// A handle to a logical pen, brush, font, bitmap, region, or palette.
///
/// If the function succeeds, the return value is nonzero. If the specified handle is not valid or is currently selected into a DC,
/// the return value is zero.
///
///
/// Do not delete a drawing object (pen or brush) while it is still selected into a DC.
/// When a pattern brush is deleted, the bitmap associated with the brush is not deleted. The bitmap must be deleted independently.
///
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd183539")]
public static extern bool DeleteObject(HGDIOBJ hObject);
/// The GdiFlush function flushes the calling thread's current batch.
///
/// If all functions in the current batch succeed, the return value is nonzero.
///
/// If not all functions in the current batch succeed, the return value is zero, indicating that at least one function returned an error.
///
///
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
[System.Security.SecurityCritical]
[PInvokeData("Wingdi.h", MSDNShortId = "dd144844")]
public static extern bool GdiFlush();
/// The GetDeviceCaps function retrieves device-specific information for the specified device.
/// A handle to the DC.
/// The item to be returned.
///
/// The return value specifies the value of the desired item. When nIndex is BITSPIXEL and the device has 15bpp or 16bpp, the return
/// value is 16.
///
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877(v=vs.85).aspx
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd144877")]
public static extern int GetDeviceCaps(HDC hdc, DeviceCap index);
/// The GetObject function retrieves information for the specified graphics object.
///
/// A handle to the graphics object of interest. This can be a handle to one of the following: a logical bitmap, a brush, a font, a
/// palette, a pen, or a device independent bitmap created by calling the CreateDIBSection function.
///
/// The number of bytes of information to be written to the buffer.
///
/// A pointer to a buffer that receives the information about the specified graphics object. If the
/// parameter is NULL, the function return value is the number of bytes required to store the information it writes to the buffer for
/// the specified graphics object.
///
///
/// If the function succeeds, and is a valid pointer, the return value is the number of bytes stored
/// into the buffer.
///
/// If the function succeeds, and is NULL, the return value is the number of bytes required to hold the
/// information the function would store into the buffer.
///
/// If the function fails, the return value is zero.
///
///
/// The buffer pointed to by the parameter must be sufficiently large to receive the information about
/// the graphics object. Depending on the graphics object, the function uses a BITMAP, DIBSECTION, EXTLOGPEN, LOGBRUSH, LOGFONT, or
/// LOGPEN structure, or a count of table entries (for a logical palette).
///
/// If is a handle to a bitmap created by calling CreateDIBSection, and the specified buffer is large
/// enough, the GetObject function returns a DIBSECTION structure. In addition, the bmBits member of the BITMAP structure contained
/// within the DIBSECTION will contain a pointer to the bitmap's bit values.
///
///
/// If is a handle to a bitmap created by any other means, GetObject returns only the width, height, and
/// color format information of the bitmap. You can obtain the bitmap's bit values by calling the GetDIBits or GetBitmapBits function.
///
///
/// If is a handle to a logical palette, GetObject retrieves a 2-byte integer that specifies the number of
/// entries in the palette. The function does not retrieve the LOGPALETTE structure defining the palette. To retrieve information
/// about palette entries, an application can call the GetPaletteEntries function.
///
///
/// If is a handle to a font, the LOGFONT that is returned is the LOGFONT used to create the font. If
/// Windows had to make some interpolation of the font because the precise LOGFONT could not be represented, the interpolation will
/// not be reflected in the LOGFONT. For example, if you ask for a vertical version of a font that doesn't support vertical painting,
/// the LOGFONT indicates the font is vertical, but Windows will paint it horizontally.
///
///
[DllImport(Lib.Gdi32, CharSet = CharSet.Auto, SetLastError = true)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd144904")]
public static extern int GetObject(HGDIOBJ hgdiobj, int cbBuffer, IntPtr lpvObject);
/// The GetObject function retrieves information for the specified graphics object.
/// The output structure type.
///
/// A handle to the graphics object of interest. This can be a handle to one of the following: a logical bitmap, a brush, a font, a
/// palette, a pen, or a device independent bitmap created by calling the CreateDIBSection function.
///
/// The output structure holding the information for the graphics object.
[PInvokeData("Wingdi.h", MSDNShortId = "dd144904")]
public static T GetObject(HGDIOBJ hgdiobj) where T : struct
{
using (var ptr = GetObject(hgdiobj))
return ptr.ToStructure();
}
/// The GetObject function retrieves information for the specified graphics object.
///
/// A handle to the graphics object of interest. This can be a handle to one of the following: a logical bitmap, a brush, a font, a
/// palette, a pen, or a device independent bitmap created by calling the CreateDIBSection function.
///
/// Allocated memory holding the information for the graphics object.
[PInvokeData("Wingdi.h", MSDNShortId = "dd144904")]
public static SafeHGlobalHandle GetObject(HGDIOBJ hgdiobj)
{
var sz = GetObject(hgdiobj, 0, IntPtr.Zero);
var ptr = new SafeHGlobalHandle(sz);
var ret = GetObject(hgdiobj, ptr.Size, (IntPtr)ptr);
if (ret == 0)
Win32Error.ThrowLastError();
return ptr;
}
/// Converts a height in logical units to pixels.
/// The height in logical units.
/// The device context handle.
/// The height in pixels.
public static int LogicalHeightToDeviceWidth(int height, HDC hdc = default)
{
var pts = new[] { new Point(0, height) };
LPtoDP(hdc.IsNull ? SafeHDC.ScreenCompatibleDCHandle : hdc, pts, 1);
return pts[0].Y;
}
/// Converts a width in logical units to pixels.
/// The width in logical units.
/// The device context handle.
/// The width in pixels.
public static int LogicalWidthToDeviceWidth(int width, HDC hdc = default)
{
var pts = new[] { new Point(width, 0) };
LPtoDP(hdc.IsNull ? SafeHDC.ScreenCompatibleDCHandle : hdc, pts, 1);
return pts[0].X;
}
///
///
/// The LPtoDP function converts logical coordinates into device coordinates. The conversion depends on the mapping mode of
/// the device context, the settings of the origins and extents for the window and viewport, and the world transformation.
///
///
///
/// A handle to the device context.
///
///
///
/// A pointer to an array of POINT structures. The x-coordinates and y-coordinates contained in each of the POINT structures
/// will be transformed.
///
///
///
/// The number of points in the array.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The LPtoDP function fails if the logical coordinates exceed 32 bits, or if the converted device coordinates exceed 27
/// bits. In the case of such an overflow, the results for all the points are undefined.
///
///
/// LPtoDP calculates complex floating-point arithmetic, and it has a caching system for efficiency. Therefore, the conversion
/// result of an initial call to LPtoDP might not exactly match the conversion result of a later call to LPtoDP. We
/// recommend not to write code that relies on the exact match of the conversion results from multiple calls to LPtoDP even if
/// the parameters that are passed to each call are identical.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-lptodp
// BOOL LPtoDP( HDC hdc, LPPOINT lppt, int c );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "670a16fb-842e-4250-9ad7-dc08e849c2ba")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool LPtoDP(HDC hdc, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Point[] lppt, int c);
///
/// The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object
/// of the same type.
///
/// A handle to the DC.
///
/// A handle to the object to be selected. The specified object must have been created by using one of the following functions.
///
///
/// If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced. If
/// the selected object is a region and the function succeeds, the return value is one of the following values.
///
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd162957")]
public static extern HGDIOBJ SelectObject(HDC hDC, HGDIOBJ hObject);
///
/// The SetBkMode function sets the background mix mode of the specified device context. The background mix mode is used with text,
/// hatched brushes, and pen styles that are not solid lines.
///
/// A handle to the device context.
/// The background mode.
///
/// If the function succeeds, the return value specifies the previous background mode. If the function fails, the return value is zero.
///
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd162965")]
public static extern BackgroundMode SetBkMode(HDC hdc, BackgroundMode mode);
/// The SetLayout function changes the layout of a device context (DC).
/// A handle to the DC.
/// The DC layout.
/// If the function succeeds, it returns the previous layout of the DC. If the function fails, it returns GDI_ERROR.
///
/// The layout specifies the order in which text and graphics are revealed in a window or a device context. The default is left to
/// right. The SetLayout function changes this to be right to left, which is the standard in Arabic and Hebrew cultures.
///
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd162979")]
public static extern DCLayout SetLayout(HDC hdc, DCLayout dwLayout);
///
/// The TransparentBlt 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.
///
/// A handle to the destination device context.
/// The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
/// The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
/// The width, in logical units, of the destination rectangle.
/// The height, in logical units, of the destination rectangle.
/// A handle to the source device context.
/// The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
/// The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
/// The width, in logical units, of the source rectangle.
/// The height, in logical units, of the source rectangle.
/// The RGB color in the source bitmap to treat as transparent.
/// If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE.
///
/// The TransparentBlt function works with compatible bitmaps (DDBs).
///
/// The TransparentBlt function supports all formats of source bitmaps. However, for 32 bpp bitmaps, it just copies the alpha value
/// over. Use AlphaBlend to specify 32 bits-per-pixel bitmaps with transparency.
///
///
/// If the source and destination rectangles are not the same size, the source bitmap is stretched to match the destination
/// rectangle. When the SetStretchBltMode function is used, the iStretchMode modes of BLACKONWHITE and WHITEONBLACK are converted to
/// COLORONCOLOR for the TransparentBlt function.
///
///
/// The destination device context specifies the transformation type for the destination coordinates. The source device context
/// specifies the transformation type for the source coordinates.
///
/// TransparentBlt does not mirror a bitmap if either the width or height, of either the source or destination, is negative.
///
/// When used in a multiple monitor system, both hdcSrc and hdcDest must refer to the same device or the function will fail. 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.
///
///
[DllImport(Lib.Gdi32, SetLastError = true, EntryPoint = "GdiTransparentBlt")]
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd145141")]
public static extern bool TransparentBlt(HDC hdcDest, int xOriginDest, int yOriginDest, int wDest, int hDest, HDC hdcSrc, int xOriginSrc, int yOriginSrc, int wSrc, int hSrc, int crTransparent);
}
}