Desktop Functions: Smart Device Functions:
|
Search Results for "BITMAP" in [All]gdi321: AlphaBlend
2: BitBlt BitBlt returns an error if the source and destination device contexts represent different devices. To transfer data between device contexts 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. Here's a way to take a bitmap snapshot of any Windows.Forms.Control (PInvoke signatrue omitted for brevity)
private Bitmap SnapShot(win.Control c)
Bitmap bmp;
bmp=new Bitmap(c.Width, c.Height); The BitBlt function can be used to quickly render a Bitmap onto a Control (and much, much more). For this purpose, it is much faster than the managed alternative, Graphics.DrawImage(). See the example code below.
IntPtr pOrig = SelectObject(pSource, bmp.GetHbitmap()); 3: CreateBitmap
static extern IntPtr CreateBitmap(int nWidth, int nHeight, uint cPlanes, uint cBitsPerPel, IntPtr lpvBits);
Private Shared Function CreateBitmap(nWidth As Integer, nHeight As Integer, cPlanes As UInteger, cBitsPerPel As UInteger, lpvBits As IntPtr) As IntPtr The [System.Drawing.Bitmap] constructor, although it creates a DIB rather than a DDB.
/// Creates a bitmap compatible with the device that is associated with the specified device context.
/// <param name="nWidth">The bitmap width, in pixels.</param>
/// <param name="nHeight">The bitmap height, in pixels.</param>
/// <returns>If the function succeeds, the return value is a handle to the compatible bitmap (DDB). If the function fails, the return value is <see cref="System.IntPtr.Zero"/>.</returns>
[DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")]
static extern IntPtr CreateCompatibleBitmap([In] IntPtr hdc, int nWidth, int nHeight);
Private Shared Function CreateCompatibleBitmap(hdc As IntPtr, nWidth As Integer, nHeight As Integer) As IntPtr
static extern IntPtr CreateDIBitmap(IntPtr hdc, [In] ref BITMAPINFOHEADER
lpbmih, uint fdwInit, byte [] lpbInit, [In] ref BITMAPINFO lpbmi,
Public Shared Function CreateDIBitmap( _
ByRef lpbmih As BITMAPINFOHEADER, _
ByRef lpbmi As BITMAPINFO, _
static extern IntPtr CreateDIBSection(IntPtr hdc, [In] ref BITMAPINFO pbmi,
ByRef pbmi As BITMAPINFO, ByVal iUsage As System.UInt32, _ The BITMAPINFO structure defines the dimensions and color information for a DIB, it contains the members BITMAPINFOHEADER structure (contains information about the dimensions of color format) and bmiColors which contains one of the following: See MSDN Documentation for BITMAPINFO concerning specific details concerning structure members.hSection is a handle to a file mapping object that the function will use to create the DIB and can be NULL. If hSection is not NULL, it must be a handle to a file mapping object created by calling the CreateFileMapping function (otherwise CreateDIBSection will fail). Moreover, the CreateDIBSection function will locate the bitmap’s bit values at offset dwOffset in the file mapping object referred to by hSection. An application can retrieve the hSection handle by calling the GetObject function with the HBITMAP returned by CreateDIBSection. dwOffset specifies the offset from the beginning of the file mapping object referenced by hSection where storage for the bitmap’s bit values is to begin (ignored if hSection is NULL). The bitmap’s bit values are aligned on doubleword boundaries, so dwOffset must be a multiple of the size of a DWORD. If the function succeeds, the return value is a handle to the newly created device-independent bitmap (and ppvBits will point to the bitmap’s bit values). If the function fails, the return value is NULL (and ptr ppvBits will be NULL). To get extended error information, call GetLastError. hbmp simply is a handle to a bitmap image. Using the System.Drawing.Bitmap class, you can create whatever pattern you desire.
Dim bB As New Bitmap(Width, Height)
gBrush = CreatePatternBrush(bB.GetHbitmap) 8: CreatePen // create a bitmap and get a pointer suitable for GDI Bitmap maskImage = new Bitmap (width, height); IntPtr maskHbitmap = maskImage.GetHbitmap(); void PaintLine3(IntPtr hbitmap, Point start, Point end, bool erase)
IntPtr pOrig = SelectObject(pDC, hbitmap); 9: DeleteObject
/// <summary>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.</summary>
/// <param name="hObject">A handle to a logical pen, brush, font, bitmap, region, or palette.</param>
/// <para>When a pattern brush is deleted, the bitmap associated with the brush is not deleted. The bitmap must be deleted independently.</para> Call DeleteObject on a HBitmap object after using the GDI+ function:
public static Bitmap FromHbitmap(
IntPtr hbitmap FromHbitmap transfers a copy of the image bytes into returned Bitmap so it is important to call DeleteObject on the HBitmap to prevent two copies of the image from existing in the system. 10: FloodFill
11: GdipLoadImage
private static Type imageType = typeof(System.Drawing.Bitmap);
return (Bitmap) imageType.InvokeMember("FromGDIplus", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { loadingImage }); 12: GetCurrentObject
OBJ_BITMAP = 7, 13: GetDIBits
/// Retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format.
/// <param name="hbmp">A handle to the bitmap. This must be a compatible bitmap (DDB).</param>
/// <param name="lpvBits">A pointer to a buffer to receive the bitmap data. If this parameter is <see cref="IntPtr.Zero"/>, the function passes the dimensions and format of the bitmap to the <see cref="BITMAPINFO"/> structure pointed to by the <paramref name="lpbi"/> parameter.</param>
/// <param name="lpbi">A pointer to a <see cref="BITMAPINFO"/> structure that specifies the desired format for the DIB data.</param>
/// <param name="uUsage">The format of the bmiColors member of the <see cref="BITMAPINFO"/> structure. It must be one of the following values.</param>
/// <returns>If the lpvBits parameter is non-NULL and the function succeeds, the return value is the number of scan lines copied from the bitmap.
/// If the lpvBits parameter is NULL and GetDIBits successfully fills the <see cref="BITMAPINFO"/> structure, the return value is nonzero.
static extern int GetDIBits([In] IntPtr hdc, [In] IntPtr hbmp, uint uStartScan, uint cScanLines, [Out] byte[] lpvBits, ref BITMAPINFO lpbi, DIB_Color_Mode uUsage); 14: GetFontData
/// Deletes a logical pen, brush, font, bitmap, region, or palette handle freeing all system resources associated with the object.
// Create dummy bitmap to generate a graphics device context
using (Graphics g = Graphics.FromImage(new Bitmap(1, 1))) 15: GetGlyphOutline
using(Bitmap b = new Bitmap(1,1)) 16: GetObject Had a terrible time getting this to work to retrieve a BITMAP object from a HBITMAP, this code finally worked. BITMAP bmpScreen; IntPtr ptrToBitmap = hndl.AddrOfPinnedObject(); GDI32.GetObject(hBitmap, Marshal.SizeOf<GDI32.BITMAP>(), ptrToBitmap); bmpScreen = Marshal.PtrToStructure<GDI32.BITMAP>(ptrToBitmap); A better option than the above example would be to leverage Image.FromHbitmap Image.FromHbitmap Documentation on MSDN: https://msdn.microsoft.com/en-us/library/k061we7x 17: GetPixel
// ... and apply the color to Bitmap-struct via SetPixel() or whatever else you want to do with it.. 18: HBitmap
static extern TODO HBitmap(TODO);
Declare Function HBitmap Lib "gdi32.dll" (TODO) As TODO System.Drawing.Bitmap 19: LineTo // create a bitmap and get a pointer suitable for GDI Bitmap maskImage = new Bitmap (width, height); IntPtr maskHbitmap = maskImage.GetHbitmap(); void PaintLine3(IntPtr hbitmap, Point start, Point end, bool erase)
IntPtr pOrig = SelectObject(pDC, hbitmap); 20: MoveToEx // create a bitmap and get a pointer suitable for GDI Bitmap maskImage = new Bitmap (width, height); IntPtr maskHbitmap = maskImage.GetHbitmap(); void PaintLine3(IntPtr hbitmap, Point start, Point end, bool erase)
IntPtr pOrig = SelectObject(pDC, hbitmap); 21: SelectObject
/// <para>An application cannot select a single bitmap into more than one DC at a time.</para> 22: SetBitmapBits SetBitmapBits (gdi32) Summary The SetBitmapBits API static extern int SetBitmapBits(IntPtr hbmp, uint cBytes, byte [] lpBits); Documentation [SetBitmapBits] on MSDN 23: SetDIBits
byte [] lpvBits, [In] ref BITMAPINFO lpbmi, uint fuColorUse); 24: SetMapMode
public static extern int DeleteObject(int hBitmap); 25: SetPixel The SetPixel method sets the color of a specified pixel in this bitmap. 27: StretchBlt
namespace StretchBlt_with_bitmap_image
Bitmap bmp;
hbmp = bmp.GetHbitmap();
bmp = new Bitmap(_fileName); 28: StretchDIBits
int nSrcHeight, byte [] lpBits, [In] ref BITMAPINFO lpBitsInfo, uint iUsage, ole3229: CLIPFORMAT
CF_BITMAP = 2,
CF_DSPBITMAP = 0x82, 30: OleDraw
/// Creates a bitmap from the supplied ActiveX control using OleDraw
Bitmap bmp = new Bitmap(rect.Width, rect.Height); avifil32
ByRef bih As BITMAPINFOHEADER) As Integer 32: AVIStreamRead
ByRef lpFormat As BITMAPINFOHEADER,
Public Structure BITMAPINFOHEADER VB BITMAPINFOHEADER Warning
Public Shared Function AVIStreamReadFormat2(ByVal aviStream As IntPtr, ByVal lPos As Int32, ByRef lpFormat As BITMAPINFOHEADER, ByRef cbFormat As Int32) As Integer
ByRef lpFormat As BITMAPINFOHEADER,
Public Structure BITMAPINFOHEADER VB BITMAPINFOHEADER Warning
Public Shared Function AVIStreamReadFormat2(ByVal aviStream As IntPtr, ByVal lPos As Int32, ByRef lpFormat As BITMAPINFOHEADER, ByRef cbFormat As Int32) As Integer cards34: cdtAnimate
comctl3235: ImageList_Add
static extern bool ImageList_AddMasked(IntPtr hImageList, IntPtr hBitmap, int crMask);
Private Shared Function ImageList_AddMasked(hImageList As IntPtr, hBitmap As IntPtr, crMask As Integer) As Boolean
static extern bool ImageList_AddMasked(IntPtr hImageList, IntPtr hBitmap, int crMask); 37: ImageList_DrawEx
/// <param name="value">A Bitmap of the image to add to the list.</param>
/// <param name="transparentColor">The color to use as the transparent color within the Bitmap.</param>
/// <param name="value">A Bitmap of the image to add to the list.</param>
/// <param name="transparentColor">The color to use as the transparent color within the Bitmap.</param> gdiplus
static extern int GdipBitmapGetPixel(HandleRef bitmap, int x, int y,
Declare Function GdipBitmapGetPixel Lib "gdiplus.dll" (TODO) As TODO From the Bitmap class in the System.Drawing namespace (C# version):
Color color = bitmap.GetPixel(int x, int y);
static extern int GdipBitmapLockBits(HandleRef bitmap, ref GPRECT rect,
ImageLockMode flags, PixelFormat format, ref BitmapData lockedBitmapData);
Declare Function GdipBitmapLockBits Lib "gdiplus.dll" (TODO) As TODO
static extern int GdipBitmapSetPixel(HandleRef bitmap, int x, int y, int argb);
Declare Function GdipBitmapSetPixel Lib "gdiplus.dll" (TODO) As Int In the Bitmap class in the System.Drawing namespace (C# version):
bitmap.SetPixel(int x, int y, Color color);
static extern int GdipBitmapSetResolution(HandleRef bitmap, float dpix,
Declare Function GdipBitmapSetResolution Lib "gdiplus.dll" (TODO) As TODO
static extern int GdipBitmapUnlockBits(HandleRef bitmap,
BitmapData lockedBitmapData);
Declare Function GdipBitmapUnlockBits Lib "gdiplus.dll" (TODO) As TODO
static extern int GdipCloneBitmapAreaI(int x, int y, int width,
int height, int format, HandleRef srcbitmap, out IntPtr dstbitmap);
Declare Function GdipCloneBitmapAreaI Lib "gdiplus.dll" (TODO) As TODO
static extern int GdipCreateBitmapFromFileICM(string filename,
out IntPtr bitmap);
Declare Function GdipCreateBitmapFromFileICM Lib "gdiplus.dll" (TODO) As TODO
static extern int GdipCreateBitmapFromGdiDib(IntPtr bminfo, IntPtr pixdat, ref IntPtr image);
Declare Function GdipCreateBitmapFromGdiDib Lib "GdiPlus.dll" (ByRef GdiBitmapInfo As BITMAPINFO, ByVal GdiBitmapData As Long, ByRef bitmap As Long) As Status
int st = GdipCreateBitmapFromGdiDib(bminfo, pixdat, ref img);
static extern int GdipCreateBitmapFromGraphics(int width, int height,
HandleRef graphics, out IntPtr bitmap);
Declare Function GdipCreateBitmapFromGraphics Lib "gdiplus.dll" (TODO) As TODO
static extern int GdipCreateBitmapFromHBITMAP(HandleRef hbitmap,
HandleRef hpalette, out IntPtr bitmap);
Declare Function GdipCreateBitmapFromHBITMAP Lib "gdiplus.dll" (TODO) As TODO
static extern int GdipCreateBitmapFromHICON(HandleRef hicon, out IntPtr bitmap);
Declare Function GdipCreateBitmapFromHICON Lib "gdiplus.dll" (TODO) As TODO msvcrt50: memcpy public static Bitmap Clone(Bitmap src)
// lock source bitmap data
BitmapData srcData = src.LockBits(
Bitmap dst = new Bitmap(width, height, src.PixelFormat);
// lock destination bitmap data
BitmapData dstData = dst.LockBits( Structures51: BITMAP
public struct BITMAPINFOHEADER
public BitmapCompressionMode biCompression;
Public Structure BITMAPINFOHEADER
Public biCompression As BitmapCompressionMode 52: BITMAPFILEHEADER
53: BITMAPINFO
public struct BITMAPINFOHEADER
public BitmapCompressionMode biCompression;
Public Structure BITMAPINFOHEADER
Public biCompression As BitmapCompressionMode 54: BITMAPINFOHEADER The BITMAPINFOHEADER contains information about the color space and dimensions of a DIB.
public struct BITMAPINFOHEADER
public BitmapCompressionMode biCompression;
Public Structure BITMAPINFOHEADER
Public biCompression As BitmapCompressionMode 55: FORMATETC
// The storage medium is a Graphics Device Interface (GDI) component (HBITMAP).
// the bitmap.
// the bitmap.
// the bitmap.
' The storage medium is a Graphics Device Interface (GDI) component (HBITMAP).
' the bitmap.
' the bitmap.
' the bitmap. 56: ICONINFO
/// The icon bitmask bitmap
/// A handle to the icon color bitmap.
''' The icon bitmask bitmap.
''' A handle to the icon color bitmap.
public int xBitmap;
public int yBitmap;
Public xBitmap As Integer
Public yBitmap As Integer kernel3258: DeviceIoControl
FsctlGetVolumeBitmap = (EFileDevice.FileSystem << 16) | (27 << 2) | EMethod.Neither | (0 << 14),
BITMAP = 2,
BITMAP = 2
private const uint RT_BITMAP = 0x00000002; 60: MoveMemory Public Function ConvertRBGTo1bpp(ByVal pSrcImg As Image) As Bitmap
Dim bitmap As Bitmap = New Bitmap(Width, Height, PixelFormat.Format1bppIndexed)
Dim BmpCopy As Bitmap = New Bitmap(Width, Height, PixelFormat.Format32bppArgb)
Dim bitmapData As BitmapData
bitmapData = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format1bppIndexed)
Dim pixels As IntPtr = bitmapData.Scan0
If (bitmapData.Stride > 0) Then
pBits = pixels.ToInt32() + bitmapData.Stride * (Height - 1)
Dim stride As Integer = Math.Abs(bitmapData.Stride)
bitmap.UnlockBits(bitmapData)
Return bitmap Cut off search results after 60. Please refine your search. |