private static void Finalize( uint pdwNumberOfPhysicalMonitors, NativeStructures.PHYSICAL_MONITOR[] pPhysicalMonitorArray) { var destroyPhysicalMonitors = NativeMethods.DestroyPhysicalMonitors( pdwNumberOfPhysicalMonitors, pPhysicalMonitorArray); if (!destroyPhysicalMonitors) throw new Win32Exception(Marshal.GetLastWin32Error()); }
private unsafe static void TestStructureSizes(List <string> errors, Dictionary <string, int> nativeData) { Dictionary <string, int> managedData = NativeStructures.ToDictionary(x => x.Name, x => Marshal.SizeOf(x)); var difference = nativeData.Keys.Except(managedData.Keys); if (difference.Any()) { errors.Add("Structure lists are different: " + string.Join(", ", difference) + "."); return; } foreach (string key in nativeData.Keys) { int nativeSize = nativeData[key]; int managedSize = managedData[key]; if (nativeSize != managedSize) { errors.Add("Structure " + key + " declarations are different. Expected size is " + nativeSize.ToString(CultureInfo.InvariantCulture) + " actual size is " + managedSize.ToString(CultureInfo.InvariantCulture) + "."); } } }
private static uint GetMonitorHandleMinMaxCurBirghtness( out NativeStructures.PHYSICAL_MONITOR[] pPhysicalMonitorArray, out uint pdwMinimumBrightness, out uint pdwCurrentBrightness, out uint pdwMaximumBrightness) { var hMonitor = NativeMethods.MonitorFromWindow( NativeMethods.GetDesktopWindow(), NativeConstants.MONITOR_DEFAULTTOPRIMARY); var pdwNumberOfPhysicalMonitors = 0u; var numberOfPhysicalMonitorsFromHmonitor = NativeMethods.GetNumberOfPhysicalMonitorsFromHMONITOR( hMonitor, ref pdwNumberOfPhysicalMonitors); if (!numberOfPhysicalMonitorsFromHmonitor) throw new Win32Exception(Marshal.GetLastWin32Error()); pPhysicalMonitorArray = new NativeStructures.PHYSICAL_MONITOR[pdwNumberOfPhysicalMonitors]; var physicalMonitorsFromHmonitor = NativeMethods.GetPhysicalMonitorsFromHMONITOR( hMonitor, pdwNumberOfPhysicalMonitors, pPhysicalMonitorArray); if (!physicalMonitorsFromHmonitor) throw new Win32Exception(Marshal.GetLastWin32Error()); pdwMinimumBrightness = 0u; pdwCurrentBrightness = 0u; pdwMaximumBrightness = 0u; var getMonitorBrightness = NativeMethods.GetMonitorBrightness( pPhysicalMonitorArray[0].hPhysicalMonitor, ref pdwMinimumBrightness, ref pdwCurrentBrightness, ref pdwMaximumBrightness); if (!getMonitorBrightness) throw new Win32Exception(Marshal.GetLastWin32Error()); return pdwNumberOfPhysicalMonitors; }
internal static IReadOnlyCollection <string> GetManagedStructureNames() { return(NativeStructures.Select(x => x.Name).ToList()); }
public static extern bool GetMonitorTechnologyType( IntPtr hMonitor, ref NativeStructures.MC_DISPLAY_TECHNOLOGY_TYPE pdtyDisplayTechnologyType);
public static extern bool GetMonitorInfo(IntPtr hmon, ref NativeStructures.MonitorInfoEx mi);
public static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref NativeStructures.DISPLAY_DEVICE lpDisplayDevice, uint dwFlags);
public Monitor(NativeStructures.PHYSICAL_MONITOR physicalMonitor) { HPhysicalMonitor = physicalMonitor.hPhysicalMonitor; Name = physicalMonitor.szPhysicalMonitorDescription; CheckCapabilities(); }
public static extern int ph_crosscorr(ref NativeStructures.Digest x, ref NativeStructures.Digest y, out double pcc, double threshold = 0.90);
public static extern int ph_image_digest(string file, double sigma, double gamma, out NativeStructures.Digest digest, int N = 180);
private double Similarity(ref NativeStructures.Digest digest1, ref NativeStructures.Digest digest2) { double result; NativeFunctions.ph_crosscorr(ref digest1, ref digest2, out result); return 1f - result; }
private bool Hash(String imagePath, out NativeStructures.Digest hash) { return NativeFunctions.ph_image_digest(imagePath, 1.0, 1.0, out hash) != -1; }
public RadialHash(NativeStructures.Digest digest) { this.Digest = digest; }