public static HBITMAP CreateDIBSectionChecked ( HDC hdc, BITMAPINFO pbmi, out IntPtr ppvBits ) { HBITMAP res = CreateDIBSection(hdc, ref pbmi, 0, out ppvBits, IntPtr.Zero, 0); if (res == IntPtr.Zero) { throw new InvalidOperationException($"{nameof(CreateDIBSection)} failed. Width: {pbmi.bmiHeader.biWidth}, Height: {pbmi.bmiHeader.biHeight}."); } return(res); }
/// <summary>Initializes a new instance of the <see cref="CREDUI_INFO"/> struct.</summary> /// <param name="hwndOwner">Specifies the handle to the parent window of the dialog box.</param> /// <param name="caption">The string containing the title for the dialog box.</param> /// <param name="message">The string containing a brief message to display in the dialog box.</param> public CREDUI_INFO(HWND hwndOwner, string caption, string message) { cbSize = Marshal.SizeOf(typeof(CREDUI_INFO)); hwndParent = hwndOwner; if (caption?.Length > CREDUI_MAX_CAPTION_LENGTH) { throw new ArgumentOutOfRangeException(nameof(caption), $"The caption may not be longer than {CREDUI_MAX_CAPTION_LENGTH}."); } pszCaptionText = caption ?? string.Empty; if (message?.Length > CREDUI_MAX_MESSAGE_LENGTH) { throw new ArgumentOutOfRangeException(nameof(message), $"The message may not be longer than {CREDUI_MAX_MESSAGE_LENGTH}."); } pszMessageText = message; hbmBanner = HBITMAP.NULL; }
public static extern int GetObject(HBITMAP hbmp, int cb, ref BITMAP bm);
public static extern HBRUSH CreatePatternBrush(HBITMAP hbmp);
public static extern GpStatus GdipCreateHBITMAPFromBitmap(GpBitmap bitmap, out HBITMAP hbmReturn, int background);
GdipCreateHBITMAPFromBitmap(GpBitmap bitmap, out HBITMAP hbmReturn, int background);
public GpStatus GetHBITMAP( Color colorBackground, out HBITMAP hbmReturn ) { return SetStatus(NativeMethods.GdipCreateHBITMAPFromBitmap( (GpBitmap)(IntPtr)nativeImage, out hbmReturn, colorBackground.ToArgb())); }
public BitmapPlus FromHBITMAP( HBITMAP hbm, IntPtr hpal ) { return new BitmapPlus(hbm, hpal); }
/* public Bitmap( BITMAPINFO* gdiBitmapInfo, VOID* gdiBitmapData ) { GpBitmap bitmap = new GpBitmap(); lastResult = NativeMethods.GdipCreateBitmapFromGdiDib(gdiBitmapInfo, gdiBitmapData, out bitmap); SetNativeImage((GpImage)(IntPtr)bitmap); } */ public BitmapPlus( HBITMAP hbm, IntPtr hpal ) { GpBitmap bitmap = new GpBitmap(); lastResult = NativeMethods.GdipCreateBitmapFromHBITMAP(hbm, hpal, out bitmap); SetNativeImage((GpImage)(IntPtr)bitmap); }
public static extern int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, IntPtr lpvBits, ref BITMAPINFO lpbi, DIBColorMode uUsage);
public HRESULT GetThumbnail(uint cx, out HBITMAP phbmp, out WTS_ALPHATYPE pdwAlpha) { // Retrieve thumbnails of the placeholders on demand by delegating to the thumbnail of the source items. try { using var thumbnailProviderSource = ComReleaserFactory.Create(_itemSrc.BindToHandler <IThumbnailProvider>(default, BHID.BHID_ThumbnailHandler.Guid()));
public HRESULT SetBitmap(HBITMAP hBitmap) { return(((delegate * unmanaged <IBanneredBar *, HBITMAP, int>)(lpVtbl[5]))((IBanneredBar *)Unsafe.AsPointer(ref this), hBitmap)); }
public HRESULT Replace2(int i, HBITMAP hbmImage, HBITMAP hbmMask, IUnknown *punk, [NativeTypeName("DWORD")] uint dwFlags) { return(((delegate * unmanaged <IImageList2 *, int, HBITMAP, HBITMAP, IUnknown *, uint, int>)(lpVtbl[42]))((IImageList2 *)Unsafe.AsPointer(ref this), i, hbmImage, hbmMask, punk, dwFlags)); }
private unsafe Bitmap GetCaptureBitmap(HWND hWnd) { Bitmap bitmap = null; HWND zero = new HWND(0); HDC desktopDC = new HDC(IntPtr.Zero); HDC memoryDC = new HDC(IntPtr.Zero); try { var result = PInvoke.GetClientRect(hWnd, out RECT rect); if (!result) { throw new NullReferenceException($"指定したハンドルのウィンドウ({hWnd})を発見することができませんでした。"); } POINT point = new POINT(); var mapResult = PInvoke.MapWindowPoints(hWnd, zero, &point, 2); if (mapResult == 0) { throw new NullReferenceException($"指定したハンドルのウィンドウ({hWnd})の座標空間の変換に失敗しました。"); } rect.left = point.x; rect.top = point.y; rect.right = rect.right + point.x; rect.bottom = rect.bottom + point.y; var tempRect = rect; desktopDC = PInvoke.GetWindowDC(zero); // デスクトップの HDC を取得 var header = new BITMAPINFOHEADER() { biSize = (uint)Marshal.SizeOf(typeof(BITMAPINFOHEADER)), biWidth = tempRect.right - rect.left, biHeight = tempRect.bottom - rect.top, biPlanes = 1, biCompression = 0, // BitmapCompressionMode.BI_RGB = 0 biBitCount = 24, }; var info = new BITMAPINFO { bmiHeader = header, }; void **bits = null; HBITMAP hBitmap = PInvoke.CreateDIBSection(desktopDC, &info, DIB_USAGE.DIB_RGB_COLORS, bits, new HANDLE(IntPtr.Zero), 0); memoryDC = PInvoke.CreateCompatibleDC(desktopDC); var phBitMap = PInvoke.SelectObject(memoryDC, new HGDIOBJ(hBitmap)); PInvoke.BitBlt(memoryDC, 0, 0, header.biWidth, header.biHeight, desktopDC, rect.left, rect.top, ROP_CODE.SRCCOPY); PInvoke.SelectObject(memoryDC, phBitMap); bitmap = Bitmap.FromHbitmap(hBitmap, IntPtr.Zero); } finally { if (desktopDC.Value != IntPtr.Zero) { PInvoke.ReleaseDC(zero, desktopDC); } if (memoryDC.Value != IntPtr.Zero) { PInvoke.ReleaseDC(hWnd, memoryDC); } } return(bitmap); }