public static Standard.SafeDC CreateCompatibleDC(Standard.SafeDC hdc) { Standard.SafeDC edc = null; try { IntPtr zero = IntPtr.Zero; if (hdc != null) { zero = hdc.handle; } edc = NativeMethods.CreateCompatibleDC(zero); if (edc == null) { Standard.HRESULT.ThrowLastError(); } } finally { if (edc != null) { edc._created = true; } } if (edc.IsInvalid) { edc.Dispose(); throw new SystemException("Unable to create a device context from the specified device information."); } return(edc); }
public static void UpdateLayeredWindow(IntPtr hwnd, Standard.SafeDC hdcDst, ref Standard.POINT pptDst, ref Standard.SIZE psize, Standard.SafeDC hdcSrc, ref Standard.POINT pptSrc, int crKey, ref Standard.BLENDFUNCTION pblend, Standard.ULW dwFlags) { if (!_UpdateLayeredWindow(hwnd, hdcDst, ref pptDst, ref psize, hdcSrc, ref pptSrc, crKey, ref pblend, dwFlags)) { Standard.HRESULT.ThrowLastError(); } }
public static IntPtr SelectObject(Standard.SafeDC hdc, IntPtr hgdiobj) { IntPtr ptr = _SelectObject(hdc, hgdiobj); if (ptr == IntPtr.Zero) { Standard.HRESULT.ThrowLastError(); } return(ptr); }
private static int _GetBitDepth() { if (s_bitDepth == 0) { using (Standard.SafeDC edc = Standard.SafeDC.GetDesktop()) { s_bitDepth = Standard.NativeMethods.GetDeviceCaps(edc, Standard.DeviceCap.BITSPIXEL) * Standard.NativeMethods.GetDeviceCaps(edc, Standard.DeviceCap.PLANES); } } return(s_bitDepth); }
static DpiHelper() { using (Standard.SafeDC edc = Standard.SafeDC.GetDesktop()) { int deviceCaps = Standard.NativeMethods.GetDeviceCaps(edc, Standard.DeviceCap.LOGPIXELSX); int num2 = Standard.NativeMethods.GetDeviceCaps(edc, Standard.DeviceCap.LOGPIXELSY); _transformToDip = Matrix.Identity; _transformToDip.Scale(96.0 / ((double)deviceCaps), 96.0 / ((double)num2)); _transformToDevice = Matrix.Identity; _transformToDevice.Scale(((double)deviceCaps) / 96.0, ((double)num2) / 96.0); } }
public static Standard.SafeHBITMAP CreateDIBSection(Standard.SafeDC hdc, ref Standard.BITMAPINFO bitmapInfo, out IntPtr ppvBits, IntPtr hSection, int dwOffset) { Standard.SafeHBITMAP ehbitmap = null; if (hdc == null) { ehbitmap = _CreateDIBSectionIntPtr(IntPtr.Zero, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset); } else { ehbitmap = _CreateDIBSection(hdc, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset); } if (ehbitmap.IsInvalid) { Standard.HRESULT.ThrowLastError(); } return(ehbitmap); }
public static Standard.SafeDC GetDC(IntPtr hwnd) { Standard.SafeDC dC = null; try { dC = NativeMethods.GetDC(hwnd); } finally { if (dC != null) { dC.Hwnd = hwnd; } } if (dC.IsInvalid) { Standard.HRESULT.E_FAIL.ThrowIfFailed(); } return(dC); }
public static Standard.SafeDC CreateDC(string deviceName) { Standard.SafeDC edc = null; try { edc = NativeMethods.CreateDC(deviceName, null, IntPtr.Zero, IntPtr.Zero); } finally { if (edc != null) { edc._created = true; } } if (edc.IsInvalid) { edc.Dispose(); throw new SystemException("Unable to create a device context from the specified device information."); } return(edc); }
public static extern int GetDeviceCaps(Standard.SafeDC hdc, Standard.DeviceCap nIndex);
private static extern Standard.SafeHBITMAP _CreateDIBSection(Standard.SafeDC hdc, [In] ref Standard.BITMAPINFO bitmapInfo, int iUsage, out IntPtr ppvBits, IntPtr hSection, int dwOffset);
private static extern bool _UpdateLayeredWindow(IntPtr hwnd, Standard.SafeDC hdcDst, [In] ref Standard.POINT pptDst, [In] ref Standard.SIZE psize, Standard.SafeDC hdcSrc, [In] ref Standard.POINT pptSrc, int crKey, ref Standard.BLENDFUNCTION pblend, Standard.ULW dwFlags);
private static extern IntPtr _SelectObjectSafeHBITMAP(Standard.SafeDC hdc, Standard.SafeHBITMAP hgdiobj);
private static extern IntPtr _SelectObject(Standard.SafeDC hdc, IntPtr hgdiobj);