private static int _GetBitDepth() { if (s_bitDepth == 0) { using (SafeDC dc = SafeDC.GetDesktop()) { s_bitDepth = NativeMethods.GetDeviceCaps(dc, DeviceCap.BITSPIXEL) * NativeMethods.GetDeviceCaps(dc, DeviceCap.PLANES); } } return(s_bitDepth); }
static DpiHelper() { using (SafeDC desktop = SafeDC.GetDesktop()) { int deviceCaps = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX); int deviceCaps2 = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY); DpiHelper._transformToDip = Matrix.Identity; DpiHelper._transformToDip.Scale(96.0 / (double)deviceCaps, 96.0 / (double)deviceCaps2); DpiHelper._transformToDevice = Matrix.Identity; DpiHelper._transformToDevice.Scale((double)deviceCaps / 96.0, (double)deviceCaps2 / 96.0); } }
static DpiHelper() { Class6.yDnXvgqzyB5jw(); using (SafeDC desktop = SafeDC.GetDesktop()) { int deviceCaps = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX); int num = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY); DpiHelper._transformToDip = Matrix.Identity; DpiHelper._transformToDip.Scale(96 / (double)deviceCaps, 96 / (double)num); DpiHelper._transformToDevice = Matrix.Identity; DpiHelper._transformToDevice.Scale((double)deviceCaps / 96, (double)num / 96); } }
private static int _bitDepth; // = 0; private static int _GetBitDepth() { if (_bitDepth != 0) { return(_bitDepth); } using (var dc = SafeDC.GetDesktop()) { _bitDepth = NativeMethods.GetDeviceCaps(dc, DeviceCap.BITSPIXEL) * NativeMethods.GetDeviceCaps(dc, DeviceCap.PLANES); } return(_bitDepth); }
static DpiHelper() { using (var desktop = SafeDC.GetDesktop()) { // Can get these in the static constructor. They shouldn't vary window to window, // and changing the system DPI requires a restart. var pixelsPerInchX = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX); var pixelsPerInchY = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY); _transformToDip = Matrix.Identity; _transformToDip.Scale(96d / pixelsPerInchX, 96d / pixelsPerInchY); _transformToDevice = Matrix.Identity; _transformToDevice.Scale(pixelsPerInchX / 96d, pixelsPerInchY / 96d); } }
static DpiHelper() { // Getting the Desktop, so we shouldn't have to release this DC. // This could potentially throw if used in a service. IntPtr desktop = NativeMethods.GetDC(IntPtr.Zero); // Can get these in the static constructor. They shouldn't vary window to window, // and changing the system DPI requires a restart. int pixelsPerInchX = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX); int pixelsPerInchY = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY); _transformToDip = Matrix.Identity; _transformToDip.Scale(96d / (double)pixelsPerInchX, 96d / (double)pixelsPerInchY); _transformToDevice = Matrix.Identity; _transformToDevice.Scale((double)pixelsPerInchX / 96d, (double)pixelsPerInchY / 96d); }