Class Gdi32Api
Gdi32 Helpers
Inheritance
Namespace: Dapplo.Windows.Gdi32
Assembly: Dapplo.Windows.Gdi32.dll
Syntax
public static class Gdi32Api : object
Methods
| Improve this Doc View SourceBitBlt(Graphics, Bitmap, Rectangle, Point, RasterOperations)
Bitblt extension for the graphics object
Declaration
public static void BitBlt(this Graphics target, Bitmap sourceBitmap, Rectangle source, Point destination, RasterOperations rasterOperations)
Parameters
Type | Name | Description |
---|---|---|
Graphics | target | Graphics |
Bitmap | sourceBitmap | Bitmap |
Rectangle | source | Rectangle |
Point | destination | Point |
RasterOperations | rasterOperations | RasterOperations |
BitBlt(SafeHandle, Int32, Int32, Int32, Int32, SafeHandle, Int32, Int32, RasterOperations)
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.
Declaration
public static bool BitBlt(SafeHandle hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, SafeHandle hdcSrc, int nXSrc, int nYSrc, RasterOperations rasterOperation)
Parameters
Type | Name | Description |
---|---|---|
SafeHandle | hdcDest | A handle to the destination device context. |
System.Int32 | nXDest | The x-coordinate, in logical units, of the upper-left corner of the destination rectangle. |
System.Int32 | nYDest | The y-coordinate, in logical units, of the upper-left corner of the destination rectangle. |
System.Int32 | nWidth | The width, in logical units, of the source and destination rectangles. |
System.Int32 | nHeight | The height, in logical units, of the source and the destination rectangles. |
SafeHandle | hdcSrc | A handle to the source device context. |
System.Int32 | nXSrc | The x-coordinate, in logical units, of the upper-left corner of the source rectangle. |
System.Int32 | nYSrc | The y-coordinate, in logical units, of the upper-left corner of the source rectangle. |
RasterOperations | rasterOperation | 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. |
Returns
Type | Description |
---|---|
System.Boolean |
CreateCompatibleDC(SafeHandle)
The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device. See CreateCompatibleDC function
Declaration
public static SafeCompatibleDcHandle CreateCompatibleDC(SafeHandle hDc)
Parameters
Type | Name | Description |
---|---|---|
SafeHandle | hDc | A handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen. |
Returns
Type | Description |
---|---|
SafeCompatibleDcHandle | If the function succeeds, the return value is the handle to a memory DC. If the function fails, the return value is NULL. |
CreateDIBSection(SafeHandle, ref BitmapInfoHeader, UInt32, out IntPtr, IntPtr, UInt32)
The CreateDIBSection 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. See CreateDIBSection function
Declaration
public static SafeDibSectionHandle CreateDIBSection(SafeHandle hdc, ref BitmapInfoHeader bmi, uint usage, out IntPtr bits, IntPtr hSection, uint dwOffset)
Parameters
Type | Name | Description |
---|---|---|
SafeHandle | 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. |
BitmapInfoHeader | bmi | A pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including the bitmap dimensions and colors. |
System.UInt32 | usage | The type of data contained in the bmiColors array member of the BITMAPINFO structure pointed to by pbmi (either logical palette indexes or literal RGB values). The following values are defined. DIB_PAL_COLORS The bmiColors member is an array of 16-bit indexes into the logical palette of the device context specified by hdc. DIB_RGB_COLORS The BITMAPINFO structure contains an array of literal RGB values. |
IntPtr | bits | A pointer to a variable that receives a pointer to the location of the DIB bit values. |
IntPtr | hSection | A handle to a file-mapping object that the function will use to create the DIB. This parameter can be NULL. If hSection is not NULL, 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 CreateDIBSection to fail. If hSection is not NULL, the CreateDIBSection 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 HBITMAP returned by CreateDIBSection. If hSection is NULL, the system allocates memory for the DIB. In this case, the CreateDIBSection function ignores the dwOffset parameter. An application cannot later obtain a handle to this memory. The dshSection member of the DIBSECTION structure filled in by calling the GetObject function will be NULL. |
System.UInt32 | dwOffset | 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 NULL. The bitmap bit values are aligned on doubleword boundaries, so dwOffset must be a multiple of the size of a DWORD. |
Returns
Type | Description |
---|---|
SafeDibSectionHandle | If the function succeeds, the return value is a handle to the newly created DIB, and *ppvBits points to the bitmap bit values. If the function fails, the return value is NULL, and *ppvBits is NULL. |
CreateRectRgn(Int32, Int32, Int32, Int32)
The CreateRectRgn function creates a rectangular region. See CreateRectRgn function
Declaration
public static SafeRegionHandle CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nLeftRect | Specifies the x-coordinate of the upper-left corner of the region in logical units. |
System.Int32 | nTopRect | Specifies the y-coordinate of the upper-left corner of the region in logical units. |
System.Int32 | nRightRect | Specifies the x-coordinate of the lower-right corner of the region in logical units. |
System.Int32 | nBottomRect | Specifies the y-coordinate of the lower-right corner of the region in logical units. |
Returns
Type | Description |
---|---|
SafeRegionHandle | If the function succeeds, the return value is the handle to the region. If the function fails, the return value is NULL. |
GetDeviceCaps(SafeHandle, DeviceCaps)
See GetDeviceCaps function The GetDeviceCaps function retrieves device-specific information for the specified device.
Declaration
public static int GetDeviceCaps(SafeHandle hdc, DeviceCaps nIndex)
Parameters
Type | Name | Description |
---|---|---|
SafeHandle | hdc | A handle to the DC. |
DeviceCaps | nIndex | The item to be returned |
Returns
Type | Description |
---|---|
System.Int32 |
GetPixel(SafeHandle, Int32, Int32)
See GetPixel function The GetPixel function retrieves the red, green, blue (RGB) color value of the pixel at the specified coordinates.
Declaration
public static uint GetPixel(SafeHandle hdc, int nXPos, int nYPos)
Parameters
Type | Name | Description |
---|---|---|
SafeHandle | hdc | A handle to the device context. |
System.Int32 | nXPos | The x-coordinate, in logical units, of the pixel to be examined. |
System.Int32 | nYPos | The y-coordinate, in logical units, of the pixel to be examined. |
Returns
Type | Description |
---|---|
System.UInt32 | The return value is the COLORREF value that specifies the RGB of the pixel. If the pixel is outside of the current clipping region, the return value is CLR_INVALID (0xFFFFFFFF defined in Wingdi.h). |
SelectObject(SafeHandle, SafeHandle)
The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type.
Declaration
public static IntPtr SelectObject(SafeHandle hDc, SafeHandle hObject)
Parameters
Type | Name | Description |
---|---|---|
SafeHandle | hDc | A handle to the DC. |
SafeHandle | hObject | A handle to the object to be selected. The specified object must have been created by using one of the following functions. Object Functions Bitmap CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (Bitmaps can only be selected into memory DC's. A single bitmap cannot be selected into more than one DC at the same time.) Brush CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush Font CreateFont, CreateFontIndirect Pen CreatePen, CreatePenIndirect Region CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect |
Returns
Type | Description |
---|---|
IntPtr | 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. SIMPLEREGION Region consists of a single rectangle. COMPLEXREGION Region consists of more than one rectangle. NULLREGION Region is empty. |
StretchBlt(Graphics, Bitmap, Rectangle, Rectangle, RasterOperations)
StretchBlt extension for the graphics object Doesn't work?
Declaration
public static void StretchBlt(this Graphics target, Bitmap sourceBitmap, Rectangle source, Rectangle destination, RasterOperations rasterOperation)
Parameters
Type | Name | Description |
---|---|---|
Graphics | target | Graphics |
Bitmap | sourceBitmap | Bitmap |
Rectangle | source | Rectangle |
Rectangle | destination | Rectangle |
RasterOperations | rasterOperation | RasterOperations |