├── .gitignore ├── LICENSE ├── LICENSE-THIRD-PARTY ├── README.md ├── novideo_srgb.sln └── novideo_srgb ├── AboutWindow.xaml ├── AboutWindow.xaml.cs ├── AdvancedViewModel.cs ├── AdvancedWindow.xaml ├── AdvancedWindow.xaml.cs ├── App.config ├── App.xaml ├── App.xaml.cs ├── Colorimetry.cs ├── DisplayConfigManager.cs ├── DoubleToneCurve.cs ├── GammaToneCurve.cs ├── ICCBinaryReader.cs ├── ICCMatrixProfile.cs ├── ICCProfileException.cs ├── LstarEOTF.cs ├── Lut16.cs ├── LutToneCurve.cs ├── MainViewModel.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Matrix.cs ├── MonitorData.cs ├── Novideo.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── RangeRule.cs ├── SrgbEOTF.cs ├── ToneCurve.cs ├── icon.ico ├── novideo_srgb.csproj └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Nuget personal access tokens and Credentials 210 | nuget.config 211 | 212 | # Microsoft Azure Build Output 213 | csx/ 214 | *.build.csdef 215 | 216 | # Microsoft Azure Emulator 217 | ecf/ 218 | rcf/ 219 | 220 | # Windows Store app package directories and files 221 | AppPackages/ 222 | BundleArtifacts/ 223 | Package.StoreAssociation.xml 224 | _pkginfo.txt 225 | *.appx 226 | *.appxbundle 227 | *.appxupload 228 | 229 | # Visual Studio cache files 230 | # files ending in .cache can be ignored 231 | *.[Cc]ache 232 | # but keep track of directories ending in .cache 233 | !?*.[Cc]ache/ 234 | 235 | # Others 236 | ClientBin/ 237 | ~$* 238 | *~ 239 | *.dbmdl 240 | *.dbproj.schemaview 241 | *.jfm 242 | *.pfx 243 | *.publishsettings 244 | orleans.codegen.cs 245 | 246 | # Including strong name files can present a security risk 247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 248 | #*.snk 249 | 250 | # Since there are multiple workflows, uncomment next line to ignore bower_components 251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 252 | #bower_components/ 253 | 254 | # RIA/Silverlight projects 255 | Generated_Code/ 256 | 257 | # Backup & report files from converting an old project file 258 | # to a newer Visual Studio version. Backup files are not needed, 259 | # because we have git ;-) 260 | _UpgradeReport_Files/ 261 | Backup*/ 262 | UpgradeLog*.XML 263 | UpgradeLog*.htm 264 | ServiceFabricBackup/ 265 | *.rptproj.bak 266 | 267 | # SQL Server files 268 | *.mdf 269 | *.ldf 270 | *.ndf 271 | 272 | # Business Intelligence projects 273 | *.rdl.data 274 | *.bim.layout 275 | *.bim_*.settings 276 | *.rptproj.rsuser 277 | *- [Bb]ackup.rdl 278 | *- [Bb]ackup ([0-9]).rdl 279 | *- [Bb]ackup ([0-9][0-9]).rdl 280 | 281 | # Microsoft Fakes 282 | FakesAssemblies/ 283 | 284 | # GhostDoc plugin setting file 285 | *.GhostDoc.xml 286 | 287 | # Node.js Tools for Visual Studio 288 | .ntvs_analysis.dat 289 | node_modules/ 290 | 291 | # Visual Studio 6 build log 292 | *.plg 293 | 294 | # Visual Studio 6 workspace options file 295 | *.opt 296 | 297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 298 | *.vbw 299 | 300 | # Visual Studio LightSwitch build output 301 | **/*.HTMLClient/GeneratedArtifacts 302 | **/*.DesktopClient/GeneratedArtifacts 303 | **/*.DesktopClient/ModelManifest.xml 304 | **/*.Server/GeneratedArtifacts 305 | **/*.Server/ModelManifest.xml 306 | _Pvt_Extensions 307 | 308 | # Paket dependency manager 309 | .paket/paket.exe 310 | paket-files/ 311 | 312 | # FAKE - F# Make 313 | .fake/ 314 | 315 | # CodeRush personal settings 316 | .cr/personal 317 | 318 | # Python Tools for Visual Studio (PTVS) 319 | __pycache__/ 320 | *.pyc 321 | 322 | # Cake - Uncomment if you are using it 323 | # tools/** 324 | # !tools/packages.config 325 | 326 | # Tabs Studio 327 | *.tss 328 | 329 | # Telerik's JustMock configuration file 330 | *.jmconfig 331 | 332 | # BizTalk build output 333 | *.btp.cs 334 | *.btm.cs 335 | *.odx.cs 336 | *.xsd.cs 337 | 338 | # OpenCover UI analysis results 339 | OpenCover/ 340 | 341 | # Azure Stream Analytics local run output 342 | ASALocalRun/ 343 | 344 | # MSBuild Binary and Structured Log 345 | *.binlog 346 | 347 | # NVidia Nsight GPU debugger configuration file 348 | *.nvuser 349 | 350 | # MFractors (Xamarin productivity tool) working folder 351 | .mfractor/ 352 | 353 | # Local History for Visual Studio 354 | .localhistory/ 355 | 356 | # BeatPulse healthcheck temp database 357 | healthchecksdb 358 | 359 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 360 | MigrationBackup/ 361 | 362 | # Ionide (cross platform F# VS Code tools) working folder 363 | .ionide/ 364 | 365 | # Fody - auto-generated XML schema 366 | FodyWeavers.xsd 367 | 368 | # VS Code files for those working on multiple tools 369 | .vscode/* 370 | !.vscode/settings.json 371 | !.vscode/tasks.json 372 | !.vscode/launch.json 373 | !.vscode/extensions.json 374 | *.code-workspace 375 | 376 | # Local History for Visual Studio Code 377 | .history/ 378 | 379 | # Windows Installer files from build outputs 380 | *.cab 381 | *.msi 382 | *.msix 383 | *.msm 384 | *.msp 385 | 386 | # JetBrains Rider 387 | .idea/ 388 | *.sln.iml 389 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /LICENSE-THIRD-PARTY: -------------------------------------------------------------------------------- 1 | NvAPIWrapper, EDIDParser and WindowsDisplayAPI 2 | https://github.com/falahati/NvAPIWrapper, https://github.com/falahati/EDIDParser and https://github.com/falahati/WindowsDisplayAPI 3 | Copyright (C) 2017-2020 Soroush Falahati 4 | 5 | GNU LESSER GENERAL PUBLIC LICENSE 6 | Version 3, 29 June 2007 7 | 8 | Copyright (C) 2007 Free Software Foundation, Inc. 9 | Everyone is permitted to copy and distribute verbatim copies 10 | of this license document, but changing it is not allowed. 11 | 12 | 13 | This version of the GNU Lesser General Public License incorporates 14 | the terms and conditions of version 3 of the GNU General Public 15 | License, supplemented by the additional permissions listed below. 16 | 17 | 0. Additional Definitions. 18 | 19 | As used herein, "this License" refers to version 3 of the GNU Lesser 20 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 21 | General Public License. 22 | 23 | "The Library" refers to a covered work governed by this License, 24 | other than an Application or a Combined Work as defined below. 25 | 26 | An "Application" is any work that makes use of an interface provided 27 | by the Library, but which is not otherwise based on the Library. 28 | Defining a subclass of a class defined by the Library is deemed a mode 29 | of using an interface provided by the Library. 30 | 31 | A "Combined Work" is a work produced by combining or linking an 32 | Application with the Library. The particular version of the Library 33 | with which the Combined Work was made is also called the "Linked 34 | Version". 35 | 36 | The "Minimal Corresponding Source" for a Combined Work means the 37 | Corresponding Source for the Combined Work, excluding any source code 38 | for portions of the Combined Work that, considered in isolation, are 39 | based on the Application, and not on the Linked Version. 40 | 41 | The "Corresponding Application Code" for a Combined Work means the 42 | object code and/or source code for the Application, including any data 43 | and utility programs needed for reproducing the Combined Work from the 44 | Application, but excluding the System Libraries of the Combined Work. 45 | 46 | 1. Exception to Section 3 of the GNU GPL. 47 | 48 | You may convey a covered work under sections 3 and 4 of this License 49 | without being bound by section 3 of the GNU GPL. 50 | 51 | 2. Conveying Modified Versions. 52 | 53 | If you modify a copy of the Library, and, in your modifications, a 54 | facility refers to a function or data to be supplied by an Application 55 | that uses the facility (other than as an argument passed when the 56 | facility is invoked), then you may convey a copy of the modified 57 | version: 58 | 59 | a) under this License, provided that you make a good faith effort to 60 | ensure that, in the event an Application does not supply the 61 | function or data, the facility still operates, and performs 62 | whatever part of its purpose remains meaningful, or 63 | 64 | b) under the GNU GPL, with none of the additional permissions of 65 | this License applicable to that copy. 66 | 67 | 3. Object Code Incorporating Material from Library Header Files. 68 | 69 | The object code form of an Application may incorporate material from 70 | a header file that is part of the Library. You may convey such object 71 | code under terms of your choice, provided that, if the incorporated 72 | material is not limited to numerical parameters, data structure 73 | layouts and accessors, or small macros, inline functions and templates 74 | (ten or fewer lines in length), you do both of the following: 75 | 76 | a) Give prominent notice with each copy of the object code that the 77 | Library is used in it and that the Library and its use are 78 | covered by this License. 79 | 80 | b) Accompany the object code with a copy of the GNU GPL and this license 81 | document. 82 | 83 | 4. Combined Works. 84 | 85 | You may convey a Combined Work under terms of your choice that, 86 | taken together, effectively do not restrict modification of the 87 | portions of the Library contained in the Combined Work and reverse 88 | engineering for debugging such modifications, if you also do each of 89 | the following: 90 | 91 | a) Give prominent notice with each copy of the Combined Work that 92 | the Library is used in it and that the Library and its use are 93 | covered by this License. 94 | 95 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 96 | document. 97 | 98 | c) For a Combined Work that displays copyright notices during 99 | execution, include the copyright notice for the Library among 100 | these notices, as well as a reference directing the user to the 101 | copies of the GNU GPL and this license document. 102 | 103 | d) Do one of the following: 104 | 105 | 0) Convey the Minimal Corresponding Source under the terms of this 106 | License, and the Corresponding Application Code in a form 107 | suitable for, and under terms that permit, the user to 108 | recombine or relink the Application with a modified version of 109 | the Linked Version to produce a modified Combined Work, in the 110 | manner specified by section 6 of the GNU GPL for conveying 111 | Corresponding Source. 112 | 113 | 1) Use a suitable shared library mechanism for linking with the 114 | Library. A suitable mechanism is one that (a) uses at run time 115 | a copy of the Library already present on the user's computer 116 | system, and (b) will operate properly with a modified version 117 | of the Library that is interface-compatible with the Linked 118 | Version. 119 | 120 | e) Provide Installation Information, but only if you would otherwise 121 | be required to provide such information under section 6 of the 122 | GNU GPL, and only to the extent that such information is 123 | necessary to install and execute a modified version of the 124 | Combined Work produced by recombining or relinking the 125 | Application with a modified version of the Linked Version. (If 126 | you use option 4d0, the Installation Information must accompany 127 | the Minimal Corresponding Source and Corresponding Application 128 | Code. If you use option 4d1, you must provide the Installation 129 | Information in the manner specified by section 6 of the GNU GPL 130 | for conveying Corresponding Source.) 131 | 132 | 5. Combined Libraries. 133 | 134 | You may place library facilities that are a work based on the 135 | Library side by side in a single library together with other library 136 | facilities that are not Applications and are not covered by this 137 | License, and convey such a combined library under terms of your 138 | choice, if you do both of the following: 139 | 140 | a) Accompany the combined library with a copy of the same work based 141 | on the Library, uncombined with any other library facilities, 142 | conveyed under the terms of this License. 143 | 144 | b) Give prominent notice with the combined library that part of it 145 | is a work based on the Library, and explaining where to find the 146 | accompanying uncombined form of the same work. 147 | 148 | 6. Revised Versions of the GNU Lesser General Public License. 149 | 150 | The Free Software Foundation may publish revised and/or new versions 151 | of the GNU Lesser General Public License from time to time. Such new 152 | versions will be similar in spirit to the present version, but may 153 | differ in detail to address new problems or concerns. 154 | 155 | Each version is given a distinguishing version number. If the 156 | Library as you received it specifies that a certain numbered version 157 | of the GNU Lesser General Public License "or any later version" 158 | applies to it, you have the option of following the terms and 159 | conditions either of that published version or of any later version 160 | published by the Free Software Foundation. If the Library as you 161 | received it does not specify a version number of the GNU Lesser 162 | General Public License, you may choose any version of the GNU Lesser 163 | General Public License ever published by the Free Software Foundation. 164 | 165 | If the Library as you received it specifies that a proxy can decide 166 | whether future versions of the GNU Lesser General Public License shall 167 | apply, that proxy's public statement of acceptance of any version is 168 | permanent authorization for you to choose that version for the 169 | Library. 170 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## [Download latest release](https://github.com/ledoge/novideo_srgb/releases/latest/download/release.zip) 2 | 3 | # About 4 | This tool uses an undocumented NVIDIA API, supported on Fermi and later, to convert colors before sending them to a wide gamut monitor to effectively clamp it to sRGB (alternatively: Display P3, Adobe RGB or BT.2020), based on the chromaticities provided in its EDID. AMD supports this as a hidden setting in their drivers, but NVIDIA doesn't because ???. 5 | 6 | ICC profiles are also supported and can be used in two different ways. By default, only the primary coordinates from the ICC profile will be used in place of the values reported in the EDID. This is useful if you want to use a profile created by someone else without taking their gamma/grayscale balance data into account, as that can vary a lot between units. If you enable the `Calibrate gamma to` checkbox, a full LUT-Matrix-LUT calibration will be applied. This is similar to the hardware calibration supported by some monitors and can be used to achieve great color and grayscale accuracy on well-behaved displays. 7 | 8 | # Usage 9 | Extract `release.zip` somewhere under your user directory and run `novideo_srgb.exe`. To enable/disable the sRGB clamp for a monitor, simply toggle the "Clamped" checkbox. For using ICC profiles and configuring dithering, click the "Advanced" button. 10 | 11 | Generally, the clamp should persist through reboots and driver updates, but it can break sometimes. You can choose to leave the application running minimized in the background to have it automatically reapply the clamp and also handle HDR toggling – see the section "HDR and automatic reapplying" below. 12 | 13 | # Notes for use with EDID data 14 | * If the checkbox for a monitor is locked, it means that the EDID is reporting the sRGB primaries as the monitor's primaries, so the monitor is either natively sRGB or uses an sRGB emulation mode by default. If this is not the case, complain to the manufacturer about the EDID being wrong, and try to find an ICC profile for your monitor to use instead of the EDID data. 15 | 16 | * The reported white point is not taken into account when calculating the color space conversion matrix. Instead, the monitor is always assumed to be calibrated to D65 white. 17 | 18 | # Notes for use with ICC profiles 19 | 20 | * For the gamma options to work properly, the profile must report the display's black point accurately. DisplayCAL's default settings, e.g. with the sRGB preset, work fine. 21 | * Since the color space conversion is done on the GPU side, the ICC profile must not be selected/loaded in Windows or any other application. If you want, you can do another profiling run on top of the active calibration and then use this profile in applications that support color management to achieve even better color accuracy. 22 | * To achieve optimal results, consider creating a custom testchart in DisplayCAL with a high number of neutral (grayscale) patches, such as 256. With that, a grayscale calibration (setting "Tone curve" to anything other than "As measured") should be unnecessary unless your display lacks RGB gain controls, but can lead to better accuracy on some poorly behaved displays. The number of colored patches should not matter much. Additionally, configuring DisplayCAL to generate a "Curves + matrix" profile with "Black point compensation" disabled should also result in a lower average error than using an XYZ LUT profile. Having dithering enabled during profiling also seems to have a positive impact, see [here](https://github.com/ledoge/novideo_srgb/issues/79#issuecomment-1817220136). This advice is based on what worked well for a handful of users, so if you have anything else to add, please let me know. 23 | * The option "Disable 8-bit color optimization" can be used to get better color accuracy in true 10-bit workflows at the cost of 8-bit accuracy. Only enable this if you really know you're working with 10-bit color. 24 | * Only the VCGT (if present), TRC and PCS matrix parts of an ICC profile are used. If present, the A2B1 data is used to calculate (hopefully) higher quality TRC and PCS matrix values. 25 | 26 | # HDR and automatic reapplying 27 | 28 | Any change in the display setup (such as a monitor being added/removed) will cause the clamp to be reapplied on all monitors, as long as the application is running in the background. The main purpose of this is to handle HDR being toggled in Windows, as the clamp will automatically be disabled for monitors for which HDR is enabled (since colors would get messed up otherwise). Additionally, you can use the "Reapply" button to manually reapply the clamp in case something breaks (e.g. due to a driver bug). 29 | 30 | Minimizing the GUI will hide it from the taskbar, so that it'll only be visible in the tray. If you want to run it on boot, you can enable the "Run at startup" checkbox, which will use the `-minimize` command line argument to make it start minimized. 31 | 32 | # Known issues 33 | 34 | * Since version 531.79, the NVIDIA driver rejects any attempt to set a color space conversion while HDR is enabled with error -104 (`NVAPI_NOT_SUPPORTED`). This means that the HDR handling mentioned above does not work anymore. I don't know whether this is a driver bug or an intentional change, but I don't think I can do anything to fix it. 35 | 36 | * The color space transform does not get applied properly to the mouse cursor, which results in it having wrong gamma and colors. This should be hardly noticeable with the default Windows cursor. Workaround: Force software rendering of the cursor, e.g. using [SoftCursor](https://www.monitortests.com/forum/Thread-SoftCursor). 37 | 38 | * Windows HDR is handled properly, but NVAPI HDR, which some applications use to output HDR even though Windows HDR is off, will result in wrong colors while the clamp is active. To work around this, you can either enable Windows HDR or disable the clamp manually before launching such applications. 39 | 40 | # Dithering 41 | 42 | Applying any kind of calibration on the GPU-level usually results in banding unless dithering is used. By default, NVIDIA GPUs do not apply dithering to full range RGB output. Therefore, it is recommended that you use the dither controls to enable and configure dithering. "Bits" should be set to match the bit depth of your GPU output, and "Mode" can be set to whatever looks best to you. Note that "Temporal" works by rapidly switching between colors, which some people's eyes are sensitive to. 43 | -------------------------------------------------------------------------------- /novideo_srgb.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31205.134 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "novideo_srgb", "novideo_srgb\novideo_srgb.csproj", "{A6A97834-7BE1-474A-B92F-A512DB1D5186}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A6A97834-7BE1-474A-B92F-A512DB1D5186}.Debug|x64.ActiveCfg = Debug|x64 15 | {A6A97834-7BE1-474A-B92F-A512DB1D5186}.Debug|x64.Build.0 = Debug|x64 16 | {A6A97834-7BE1-474A-B92F-A512DB1D5186}.Release|x64.ActiveCfg = Release|x64 17 | {A6A97834-7BE1-474A-B92F-A512DB1D5186}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {537994B5-851A-439F-89CE-A61A10A74CF9} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /novideo_srgb/AboutWindow.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | novideo_srgb v4.2 by ledoge 15 | 16 | 17 | Licensed under GPLv3 18 | Source code and releases hosted at 19 | https://github.com/ledoge/novideo_srgb 20 | 21 | 22 | -------------------------------------------------------------------------------- /novideo_srgb/AboutWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Navigation; 3 | 4 | namespace novideo_srgb 5 | { 6 | public partial class AboutWindow : Window 7 | { 8 | public AboutWindow() 9 | { 10 | InitializeComponent(); 11 | } 12 | 13 | private void OnRequestNavigate(object sender, RequestNavigateEventArgs e) 14 | { 15 | var processStartInfo = new System.Diagnostics.ProcessStartInfo(e.Uri.AbsoluteUri) 16 | { 17 | UseShellExecute = true, 18 | }; 19 | System.Diagnostics.Process.Start(processStartInfo); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /novideo_srgb/AdvancedViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.IO; 4 | using System.Runtime.CompilerServices; 5 | using System.Windows; 6 | using EDIDParser; 7 | 8 | namespace novideo_srgb 9 | { 10 | public class AdvancedViewModel : INotifyPropertyChanged 11 | { 12 | public event PropertyChangedEventHandler PropertyChanged; 13 | 14 | private MonitorData _monitor; 15 | 16 | private int _target; 17 | private bool _useIcc; 18 | private string _profilePath; 19 | private bool _calibrateGamma; 20 | private int _selectedGamma; 21 | private double _customGamma; 22 | private double _customPercentage; 23 | private bool _disableOptimization; 24 | 25 | private int _ditherState; 26 | private int _ditherMode; 27 | private int _ditherBits; 28 | 29 | public AdvancedViewModel() 30 | { 31 | throw new NotSupportedException(); 32 | } 33 | 34 | public AdvancedViewModel(MonitorData monitor, Novideo.DitherControl dither) 35 | { 36 | _monitor = monitor; 37 | 38 | _target = monitor.Target; 39 | _useIcc = monitor.UseIcc; 40 | _profilePath = monitor.ProfilePath; 41 | _calibrateGamma = monitor.CalibrateGamma; 42 | _selectedGamma = monitor.SelectedGamma; 43 | _customGamma = monitor.CustomGamma; 44 | _customPercentage = monitor.CustomPercentage; 45 | _disableOptimization = monitor.DisableOptimization; 46 | 47 | _ditherBits = dither.bits; 48 | _ditherMode = dither.mode; 49 | _ditherState = dither.state; 50 | } 51 | 52 | public void ApplyChanges() 53 | { 54 | ChangedCalibration |= _monitor.Target != _target; 55 | _monitor.Target = _target; 56 | ChangedCalibration |= _monitor.UseIcc != _useIcc; 57 | _monitor.UseIcc = _useIcc; 58 | ChangedCalibration |= _monitor.ProfilePath != _profilePath; 59 | _monitor.ProfilePath = _profilePath; 60 | ChangedCalibration |= _monitor.CalibrateGamma != _calibrateGamma; 61 | _monitor.CalibrateGamma = _calibrateGamma; 62 | ChangedCalibration |= _monitor.SelectedGamma != _selectedGamma; 63 | _monitor.SelectedGamma = _selectedGamma; 64 | ChangedCalibration |= _monitor.CustomGamma != _customGamma; 65 | _monitor.CustomGamma = _customGamma; 66 | ChangedCalibration |= _monitor.CustomPercentage != _customPercentage; 67 | _monitor.CustomPercentage = _customPercentage; 68 | ChangedCalibration |= _monitor.DisableOptimization != _disableOptimization; 69 | _monitor.DisableOptimization = _disableOptimization; 70 | } 71 | 72 | public ChromaticityCoordinates Coords => _monitor.Edid.DisplayParameters.ChromaticityCoordinates; 73 | 74 | public bool UseEdid 75 | { 76 | set 77 | { 78 | if (!value == _useIcc) return; 79 | _useIcc = !value; 80 | OnPropertyChanged(); 81 | OnPropertyChanged(nameof(UseIcc)); 82 | OnPropertyChanged(nameof(EdidWarning)); 83 | } 84 | get => !_useIcc; 85 | } 86 | 87 | public bool UseIcc 88 | { 89 | set 90 | { 91 | if (value == _useIcc) return; 92 | _useIcc = value; 93 | OnPropertyChanged(); 94 | OnPropertyChanged(nameof(UseEdid)); 95 | OnPropertyChanged(nameof(EdidWarning)); 96 | } 97 | get => _useIcc; 98 | } 99 | 100 | public string ProfilePath 101 | { 102 | set 103 | { 104 | if (value == _profilePath) return; 105 | _profilePath = value; 106 | OnPropertyChanged(); 107 | OnPropertyChanged(nameof(ProfileName)); 108 | } 109 | get => _profilePath; 110 | } 111 | 112 | public string ProfileName => Path.GetFileName(ProfilePath); 113 | 114 | public bool CalibrateGamma 115 | { 116 | set 117 | { 118 | if (value == _calibrateGamma) return; 119 | _calibrateGamma = value; 120 | OnPropertyChanged(); 121 | } 122 | get => _calibrateGamma; 123 | } 124 | 125 | public int SelectedGamma 126 | { 127 | set 128 | { 129 | if (value == _selectedGamma) return; 130 | _selectedGamma = value; 131 | OnPropertyChanged(); 132 | OnPropertyChanged(nameof(UseCustomGamma)); 133 | } 134 | get => _selectedGamma; 135 | } 136 | 137 | public Visibility UseCustomGamma => 138 | SelectedGamma == 2 || SelectedGamma == 3 ? Visibility.Visible : Visibility.Collapsed; 139 | 140 | public double CustomGamma 141 | { 142 | set 143 | { 144 | if (value == _customGamma) return; 145 | _customGamma = value; 146 | OnPropertyChanged(); 147 | } 148 | get => _customGamma; 149 | } 150 | 151 | public int Target 152 | { 153 | set 154 | { 155 | if (value == _target) return; 156 | _target = value; 157 | OnPropertyChanged(); 158 | OnPropertyChanged(nameof(EdidWarning)); 159 | } 160 | get => _target; 161 | } 162 | 163 | public Visibility HdrWarning => _monitor.HdrActive ? Visibility.Visible : Visibility.Collapsed; 164 | public Visibility EdidWarning => HdrWarning != Visibility.Visible && UseEdid && Colorimetry.ColorSpaces[_target].Equals(_monitor.EdidColorSpace) 165 | ? Visibility.Visible 166 | : Visibility.Collapsed; 167 | 168 | public double CustomPercentage 169 | { 170 | set 171 | { 172 | if (value == _customPercentage) return; 173 | _customPercentage = value; 174 | OnPropertyChanged(); 175 | } 176 | get => _customPercentage; 177 | } 178 | 179 | public bool DisableOptimization 180 | { 181 | set 182 | { 183 | if (value == _disableOptimization) return; 184 | _disableOptimization = value; 185 | OnPropertyChanged(); 186 | } 187 | get => _disableOptimization; 188 | } 189 | 190 | public bool ChangedCalibration { get; set; } 191 | 192 | public int DitherState 193 | { 194 | set 195 | { 196 | if (value == _ditherState) return; 197 | _ditherState = value; 198 | OnPropertyChanged(); 199 | OnPropertyChanged(nameof(CustomDither)); 200 | OnPropertyChanged(nameof(DitherMode)); 201 | OnPropertyChanged(nameof(DitherBits)); 202 | ChangedDither = true; 203 | } 204 | get => _ditherState; 205 | } 206 | 207 | public int DitherMode 208 | { 209 | set 210 | { 211 | if (value == _ditherMode) return; 212 | _ditherMode = value; 213 | OnPropertyChanged(); 214 | ChangedDither = true; 215 | } 216 | get => _ditherState == 0 ? -1 : _ditherMode; 217 | } 218 | 219 | public int DitherBits 220 | { 221 | set 222 | { 223 | if (value == _ditherBits) return; 224 | _ditherBits = value; 225 | OnPropertyChanged(); 226 | ChangedDither = true; 227 | } 228 | get => _ditherState == 0 ? -1 : _ditherBits; 229 | } 230 | 231 | public bool CustomDither => DitherState == 1; 232 | 233 | public bool ChangedDither { get; set; } 234 | 235 | private void OnPropertyChanged([CallerMemberName] string name = null) 236 | { 237 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); 238 | } 239 | } 240 | } -------------------------------------------------------------------------------- /novideo_srgb/AdvancedWindow.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | sRGB/BT.709 33 | Display P3 34 | Adobe RGB 35 | BT.2020 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 61 | 62 | 67 | 68 | 69 | 74 | 75 | 80 | 81 | 82 | 87 | 88 | 93 | 94 | 95 | Primaries match target – cannot clamp 96 | HDR is active – cannot clamp 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 109 | 202 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /novideo_srgb/AdvancedWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace novideo_srgb 5 | { 6 | public partial class AdvancedWindow 7 | { 8 | private AdvancedViewModel _viewModel; 9 | 10 | public AdvancedWindow(MonitorData monitor) 11 | { 12 | var dither = monitor.DitherControl; 13 | var bitDepth = monitor.BitDepth; 14 | if (bitDepth != 0 && dither.state == 0 && dither.mode == 0 && dither.bits == 0) 15 | { 16 | dither.mode = 4; 17 | dither.bits = bitDepth == 8 ? 1 : 2; 18 | } 19 | _viewModel = new AdvancedViewModel(monitor, dither); 20 | DataContext = _viewModel; 21 | InitializeComponent(); 22 | 23 | for (var i = 0; i < 5; i++) 24 | { 25 | ((ComboBoxItem)DitherMode.Items[i]).IsEnabled = ((dither.modeCaps >> i) & 1) == 1; 26 | } 27 | 28 | for (var i = 0; i < 3; i++) 29 | { 30 | ((ComboBoxItem)DitherBits.Items[i]).IsEnabled = ((dither.bitsCaps >> i) & 1) == 1; 31 | } 32 | } 33 | 34 | private static string BrowseProfiles() 35 | { 36 | var dlg = new Microsoft.Win32.OpenFileDialog 37 | { 38 | Filter = "ICC Profiles|*.icc;*.icm" 39 | }; 40 | 41 | var result = dlg.ShowDialog(); 42 | 43 | return result == true ? dlg.FileName : null; 44 | } 45 | 46 | private void Browse_Click(object sender, RoutedEventArgs e) 47 | { 48 | var profilePath = BrowseProfiles(); 49 | if (!string.IsNullOrEmpty(profilePath)) 50 | { 51 | _viewModel.ProfilePath = profilePath; 52 | } 53 | } 54 | 55 | private void OK_Click(object sender, RoutedEventArgs e) 56 | { 57 | _viewModel.ApplyChanges(); 58 | DialogResult = true; 59 | } 60 | 61 | public bool ChangedCalibration => _viewModel.ChangedCalibration; 62 | public bool ChangedDither => _viewModel.ChangedDither; 63 | } 64 | } -------------------------------------------------------------------------------- /novideo_srgb/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /novideo_srgb/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /novideo_srgb/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace novideo_srgb 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } -------------------------------------------------------------------------------- /novideo_srgb/Colorimetry.cs: -------------------------------------------------------------------------------- 1 | // credit to https://mina86.com/2019/srgb-xyz-matrix/ and http://www.brucelindbloom.com/ for the math 2 | 3 | namespace novideo_srgb 4 | { 5 | public static class Colorimetry 6 | { 7 | public struct Point 8 | { 9 | public bool Equals(Point other) 10 | { 11 | return X.Equals(other.X) && Y.Equals(other.Y); 12 | } 13 | 14 | public override bool Equals(object obj) 15 | { 16 | return obj is Point other && Equals(other); 17 | } 18 | 19 | public override int GetHashCode() 20 | { 21 | unchecked 22 | { 23 | return (X.GetHashCode() * 397) ^ Y.GetHashCode(); 24 | } 25 | } 26 | 27 | public double X; 28 | public double Y; 29 | } 30 | 31 | public struct ColorSpace 32 | { 33 | public bool Equals(ColorSpace other) 34 | { 35 | return Red.Equals(other.Red) && Green.Equals(other.Green) && Blue.Equals(other.Blue) && 36 | White.Equals(other.White); 37 | } 38 | 39 | public override bool Equals(object obj) 40 | { 41 | return obj is ColorSpace other && Equals(other); 42 | } 43 | 44 | public override int GetHashCode() 45 | { 46 | unchecked 47 | { 48 | var hashCode = Red.GetHashCode(); 49 | hashCode = (hashCode * 397) ^ Green.GetHashCode(); 50 | hashCode = (hashCode * 397) ^ Blue.GetHashCode(); 51 | hashCode = (hashCode * 397) ^ White.GetHashCode(); 52 | return hashCode; 53 | } 54 | } 55 | 56 | public Point Red; 57 | public Point Green; 58 | public Point Blue; 59 | public Point White; 60 | } 61 | 62 | public static Point D65 = new Point { X = 0.3127, Y = 0.3290 }; 63 | 64 | public static ColorSpace sRGB = new ColorSpace 65 | { 66 | Red = new Point { X = 0.64, Y = 0.33 }, 67 | Green = new Point { X = 0.3, Y = 0.6 }, 68 | Blue = new Point { X = 0.15, Y = 0.06 }, 69 | White = D65 70 | }; 71 | 72 | public static ColorSpace DisplayP3 = new ColorSpace 73 | { 74 | Red = new Point { X = 0.68, Y = 0.32 }, 75 | Green = new Point { X = 0.265, Y = 0.69 }, 76 | Blue = new Point { X = 0.15, Y = 0.06 }, 77 | White = D65 78 | }; 79 | 80 | public static ColorSpace AdobeRGB = new ColorSpace 81 | { 82 | Red = new Point { X = 0.64, Y = 0.33 }, 83 | Green = new Point { X = 0.21, Y = 0.71 }, 84 | Blue = new Point { X = 0.15, Y = 0.06 }, 85 | White = D65 86 | }; 87 | 88 | public static ColorSpace BT2020 = new ColorSpace 89 | { 90 | Red = new Point { X = 0.708, Y = 0.292 }, 91 | Green = new Point { X = 0.17, Y = 0.797 }, 92 | Blue = new Point { X = 0.131, Y = 0.046 }, 93 | White = D65 94 | }; 95 | 96 | public static ColorSpace[] ColorSpaces => new[] { sRGB, DisplayP3, AdobeRGB, BT2020 }; 97 | 98 | public static Matrix D50 = Matrix.FromValues(new[,] { { 0.9642 }, { 1 }, { 0.8249 } }); 99 | 100 | public static Matrix RGBToXYZ(ColorSpace colorSpace) 101 | { 102 | var red = colorSpace.Red; 103 | var green = colorSpace.Green; 104 | var blue = colorSpace.Blue; 105 | var white = colorSpace.White; 106 | var whiteXYZ = Matrix.FromValues(new[,] 107 | { { white.X / white.Y }, { 1 }, { (1 - white.X - white.Y) / white.Y } }); 108 | 109 | var Mprime = Matrix.FromValues(new[,] 110 | { 111 | { red.X / red.Y, green.X / green.Y, blue.X / blue.Y }, 112 | { 1, 1, 1 }, 113 | { (1 - red.X - red.Y) / red.Y, (1 - green.X - green.Y) / green.Y, (1 - blue.X - blue.Y) / blue.Y } 114 | }); 115 | 116 | return Mprime * Matrix.FromDiagonal(Mprime.Inverse() * whiteXYZ); 117 | } 118 | 119 | public static Matrix XYZToRGB(ColorSpace colorSpace) 120 | { 121 | return RGBToXYZ(colorSpace).Inverse(); 122 | } 123 | 124 | public static Matrix RGBToRGB(ColorSpace from, ColorSpace to) 125 | { 126 | var result = XYZToRGB(to) * RGBToXYZ(from); 127 | return result; 128 | } 129 | 130 | public static Matrix RGBToAdaptedXYZ(ColorSpace colorspace, Matrix whiteXYZ) 131 | { 132 | var xyz = RGBToXYZ(colorspace); 133 | var bradford = Matrix.FromValues(new[,] 134 | { 135 | { 0.8951, 0.2664, -0.1614 }, 136 | { -0.7502, 1.7135, 0.0367 }, 137 | { 0.0389, -0.0685, 1.0296 } 138 | }); 139 | var ws = colorspace.White; 140 | var aws = bradford * Matrix.FromValues(new[,] 141 | { 142 | { ws.X / ws.Y }, { 1 }, { (1 - ws.X - ws.Y) / ws.Y } 143 | }); 144 | var awd = bradford * whiteXYZ; 145 | var m = bradford.Inverse() * Matrix.FromDiagonal(new[] 146 | { awd[0] / aws[0], awd[1] / aws[1], awd[2] / aws[2] }) * bradford; 147 | return m * xyz; 148 | } 149 | 150 | public static Matrix RGBToPCSXYZ(ColorSpace colorspace) 151 | { 152 | return RGBToAdaptedXYZ(colorspace, D50); 153 | } 154 | 155 | public static Matrix PCSXYZToRGB(ColorSpace colorspace) 156 | { 157 | return RGBToPCSXYZ(colorspace).Inverse(); 158 | } 159 | 160 | public static Matrix XYZScale(Matrix matrix, Matrix target) 161 | { 162 | var result = Matrix.Zero3x3(); 163 | var white = matrix * Matrix.One3x1(); 164 | for (var i = 0; i < 3; i++) 165 | { 166 | for (var j = 0; j < 3; j++) 167 | { 168 | result[i, j] = matrix[i, j] * target[i] / white[i]; 169 | } 170 | } 171 | 172 | return result; 173 | } 174 | 175 | public static Matrix XYZScaleToD50(Matrix matrix) 176 | { 177 | return XYZScale(matrix, D50); 178 | } 179 | } 180 | } -------------------------------------------------------------------------------- /novideo_srgb/DisplayConfigManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace novideo_srgb 8 | { 9 | public static class DisplayConfigManager 10 | { 11 | [DllImport("user32")] 12 | private static extern int GetDisplayConfigBufferSizes(QDC flags, out int numPathArrayElements, out int numModeInfoArrayElements); 13 | 14 | [DllImport("user32")] 15 | private static extern int QueryDisplayConfig(QDC flags, ref int numPathArrayElements, [In, Out] DISPLAYCONFIG_PATH_INFO[] pathArray, ref int numModeInfoArrayElements, [In, Out] DISPLAYCONFIG_MODE_INFO[] modeInfoArray, out DISPLAYCONFIG_TOPOLOGY_ID currentTopologyId); 16 | 17 | [DllImport("user32")] 18 | private static extern int QueryDisplayConfig(QDC flags, ref int numPathArrayElements, [In, Out] DISPLAYCONFIG_PATH_INFO[] pathArray, ref int numModeInfoArrayElements, [In, Out] DISPLAYCONFIG_MODE_INFO[] modeInfoArray, IntPtr currentTopologyId); 19 | 20 | [DllImport("user32")] 21 | private static extern int DisplayConfigGetDeviceInfo(ref DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO requestPacket); 22 | 23 | [DllImport("user32")] 24 | private static extern int DisplayConfigGetDeviceInfo(ref DISPLAYCONFIG_SOURCE_DEVICE_NAME requestPacket); 25 | 26 | [DllImport("user32")] 27 | private static extern int DisplayConfigGetDeviceInfo(ref DISPLAYCONFIG_TARGET_DEVICE_NAME requestPacket); 28 | 29 | public static HashSet GetHdrDisplayPaths() 30 | { 31 | Action check = (e) => 32 | { 33 | if (e != 0) 34 | { 35 | throw new Win32Exception(e); 36 | } 37 | }; 38 | 39 | check(GetDisplayConfigBufferSizes(QDC.QDC_ONLY_ACTIVE_PATHS, out var pathCount, out var modeCount)); 40 | 41 | var paths = new DISPLAYCONFIG_PATH_INFO[pathCount]; 42 | var modes = new DISPLAYCONFIG_MODE_INFO[modeCount]; 43 | 44 | check(QueryDisplayConfig(QDC.QDC_ONLY_ACTIVE_PATHS, ref pathCount, paths, ref modeCount, modes, IntPtr.Zero)); 45 | 46 | var result = new HashSet(); 47 | 48 | Array.ForEach(paths, path => 49 | { 50 | var displayInfo = new DISPLAYCONFIG_TARGET_DEVICE_NAME(); 51 | displayInfo.header.type = DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; 52 | displayInfo.header.size = Marshal.SizeOf(); 53 | displayInfo.header.adapterId = path.targetInfo.adapterId; 54 | displayInfo.header.id = path.targetInfo.id; 55 | 56 | check(DisplayConfigGetDeviceInfo(ref displayInfo)); 57 | 58 | var colorInfo = new DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO(); 59 | colorInfo.header.type = DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO; 60 | colorInfo.header.size = Marshal.SizeOf(); 61 | colorInfo.header.adapterId = path.targetInfo.adapterId; 62 | colorInfo.header.id = path.targetInfo.id; 63 | 64 | check(DisplayConfigGetDeviceInfo(ref colorInfo)); 65 | 66 | if (colorInfo.advancedColorEnabled) 67 | { 68 | result.Add(displayInfo.monitorDevicePath); 69 | } 70 | }); 71 | 72 | return result; 73 | } 74 | } 75 | 76 | internal enum DISPLAYCONFIG_DEVICE_INFO_TYPE 77 | { 78 | DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1, 79 | DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2, 80 | DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3, 81 | DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME = 4, 82 | DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE = 5, 83 | DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE = 6, 84 | DISPLAYCONFIG_DEVICE_INFO_GET_SUPPORT_VIRTUAL_RESOLUTION = 7, 85 | DISPLAYCONFIG_DEVICE_INFO_SET_SUPPORT_VIRTUAL_RESOLUTION = 8, 86 | DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO = 9, 87 | DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE = 10, 88 | DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL = 11, 89 | } 90 | 91 | internal enum DISPLAYCONFIG_COLOR_ENCODING 92 | { 93 | DISPLAYCONFIG_COLOR_ENCODING_RGB = 0, 94 | DISPLAYCONFIG_COLOR_ENCODING_YCBCR444 = 1, 95 | DISPLAYCONFIG_COLOR_ENCODING_YCBCR422 = 2, 96 | DISPLAYCONFIG_COLOR_ENCODING_YCBCR420 = 3, 97 | DISPLAYCONFIG_COLOR_ENCODING_INTENSITY = 4, 98 | } 99 | 100 | internal enum DISPLAYCONFIG_SCALING 101 | { 102 | DISPLAYCONFIG_SCALING_IDENTITY = 1, 103 | DISPLAYCONFIG_SCALING_CENTERED = 2, 104 | DISPLAYCONFIG_SCALING_STRETCHED = 3, 105 | DISPLAYCONFIG_SCALING_ASPECTRATIOCENTEREDMAX = 4, 106 | DISPLAYCONFIG_SCALING_CUSTOM = 5, 107 | DISPLAYCONFIG_SCALING_PREFERRED = 128, 108 | } 109 | 110 | internal enum DISPLAYCONFIG_ROTATION 111 | { 112 | DISPLAYCONFIG_ROTATION_IDENTITY = 1, 113 | DISPLAYCONFIG_ROTATION_ROTATE90 = 2, 114 | DISPLAYCONFIG_ROTATION_ROTATE180 = 3, 115 | } 116 | 117 | internal enum DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY 118 | { 119 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER = -1, 120 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HD15 = 0, 121 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SVIDEO = 1, 122 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPOSITE_VIDEO = 2, 123 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPONENT_VIDEO = 3, 124 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DVI = 4, 125 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI = 5, 126 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_LVDS = 6, 127 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_D_JPN = 8, 128 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDI = 9, 129 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EXTERNAL = 10, 130 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED = 11, 131 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EXTERNAL = 12, 132 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED = 13, 133 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDTVDONGLE = 14, 134 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_MIRACAST = 15, 135 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INDIRECT_WIRED = 16, 136 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INDIRECT_VIRTUAL = 17, 137 | DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL = unchecked((int)0x80000000), 138 | } 139 | 140 | internal enum DISPLAYCONFIG_TOPOLOGY_ID 141 | { 142 | DISPLAYCONFIG_TOPOLOGY_INTERNAL = 0x00000001, 143 | DISPLAYCONFIG_TOPOLOGY_CLONE = 0x00000002, 144 | DISPLAYCONFIG_TOPOLOGY_EXTEND = 0x00000004, 145 | DISPLAYCONFIG_TOPOLOGY_EXTERNAL = 0x00000008, 146 | } 147 | 148 | internal enum DISPLAYCONFIG_PATH 149 | { 150 | DISPLAYCONFIG_PATH_ACTIVE = 0x00000001, 151 | DISPLAYCONFIG_PATH_PREFERRED_UNSCALED = 0x00000004, 152 | DISPLAYCONFIG_PATH_SUPPORT_VIRTUAL_MODE = 0x00000008, 153 | } 154 | 155 | internal enum DISPLAYCONFIG_SOURCE_FLAGS 156 | { 157 | DISPLAYCONFIG_SOURCE_IN_USE = 0x00000001, 158 | } 159 | 160 | internal enum DISPLAYCONFIG_TARGET_FLAGS 161 | { 162 | DISPLAYCONFIG_TARGET_IN_USE = 0x00000001, 163 | DISPLAYCONFIG_TARGET_FORCIBLE = 0x00000002, 164 | DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_BOOT = 0x00000004, 165 | DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_PATH = 0x00000008, 166 | DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_SYSTEM = 0x00000010, 167 | DISPLAYCONFIG_TARGET_IS_HMD = 0x00000020, 168 | } 169 | 170 | internal enum QDC 171 | { 172 | QDC_ALL_PATHS = 0x00000001, 173 | QDC_ONLY_ACTIVE_PATHS = 0x00000002, 174 | QDC_DATABASE_CURRENT = 0x00000004, 175 | QDC_VIRTUAL_MODE_AWARE = 0x00000010, 176 | QDC_INCLUDE_HMD = 0x00000020, 177 | } 178 | 179 | internal enum DISPLAYCONFIG_SCANLINE_ORDERING 180 | { 181 | DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED = 0, 182 | DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE = 1, 183 | DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED = 2, 184 | DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_UPPERFIELDFIRST = DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED, 185 | DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_LOWERFIELDFIRST = 3, 186 | } 187 | 188 | internal enum DISPLAYCONFIG_PIXELFORMAT 189 | { 190 | DISPLAYCONFIG_PIXELFORMAT_8BPP = 1, 191 | DISPLAYCONFIG_PIXELFORMAT_16BPP = 2, 192 | DISPLAYCONFIG_PIXELFORMAT_24BPP = 3, 193 | DISPLAYCONFIG_PIXELFORMAT_32BPP = 4, 194 | DISPLAYCONFIG_PIXELFORMAT_NONGDI = 5, 195 | } 196 | 197 | internal enum DISPLAYCONFIG_MODE_INFO_TYPE 198 | { 199 | DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1, 200 | DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2, 201 | DISPLAYCONFIG_MODE_INFO_TYPE_DESKTOP_IMAGE = 3, 202 | } 203 | 204 | [StructLayout(LayoutKind.Sequential)] 205 | internal struct DISPLAYCONFIG_DEVICE_INFO_HEADER 206 | { 207 | public DISPLAYCONFIG_DEVICE_INFO_TYPE type; 208 | public int size; 209 | public LUID adapterId; 210 | public uint id; 211 | } 212 | 213 | [StructLayout(LayoutKind.Sequential)] 214 | internal struct DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO 215 | { 216 | public DISPLAYCONFIG_DEVICE_INFO_HEADER header; 217 | public uint value; 218 | public DISPLAYCONFIG_COLOR_ENCODING colorEncoding; 219 | public int bitsPerColorChannel; 220 | 221 | public bool advancedColorSupported => (value & 0x1) == 0x1; 222 | public bool advancedColorEnabled => (value & 0x2) == 0x2; 223 | public bool wideColorEnforced => (value & 0x4) == 0x4; 224 | public bool advancedColorForceDisabled => (value & 0x8) == 0x8; 225 | } 226 | 227 | [StructLayout(LayoutKind.Sequential)] 228 | internal struct POINTL 229 | { 230 | public int x; 231 | public int y; 232 | } 233 | 234 | [StructLayout(LayoutKind.Sequential)] 235 | internal struct LUID 236 | { 237 | public uint LowPart; 238 | public int HighPart; 239 | 240 | public long Value => ((long)HighPart << 32) | LowPart; 241 | public override string ToString() => Value.ToString(); 242 | } 243 | 244 | [StructLayout(LayoutKind.Sequential)] 245 | internal struct DISPLAYCONFIG_SOURCE_MODE 246 | { 247 | public uint width; 248 | public uint height; 249 | public DISPLAYCONFIG_PIXELFORMAT pixelFormat; 250 | public POINTL position; 251 | } 252 | 253 | [StructLayout(LayoutKind.Sequential)] 254 | internal struct DISPLAYCONFIG_RATIONAL 255 | { 256 | public uint Numerator; 257 | public uint Denominator; 258 | 259 | public override string ToString() => Numerator + " / " + Denominator; 260 | } 261 | 262 | [StructLayout(LayoutKind.Sequential)] 263 | internal struct DISPLAYCONFIG_2DREGION 264 | { 265 | public uint cx; 266 | public uint cy; 267 | } 268 | 269 | [StructLayout(LayoutKind.Sequential)] 270 | internal struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO 271 | { 272 | public POINTL PathSourceSize; 273 | public RECT DesktopImageRegion; 274 | public RECT DesktopImageClip; 275 | } 276 | 277 | [StructLayout(LayoutKind.Sequential)] 278 | internal struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO 279 | { 280 | public ulong pixelRate; 281 | public DISPLAYCONFIG_RATIONAL hSyncFreq; 282 | public DISPLAYCONFIG_RATIONAL vSyncFreq; 283 | public DISPLAYCONFIG_2DREGION activeSize; 284 | public DISPLAYCONFIG_2DREGION totalSize; 285 | public uint videoStandard; 286 | public DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering; 287 | } 288 | 289 | [StructLayout(LayoutKind.Sequential)] 290 | internal struct DISPLAYCONFIG_TARGET_MODE 291 | { 292 | public DISPLAYCONFIG_VIDEO_SIGNAL_INFO targetVideoSignalInfo; 293 | } 294 | 295 | [StructLayout(LayoutKind.Explicit)] 296 | internal struct DISPLAYCONFIG_MODE_INFO_union 297 | { 298 | [FieldOffset(0)] 299 | public DISPLAYCONFIG_TARGET_MODE targetMode; 300 | 301 | [FieldOffset(0)] 302 | public DISPLAYCONFIG_SOURCE_MODE sourceMode; 303 | 304 | [FieldOffset(0)] 305 | public DISPLAYCONFIG_DESKTOP_IMAGE_INFO desktopImageInfo; 306 | } 307 | 308 | [StructLayout(LayoutKind.Sequential)] 309 | internal struct DISPLAYCONFIG_PATH_SOURCE_INFO 310 | { 311 | public LUID adapterId; 312 | public uint id; 313 | public uint modeInfoIdx; 314 | public DISPLAYCONFIG_SOURCE_FLAGS statusFlags; 315 | } 316 | 317 | [StructLayout(LayoutKind.Sequential)] 318 | internal struct DISPLAYCONFIG_PATH_TARGET_INFO 319 | { 320 | public LUID adapterId; 321 | public uint id; 322 | public uint modeInfoIdx; 323 | public DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology; 324 | public DISPLAYCONFIG_ROTATION rotation; 325 | public DISPLAYCONFIG_SCALING scaling; 326 | public DISPLAYCONFIG_RATIONAL refreshRate; 327 | public DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering; 328 | public bool targetAvailable; 329 | public DISPLAYCONFIG_TARGET_FLAGS statusFlags; 330 | } 331 | 332 | [StructLayout(LayoutKind.Sequential)] 333 | internal struct DISPLAYCONFIG_PATH_INFO 334 | { 335 | public DISPLAYCONFIG_PATH_SOURCE_INFO sourceInfo; 336 | public DISPLAYCONFIG_PATH_TARGET_INFO targetInfo; 337 | public DISPLAYCONFIG_PATH flags; 338 | } 339 | 340 | [StructLayout(LayoutKind.Sequential)] 341 | internal struct DISPLAYCONFIG_MODE_INFO 342 | { 343 | public DISPLAYCONFIG_MODE_INFO_TYPE infoType; 344 | public uint id; 345 | public LUID adapterId; 346 | public DISPLAYCONFIG_MODE_INFO_union info; 347 | } 348 | 349 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 350 | internal struct DISPLAYCONFIG_SOURCE_DEVICE_NAME 351 | { 352 | public DISPLAYCONFIG_DEVICE_INFO_HEADER header; 353 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] 354 | public string viewGdiDeviceName; 355 | } 356 | 357 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 358 | internal struct DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS 359 | { 360 | public uint value; 361 | } 362 | 363 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 364 | internal struct DISPLAYCONFIG_TARGET_DEVICE_NAME 365 | { 366 | public DISPLAYCONFIG_DEVICE_INFO_HEADER header; 367 | public DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS flags; 368 | public DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology; 369 | public ushort edidManufactureId; 370 | public ushort edidProductCodeId; 371 | public uint connectorInstance; 372 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] 373 | public string monitorFriendlyDeviceName; 374 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] 375 | public string monitorDevicePath; 376 | } 377 | 378 | [StructLayout(LayoutKind.Sequential)] 379 | internal struct RECT 380 | { 381 | public int left; 382 | public int top; 383 | public int right; 384 | public int bottom; 385 | } 386 | } -------------------------------------------------------------------------------- /novideo_srgb/DoubleToneCurve.cs: -------------------------------------------------------------------------------- 1 | namespace novideo_srgb 2 | { 3 | public class DoubleToneCurve : ToneCurve 4 | { 5 | private double[] _values; 6 | 7 | public DoubleToneCurve(double[] values) 8 | { 9 | _values = values; 10 | } 11 | 12 | public double SampleAt(double x) 13 | { 14 | if (x == 0) return _values[0]; 15 | if (x >= 1) return _values[_values.Length - 1]; 16 | 17 | var index = x * (_values.Length - 1); 18 | var frac = index - (uint)index; 19 | return _values[(uint)index] * (1 - frac) + _values[(uint)index + 1] * frac; 20 | } 21 | 22 | public double SampleInverseAt(double x) 23 | { 24 | if (_values[0] >= x) return 0; 25 | if (_values[_values.Length - 1] <= x) return 1; 26 | 27 | var lowerIndex = -1; 28 | for (var i = 0; i < _values.Length; i++) 29 | { 30 | if (x >= _values[i]) 31 | { 32 | lowerIndex = i; 33 | } 34 | } 35 | 36 | var low = _values[lowerIndex]; 37 | var high = _values[lowerIndex + 1]; 38 | var frac = (x - low) / (high - low); 39 | 40 | return (lowerIndex + frac) / (_values.Length - 1); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /novideo_srgb/GammaToneCurve.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace novideo_srgb 4 | { 5 | public class GammaToneCurve : ToneCurve 6 | { 7 | private readonly double _gamma; 8 | private double _a = 1; 9 | private double _b; 10 | private readonly double _c; 11 | 12 | public unsafe GammaToneCurve(double gamma, double black = 0, double outputOffset = 1, bool relative = false) 13 | { 14 | if (black == 0) 15 | { 16 | _gamma = gamma; 17 | return; 18 | } 19 | 20 | if (outputOffset == 1) 21 | { 22 | _gamma = !relative 23 | ? gamma 24 | : Math.Log((black - 1) * Math.Pow(2, gamma) / (black * Math.Pow(2, gamma) - 1), 2); 25 | _a = 1 - black; 26 | _c = black; 27 | } 28 | else 29 | { 30 | var outBlack = outputOffset * black; 31 | var btWhite = 1 - outBlack; 32 | var btBlack = black - outBlack; 33 | _c = outBlack; 34 | 35 | if (!relative) 36 | { 37 | _gamma = gamma; 38 | CalculateBT1886(btWhite, btBlack); 39 | } 40 | else 41 | { 42 | // assume sane values for black and gamma 43 | double lowD = 1; 44 | double highD = 8; 45 | 46 | // what the hell 47 | var low = *(ulong*)&lowD; 48 | var high = *(ulong*)&highD; 49 | 50 | var target = Math.Pow(0.5, gamma); 51 | 52 | while (true) 53 | { 54 | var mid = (low + high) / 2; 55 | _gamma = *(double*)∣ 56 | CalculateBT1886(btWhite, btBlack); 57 | var sample = SampleAt(0.5); 58 | if (sample == target || low == mid || high == mid) 59 | { 60 | break; 61 | } 62 | 63 | if (sample > target) 64 | { 65 | low = mid; 66 | } 67 | else 68 | { 69 | high = mid; 70 | } 71 | } 72 | } 73 | } 74 | } 75 | 76 | private void CalculateBT1886(double white, double black) 77 | { 78 | var lwg = Math.Pow(white, 1 / _gamma); 79 | var lbg = Math.Pow(black, 1 / _gamma); 80 | _a = Math.Pow(lwg - lbg, _gamma); 81 | _b = lbg / (lwg - lbg); 82 | } 83 | 84 | public double SampleAt(double x) 85 | { 86 | if (x >= 1) return 1; 87 | return _a * Math.Pow(Math.Max(x + _b, 0), _gamma) + _c; 88 | } 89 | 90 | public double SampleInverseAt(double x) 91 | { 92 | if (_a != 1) throw new NotSupportedException(); 93 | if (x >= 1) return 1; 94 | return Math.Pow(x, 1 / _gamma); 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /novideo_srgb/ICCBinaryReader.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Net; 3 | 4 | namespace novideo_srgb 5 | { 6 | public class ICCBinaryReader : BinaryReader 7 | { 8 | public ICCBinaryReader(Stream stream) : base(stream) 9 | { 10 | } 11 | 12 | public override short ReadInt16() 13 | { 14 | return IPAddress.NetworkToHostOrder(base.ReadInt16()); 15 | } 16 | 17 | public override ushort ReadUInt16() 18 | { 19 | return (ushort)ReadInt16(); 20 | } 21 | 22 | public override int ReadInt32() 23 | { 24 | return IPAddress.NetworkToHostOrder(base.ReadInt32()); 25 | } 26 | 27 | public override uint ReadUInt32() 28 | { 29 | return (uint)ReadInt32(); 30 | } 31 | 32 | public override long ReadInt64() 33 | { 34 | return IPAddress.NetworkToHostOrder(base.ReadInt64()); 35 | } 36 | 37 | public override ulong ReadUInt64() 38 | { 39 | return (ulong)ReadInt64(); 40 | } 41 | 42 | public float ReadU8Fixed8() 43 | { 44 | return ReadUInt16() / 256f; 45 | } 46 | 47 | public double ReadS15Fixed16() 48 | { 49 | return ReadInt32() / 65536d; 50 | } 51 | 52 | public double ReadCIEXYZ() 53 | { 54 | return ReadUInt16() / 32768d; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /novideo_srgb/ICCMatrixProfile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace novideo_srgb 5 | { 6 | public class ICCMatrixProfile 7 | { 8 | public Matrix matrix = Matrix.Zero3x3(); 9 | public ToneCurve[] trcs = new ToneCurve[3]; 10 | public ToneCurve[] vcgt; 11 | 12 | private ICCMatrixProfile() 13 | { 14 | } 15 | 16 | public static ICCMatrixProfile FromFile(string path) 17 | { 18 | var result = new ICCMatrixProfile(); 19 | 20 | using (var reader = new ICCBinaryReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))) 21 | { 22 | var stream = reader.BaseStream; 23 | 24 | { 25 | stream.Seek(0x24, SeekOrigin.Begin); 26 | var magic = new string(reader.ReadChars(4)); 27 | if (magic != "acsp") 28 | { 29 | throw new ICCProfileException("Not an ICC profile"); 30 | } 31 | } 32 | 33 | { 34 | stream.Seek(0xC, SeekOrigin.Begin); 35 | var type = new string(reader.ReadChars(4)); 36 | if (type != "mntr") 37 | { 38 | throw new ICCProfileException("Not a display device profile"); 39 | } 40 | } 41 | 42 | { 43 | stream.Seek(0x10, SeekOrigin.Begin); 44 | var spaces = new string(reader.ReadChars(8)); 45 | if (spaces != "RGB XYZ ") 46 | { 47 | throw new ICCProfileException("Not an RGB profile with XYZ PCS"); 48 | } 49 | } 50 | 51 | stream.Seek(0x80, SeekOrigin.Begin); 52 | 53 | var tagCount = reader.ReadUInt32(); 54 | 55 | var seenTags = 0; 56 | 57 | var useCLUT = false; 58 | for (uint i = 0; i < tagCount; i++) 59 | { 60 | stream.Seek(0x80 + 4 + 12 * i, SeekOrigin.Begin); 61 | var tagSig = new string(reader.ReadChars(4)); 62 | 63 | var offset = reader.ReadUInt32(); 64 | var size = reader.ReadUInt32(); 65 | 66 | reader.BaseStream.Seek(offset, SeekOrigin.Begin); 67 | 68 | var index = Array.IndexOf(new[] { 'r', 'g', 'b' }, tagSig[0]); 69 | 70 | if (tagSig == "A2B1") 71 | { 72 | useCLUT = true; 73 | var typeSig = new string(reader.ReadChars(4)); 74 | if (typeSig != "mft2") 75 | { 76 | throw new ICCProfileException(tagSig + " is not of lut16Type"); 77 | } 78 | 79 | reader.ReadUInt32(); 80 | 81 | var inputChannels = reader.ReadByte(); 82 | if (inputChannels != 3) 83 | { 84 | throw new ICCProfileException(tagSig + " must have 3 input channels"); 85 | } 86 | 87 | var outputChannels = reader.ReadByte(); 88 | if (outputChannels != 3) 89 | { 90 | throw new ICCProfileException(tagSig + " must have 3 output channels"); 91 | } 92 | 93 | var lutPoints = reader.ReadByte(); 94 | 95 | reader.ReadByte(); 96 | for (var j = 0; j < 9; j++) 97 | { 98 | reader.ReadS15Fixed16(); 99 | } 100 | 101 | var inputEntries = reader.ReadUInt16(); 102 | var outputEntries = reader.ReadUInt16(); 103 | 104 | var input = new ToneCurve[3]; 105 | for (var j = 0; j < 3; j++) 106 | { 107 | var table = new ushort[inputEntries]; 108 | for (var k = 0; k < inputEntries; k++) 109 | { 110 | table[k] = reader.ReadUInt16(); 111 | } 112 | 113 | input[j] = new LutToneCurve(table); 114 | } 115 | 116 | var clut = new ushort[lutPoints, lutPoints, lutPoints, 3]; 117 | for (var r = 0; r < lutPoints; r++) 118 | { 119 | for (var g = 0; g < lutPoints; g++) 120 | { 121 | for (var b = 0; b < lutPoints; b++) 122 | { 123 | for (var j = 0; j < 3; j++) 124 | { 125 | clut[r, g, b, j] = reader.ReadUInt16(); 126 | } 127 | } 128 | } 129 | } 130 | 131 | var output = new LutToneCurve[3]; 132 | for (var j = 0; j < 3; j++) 133 | { 134 | var table = new ushort[outputEntries]; 135 | for (var k = 0; k < outputEntries; k++) 136 | { 137 | table[k] = reader.ReadUInt16(); 138 | } 139 | 140 | output[j] = new LutToneCurve(table, 32768); 141 | } 142 | 143 | var lut16 = new Lut16(input, clut, output); 144 | var black = lut16.SampleGrayscaleAt(0); 145 | 146 | var primaries = new[] 147 | { 148 | lut16.SampleAt(1, 0, 0), 149 | lut16.SampleAt(0, 1, 0), 150 | lut16.SampleAt(0, 0, 1) 151 | }; 152 | 153 | var Mprime = Matrix.Zero3x3(); 154 | for (var j = 0; j < 3; j++) 155 | { 156 | var purePrimary = primaries[j] - black; 157 | for (var k = 0; k < 3; k++) 158 | { 159 | Mprime[k, j] = purePrimary[k] / purePrimary[1]; 160 | } 161 | } 162 | 163 | var M = Mprime * Matrix.FromDiagonal(Mprime.Inverse() * Colorimetry.D50); 164 | var Minv = M.Inverse(); 165 | result.matrix = M; 166 | 167 | const int trcSize = 4096; 168 | var trcs = new double[3][]; 169 | for (var j = 0; j < 3; j++) 170 | { 171 | trcs[j] = new double[trcSize]; 172 | } 173 | 174 | for (var j = 0; j < trcSize - 1; j++) 175 | { 176 | var values = lut16.SampleGrayscaleAt(j / (double)(trcSize - 1)); 177 | 178 | var toneResponse = Minv * values; 179 | for (var k = 0; k < 3; k++) 180 | { 181 | trcs[k][j] = Math.Min(Math.Max(toneResponse[k], 0), 1); 182 | } 183 | } 184 | 185 | for (var j = 0; j < 3; j++) 186 | { 187 | trcs[j][trcSize - 1] = 1; 188 | result.trcs[j] = new DoubleToneCurve(trcs[j]); 189 | } 190 | } 191 | else if (tagSig.EndsWith("TRC") && !useCLUT) 192 | { 193 | var typeSig = new string(reader.ReadChars(4)); 194 | if (typeSig != "curv") 195 | { 196 | throw new ICCProfileException(tagSig + " is not of curveType"); 197 | } 198 | 199 | reader.ReadUInt32(); 200 | 201 | var numEntries = reader.ReadUInt32(); 202 | 203 | ToneCurve curve; 204 | if (numEntries == 1) 205 | { 206 | var gamma = reader.ReadU8Fixed8(); 207 | curve = new GammaToneCurve(gamma); 208 | } 209 | else 210 | { 211 | var entries = new ushort[numEntries]; 212 | for (uint j = 0; j < numEntries; j++) 213 | { 214 | entries[j] = reader.ReadUInt16(); 215 | } 216 | 217 | curve = new LutToneCurve(entries); 218 | } 219 | 220 | result.trcs[index] = curve; 221 | 222 | seenTags++; 223 | } 224 | else if (tagSig.EndsWith("XYZ") && !useCLUT) 225 | { 226 | reader.ReadUInt32(); 227 | reader.ReadUInt32(); 228 | 229 | for (var j = 0; j < 3; j++) 230 | { 231 | result.matrix[j, index] = reader.ReadS15Fixed16(); 232 | } 233 | 234 | seenTags++; 235 | } 236 | else if (tagSig == "vcgt") 237 | { 238 | reader.ReadChars(4); 239 | reader.ReadUInt32(); 240 | var type = reader.ReadUInt32(); 241 | if (type != 0) throw new ICCProfileException("Only VCGT type 0 is supported"); 242 | 243 | var numChannels = reader.ReadUInt16(); 244 | var numEntries = reader.ReadUInt16(); 245 | var entrySize = reader.ReadUInt16(); 246 | 247 | if (numChannels != 3) throw new ICCProfileException("Only VCGT with 3 channels is supported"); 248 | 249 | result.vcgt = new ToneCurve[3]; 250 | for (var j = 0; j < 3; j++) 251 | { 252 | var values = new ushort[numEntries]; 253 | for (var k = 0; k < numEntries; k++) 254 | { 255 | switch (entrySize) 256 | { 257 | case 1: 258 | values[k] = (ushort)(reader.ReadByte() * ushort.MaxValue / byte.MaxValue); 259 | break; 260 | case 2: 261 | values[k] = reader.ReadUInt16(); 262 | break; 263 | default: 264 | throw new ICCProfileException("Only 8 and 16 bit VCGT is supported"); 265 | } 266 | } 267 | 268 | result.vcgt[j] = new LutToneCurve(values); 269 | } 270 | } 271 | } 272 | 273 | if (!useCLUT) 274 | { 275 | if (seenTags != 6) 276 | { 277 | throw new ICCProfileException("Missing required tags for curves + matrix profile"); 278 | } 279 | 280 | result.matrix = Colorimetry.XYZScaleToD50(result.matrix); 281 | } 282 | } 283 | 284 | return result; 285 | } 286 | } 287 | } -------------------------------------------------------------------------------- /novideo_srgb/ICCProfileException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace novideo_srgb 4 | { 5 | public class ICCProfileException : FormatException 6 | { 7 | public ICCProfileException(string message) : base(message) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /novideo_srgb/LstarEOTF.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace novideo_srgb 4 | { 5 | public class LstarEOTF : ToneCurve 6 | { 7 | private double _black; 8 | 9 | public LstarEOTF(double black) 10 | { 11 | _black = black; 12 | } 13 | 14 | public double SampleAt(double x) 15 | { 16 | if (x >= 1) return 1; 17 | if (x <= 0) return _black; 18 | 19 | const double delta = 6 / 29d; 20 | 21 | x = (x + 0.16) / 1.16; 22 | 23 | double result; 24 | if (x > delta) 25 | { 26 | result = x * x * x; 27 | } 28 | else 29 | { 30 | result = 3 * (delta * delta) * (x - 4 / 29d); 31 | } 32 | 33 | return result * (1 - _black) + _black; 34 | } 35 | 36 | public double SampleInverseAt(double x) 37 | { 38 | throw new NotImplementedException(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /novideo_srgb/Lut16.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace novideo_srgb 4 | { 5 | public class Lut16 6 | { 7 | private ushort[,,,] _lut; 8 | private int _lutSize; 9 | 10 | private ToneCurve[] inputCurves; 11 | private ToneCurve[] outputCurves; 12 | 13 | public Lut16(ToneCurve[] input, ushort[,,,] lut, ToneCurve[] output) 14 | { 15 | _lut = lut; 16 | _lutSize = _lut.GetLength(0); 17 | 18 | inputCurves = input; 19 | outputCurves = output; 20 | } 21 | 22 | public Matrix SampleGrayscaleAt(double index) 23 | { 24 | return SampleAt(index, index, index); 25 | } 26 | 27 | public Matrix SampleAt(double r, double g, double b) 28 | { 29 | var result = Matrix.FromValues(new[,] 30 | { 31 | { inputCurves[0].SampleAt(r) }, 32 | { inputCurves[1].SampleAt(g) }, 33 | { inputCurves[2].SampleAt(b) } 34 | }); 35 | 36 | result = SampleCLUTTetrahedral(result); 37 | 38 | for (var i = 0; i < 3; i++) 39 | { 40 | result[i] = outputCurves[i].SampleAt(result[i]); 41 | } 42 | 43 | return result; 44 | } 45 | 46 | private Matrix S(int x, int y, int z) 47 | { 48 | x = Math.Min(x, _lutSize - 1); 49 | y = Math.Min(y, _lutSize - 1); 50 | z = Math.Min(z, _lutSize - 1); 51 | var sample0 = _lut[x, y, z, 0] / (double)ushort.MaxValue; 52 | var sample1 = _lut[x, y, z, 1] / (double)ushort.MaxValue; 53 | var sample2 = _lut[x, y, z, 2] / (double)ushort.MaxValue; 54 | 55 | return Matrix.FromValues(new[,] { { sample0 }, { sample1 }, { sample2 } }); 56 | } 57 | 58 | private Matrix S(double x, double y, double z) 59 | { 60 | return S((int)x, (int)y, (int)z); 61 | } 62 | 63 | // https://www.filmlight.ltd.uk/pdf/whitepapers/FL-TL-TN-0057-SoftwareLib.pdf 64 | private Matrix SampleCLUTTetrahedral(Matrix rgb) 65 | { 66 | var lutIndex = rgb * (_lutSize - 1); 67 | var n = lutIndex.Map(Math.Floor); 68 | var f = lutIndex.Map(x => x - (int)x); 69 | 70 | Matrix Sxyz; 71 | if (f[0] > f[1]) 72 | { 73 | if (f[1] > f[2]) 74 | { 75 | Sxyz = (1 - f[0]) * S(n[0], n[1], n[2]) 76 | + (f[0] - f[1]) * S(n[0] + 1, n[1], n[2]) 77 | + (f[1] - f[2]) * S(n[0] + 1, n[1] + 1, n[2]) 78 | + (f[2]) * S(n[0] + 1, n[1] + 1, n[2] + 1); 79 | } 80 | else if (f[0] > f[2]) 81 | { 82 | Sxyz = (1 - f[0]) * S(n[0], n[1], n[2]) 83 | + (f[0] - f[2]) * S(n[0] + 1, n[1], n[2]) 84 | + (f[2] - f[1]) * S(n[0] + 1, n[1], n[2] + 1) 85 | + (f[1]) * S(n[0] + 1, n[1] + 1, n[2] + 1); 86 | } 87 | else 88 | { 89 | Sxyz = (1 - f[2]) * S(n[0], n[1], n[2]) 90 | + (f[2] - f[0]) * S(n[0], n[1], n[2] + 1) 91 | + (f[0] - f[1]) * S(n[0] + 1, n[1], n[2] + 1) 92 | + (f[1]) * S(n[0] + 1, n[1] + 1, n[2] + 1); 93 | } 94 | } 95 | else 96 | { 97 | if (f[2] > f[1]) 98 | { 99 | Sxyz = (1 - f[2]) * S(n[0], n[1], n[2]) 100 | + (f[2] - f[1]) * S(n[0], n[1], n[2] + 1) 101 | + (f[1] - f[0]) * S(n[0], n[1] + 1, n[2] + 1) 102 | + (f[0]) * S(n[0] + 1, n[1] + 1, n[2] + 1); 103 | } 104 | else if (f[2] > f[0]) 105 | { 106 | Sxyz = (1 - f[1]) * S(n[0], n[1], n[2]) 107 | + (f[1] - f[2]) * S(n[0], n[1] + 1, n[2]) 108 | + (f[2] - f[0]) * S(n[0], n[1] + 1, n[2] + 1) 109 | + (f[0]) * S(n[0] + 1, n[1] + 1, n[2] + 1); 110 | } 111 | else 112 | { 113 | Sxyz = (1 - f[1]) * S(n[0], n[1], n[2]) 114 | + (f[1] - f[0]) * S(n[0], n[1] + 1, n[2]) 115 | + (f[0] - f[2]) * S(n[0] + 1, n[1] + 1, n[2]) 116 | + (f[2]) * S(n[0] + 1, n[1] + 1, n[2] + 1); 117 | } 118 | } 119 | 120 | return Sxyz; 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /novideo_srgb/LutToneCurve.cs: -------------------------------------------------------------------------------- 1 | namespace novideo_srgb 2 | { 3 | public class LutToneCurve : ToneCurve 4 | { 5 | private ushort[] _values; 6 | private ushort _divisor; 7 | 8 | public LutToneCurve(ushort[] values, ushort divisor = ushort.MaxValue) 9 | { 10 | _values = values; 11 | _divisor = divisor; 12 | } 13 | 14 | public double SampleAt(double x) 15 | { 16 | if (x == 0) return (double)_values[0] / _divisor; 17 | if (x >= 1) return (double)_values[_values.Length - 1] / _divisor; 18 | 19 | var index = x * (_values.Length - 1); 20 | var frac = index - (uint)index; 21 | return (_values[(uint)index] * (1 - frac) + _values[(uint)index + 1] * frac) / _divisor; 22 | } 23 | 24 | public double SampleInverseAt(double x) 25 | { 26 | var value = x * _divisor; 27 | var lowValue = (ushort)value; 28 | 29 | if (_values[0] >= value) return 0; 30 | if (_values[_values.Length - 1] <= lowValue) return 1; 31 | 32 | var lowerIndex = -1; 33 | for (var i = 0; i < _values.Length; i++) 34 | { 35 | if (lowValue >= _values[i]) 36 | { 37 | lowerIndex = i; 38 | } 39 | } 40 | 41 | var low = _values[lowerIndex]; 42 | var high = _values[lowerIndex + 1]; 43 | var frac = (value - low) / (high - low); 44 | 45 | return (lowerIndex + frac) / (_values.Length - 1); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /novideo_srgb/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Windows.Forms; 7 | using System.Xml.Linq; 8 | using Microsoft.Win32; 9 | using NvAPIWrapper.Display; 10 | 11 | namespace novideo_srgb 12 | { 13 | public class MainViewModel 14 | { 15 | public ObservableCollection Monitors { get; } 16 | 17 | private string _configPath; 18 | 19 | private string _startupName; 20 | private RegistryKey _startupKey; 21 | private string _startupValue; 22 | 23 | public MainViewModel() 24 | { 25 | Monitors = new ObservableCollection(); 26 | _configPath = AppDomain.CurrentDomain.BaseDirectory + "config.xml"; 27 | 28 | _startupName = "novideo_srgb"; 29 | _startupKey = Registry.CurrentUser.OpenSubKey 30 | ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); 31 | _startupValue = Application.ExecutablePath + " -minimize"; 32 | 33 | UpdateMonitors(); 34 | } 35 | 36 | public bool? RunAtStartup 37 | { 38 | get 39 | { 40 | var keyValue = _startupKey.GetValue(_startupName); 41 | 42 | if (keyValue == null) 43 | { 44 | return false; 45 | } 46 | 47 | if ((string)keyValue == _startupValue) 48 | { 49 | return true; 50 | } 51 | 52 | return null; 53 | } 54 | set 55 | { 56 | if (value == true) 57 | { 58 | _startupKey.SetValue(_startupName, _startupValue); 59 | } 60 | else 61 | { 62 | _startupKey.DeleteValue(_startupName); 63 | } 64 | } 65 | } 66 | 67 | private void UpdateMonitors() 68 | { 69 | Monitors.Clear(); 70 | List config = null; 71 | if (File.Exists(_configPath)) 72 | { 73 | config = XElement.Load(_configPath).Descendants("monitor").ToList(); 74 | } 75 | 76 | var hdrPaths = DisplayConfigManager.GetHdrDisplayPaths(); 77 | 78 | var number = 1; 79 | foreach (var display in Display.GetDisplays()) 80 | { 81 | var displays = WindowsDisplayAPI.Display.GetDisplays(); 82 | var path = displays.First(x => x.DisplayName == display.Name).DevicePath; 83 | 84 | var hdrActive = hdrPaths.Contains(path); 85 | 86 | var settings = config?.FirstOrDefault(x => (string)x.Attribute("path") == path); 87 | MonitorData monitor; 88 | if (settings != null) 89 | { 90 | monitor = new MonitorData(this, number++, display, path, hdrActive, 91 | (bool)settings.Attribute("clamp_sdr"), 92 | (bool)settings.Attribute("use_icc"), 93 | (string)settings.Attribute("icc_path"), 94 | (bool)settings.Attribute("calibrate_gamma"), 95 | (int)settings.Attribute("selected_gamma"), 96 | (double)settings.Attribute("custom_gamma"), 97 | (double)settings.Attribute("custom_percentage"), 98 | (int)settings.Attribute("target"), 99 | (bool)settings.Attribute("disable_optimization")); 100 | } 101 | else 102 | { 103 | monitor = new MonitorData(this, number++, display, path, hdrActive, false); 104 | } 105 | 106 | Monitors.Add(monitor); 107 | } 108 | 109 | foreach (var monitor in Monitors) 110 | { 111 | monitor.ReapplyClamp(); 112 | } 113 | } 114 | 115 | public void OnDisplaySettingsChanged(object sender, EventArgs e) 116 | { 117 | UpdateMonitors(); 118 | } 119 | 120 | public void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e) 121 | { 122 | if (e.Mode != PowerModes.Resume) return; 123 | OnDisplaySettingsChanged(null, null); 124 | } 125 | 126 | public void SaveConfig() 127 | { 128 | try 129 | { 130 | var xElem = new XElement("monitors", 131 | Monitors.Select(x => 132 | new XElement("monitor", new XAttribute("path", x.Path), 133 | new XAttribute("clamp_sdr", x.ClampSdr), 134 | new XAttribute("use_icc", x.UseIcc), 135 | new XAttribute("icc_path", x.ProfilePath), 136 | new XAttribute("calibrate_gamma", x.CalibrateGamma), 137 | new XAttribute("selected_gamma", x.SelectedGamma), 138 | new XAttribute("custom_gamma", x.CustomGamma), 139 | new XAttribute("custom_percentage", x.CustomPercentage), 140 | new XAttribute("target", x.Target), 141 | new XAttribute("disable_optimization", x.DisableOptimization)))); 142 | xElem.Save(_configPath); 143 | } 144 | catch (Exception ex) 145 | { 146 | MessageBox.Show(ex.Message + "\n\nTry extracting the program elsewhere."); 147 | Environment.Exit(1); 148 | } 149 | } 150 | } 151 | } -------------------------------------------------------------------------------- /novideo_srgb/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 51 | 52 | 53 | 54 | 57 | 58 | 59 | 60 | 61 | 62 | 65 | 66 | 67 | 68 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /novideo_srgb/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Windows; 6 | using System.Windows.Forms; 7 | using Application = System.Windows.Application; 8 | using MessageBox = System.Windows.Forms.MessageBox; 9 | 10 | namespace novideo_srgb 11 | { 12 | public partial class MainWindow 13 | { 14 | private readonly MainViewModel _viewModel; 15 | 16 | private ContextMenu _contextMenu; 17 | 18 | public MainWindow() 19 | { 20 | if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1) 21 | { 22 | MessageBox.Show("Already running!"); 23 | Close(); 24 | return; 25 | } 26 | 27 | InitializeComponent(); 28 | _viewModel = (MainViewModel)DataContext; 29 | SystemEvents.DisplaySettingsChanged += _viewModel.OnDisplaySettingsChanged; 30 | SystemEvents.PowerModeChanged += _viewModel.OnPowerModeChanged; 31 | 32 | var args = Environment.GetCommandLineArgs().ToList(); 33 | args.RemoveAt(0); 34 | 35 | if (args.Contains("-minimize")) 36 | { 37 | WindowState = WindowState.Minimized; 38 | Hide(); 39 | } 40 | 41 | InitializeTrayIcon(); 42 | } 43 | 44 | protected override void OnStateChanged(EventArgs e) 45 | { 46 | if (WindowState == WindowState.Minimized) 47 | { 48 | Hide(); 49 | } 50 | 51 | base.OnStateChanged(e); 52 | } 53 | 54 | private void AboutButton_Click(object sender, RoutedEventArgs o) 55 | { 56 | var window = new AboutWindow 57 | { 58 | Owner = this 59 | }; 60 | window.ShowDialog(); 61 | } 62 | 63 | private void AdvancedButton_Click(object sender, RoutedEventArgs e) 64 | { 65 | if (Application.Current.Windows.Cast().Any(x => x is AdvancedWindow)) return; 66 | var monitor = ((FrameworkElement)sender).DataContext as MonitorData; 67 | var window = new AdvancedWindow(monitor) 68 | { 69 | Owner = this 70 | }; 71 | 72 | void CloseWindow(object o, EventArgs e2) => window.Close(); 73 | 74 | SystemEvents.DisplaySettingsChanged += CloseWindow; 75 | if (window.ShowDialog() == false) return; 76 | SystemEvents.DisplaySettingsChanged -= CloseWindow; 77 | 78 | if (window.ChangedCalibration) 79 | { 80 | _viewModel.SaveConfig(); 81 | monitor?.ReapplyClamp(); 82 | } 83 | 84 | if (window.ChangedDither) 85 | { 86 | monitor?.ApplyDither(window.DitherState.SelectedIndex, Math.Max(window.DitherBits.SelectedIndex, 0), 87 | Math.Max(window.DitherMode.SelectedIndex, 0)); 88 | } 89 | } 90 | 91 | private void ReapplyButton_Click(object sender, RoutedEventArgs e) 92 | { 93 | ReapplyMonitorSettings(); 94 | } 95 | 96 | private void InitializeTrayIcon() 97 | { 98 | var notifyIcon = new NotifyIcon 99 | { 100 | Text = "Novideo sRGB", 101 | Icon = Properties.Resources.icon, 102 | Visible = true 103 | }; 104 | 105 | notifyIcon.MouseDoubleClick += 106 | delegate 107 | { 108 | Show(); 109 | WindowState = WindowState.Normal; 110 | }; 111 | 112 | _contextMenu = new ContextMenu(); 113 | 114 | _contextMenu.Popup += delegate { UpdateContextMenu(); }; 115 | 116 | notifyIcon.ContextMenu = _contextMenu; 117 | 118 | Closed += delegate { notifyIcon.Dispose(); }; 119 | } 120 | 121 | private void UpdateContextMenu() 122 | { 123 | _contextMenu.MenuItems.Clear(); 124 | 125 | foreach (var monitor in _viewModel.Monitors) 126 | { 127 | var item = new MenuItem(); 128 | _contextMenu.MenuItems.Add(item); 129 | item.Text = monitor.Name; 130 | item.Checked = monitor.Clamped; 131 | item.Enabled = monitor.CanClamp; 132 | item.Click += (sender, args) => monitor.Clamped = !monitor.Clamped; 133 | } 134 | 135 | _contextMenu.MenuItems.Add("-"); 136 | 137 | var reapplyItem = new MenuItem(); 138 | _contextMenu.MenuItems.Add(reapplyItem); 139 | reapplyItem.Text = "Reapply"; 140 | reapplyItem.Click += delegate { ReapplyMonitorSettings(); }; 141 | 142 | var exitItem = new MenuItem(); 143 | _contextMenu.MenuItems.Add(exitItem); 144 | exitItem.Text = "Exit"; 145 | exitItem.Click += delegate { Close(); }; 146 | } 147 | 148 | private void ReapplyMonitorSettings() 149 | { 150 | foreach (var monitor in _viewModel.Monitors) 151 | { 152 | monitor.ReapplyClamp(); 153 | } 154 | } 155 | } 156 | } -------------------------------------------------------------------------------- /novideo_srgb/Matrix.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace novideo_srgb 4 | { 5 | public class Matrix 6 | { 7 | private double[,] _values; 8 | 9 | private Matrix() 10 | { 11 | } 12 | 13 | public double this[int x, int y] 14 | { 15 | get => _values[x, y]; 16 | set => _values[x, y] = value; 17 | } 18 | 19 | public double this[int x] 20 | { 21 | get 22 | { 23 | if (Cols != 1) 24 | { 25 | throw new NotSupportedException("Matrix must be 3x1"); 26 | } 27 | 28 | return _values[x, 0]; 29 | } 30 | set 31 | { 32 | if (Cols != 1) 33 | { 34 | throw new NotSupportedException("Matrix must be 3x1"); 35 | } 36 | 37 | _values[x, 0] = value; 38 | } 39 | } 40 | 41 | public int Rows => _values.GetLength(0); 42 | public int Cols => _values.GetLength(1); 43 | 44 | public static Matrix FromValues(double[,] array) 45 | { 46 | if (array.GetLength(0) != 3 || !(array.GetLength(1) == 3 || array.GetLength(1) == 1)) 47 | { 48 | throw new ArgumentException("Array must be 3x3 or 3x1"); 49 | } 50 | 51 | var result = new Matrix 52 | { 53 | _values = array 54 | }; 55 | return result; 56 | } 57 | 58 | public static Matrix Zero3x3() 59 | { 60 | return FromValues(new double[3, 3]); 61 | } 62 | 63 | public static Matrix Zero3x1() 64 | { 65 | return FromValues(new double[3, 1]); 66 | } 67 | 68 | public static Matrix One3x1() 69 | { 70 | return FromValues(new double[,] { { 1 }, { 1 }, { 1 } }); 71 | } 72 | 73 | public static Matrix FromDiagonal(double[] array) 74 | { 75 | if (array.Length != 3) 76 | { 77 | throw new ArgumentException("Array must have length 3"); 78 | } 79 | 80 | var result = new Matrix 81 | { 82 | _values = new double[3, 3] 83 | }; 84 | for (var i = 0; i < 3; i++) 85 | { 86 | result._values[i, i] = array[i]; 87 | } 88 | 89 | return result; 90 | } 91 | 92 | public static Matrix FromDiagonal(Matrix column) 93 | { 94 | if (column.Cols != 1) 95 | { 96 | throw new ArgumentException("Matrix must be 3x1"); 97 | } 98 | 99 | return FromDiagonal(new[] { column[0], column[1], column[2] }); 100 | } 101 | 102 | public static Matrix operator *(Matrix a, Matrix b) 103 | { 104 | if (a.Cols != 3) 105 | { 106 | throw new ArgumentException("Left side must be 3x3"); 107 | } 108 | 109 | var result = b.Cols == 3 ? Zero3x3() : Zero3x1(); 110 | 111 | for (var i = 0; i < 3; i++) 112 | { 113 | for (var j = 0; j < result.Cols; j++) 114 | { 115 | for (var k = 0; k < 3; k++) 116 | { 117 | result[i, j] += a[i, k] * b[k, j]; 118 | } 119 | } 120 | } 121 | 122 | return result; 123 | } 124 | 125 | public static Matrix operator *(double a, Matrix b) 126 | { 127 | var result = b.Cols == 1 ? Zero3x1() : Zero3x3(); 128 | 129 | for (var i = 0; i < result.Rows; i++) 130 | { 131 | for (var j = 0; j < result.Cols; j++) 132 | { 133 | result[i, j] = a * b[i, j]; 134 | } 135 | } 136 | 137 | return result; 138 | } 139 | 140 | public static Matrix operator *(Matrix a, double b) 141 | { 142 | return b * a; 143 | } 144 | 145 | public static Matrix operator /(double a, Matrix b) 146 | { 147 | return 1 / a * b; 148 | } 149 | 150 | public static Matrix operator /(Matrix a, double b) 151 | { 152 | return a * (1 / b); 153 | } 154 | 155 | public static Matrix operator +(Matrix a, Matrix b) 156 | { 157 | if (a.Cols != b.Cols) 158 | { 159 | throw new ArgumentException("Both sides must have same size"); 160 | } 161 | 162 | var result = b.Cols == 1 ? Zero3x1() : Zero3x3(); 163 | 164 | for (var i = 0; i < result.Rows; i++) 165 | { 166 | for (var j = 0; j < result.Cols; j++) 167 | { 168 | result[i, j] = a[i, j] + b[i, j]; 169 | } 170 | } 171 | 172 | return result; 173 | } 174 | 175 | public static Matrix operator -(Matrix a, Matrix b) 176 | { 177 | if (a.Cols != b.Cols) 178 | { 179 | throw new ArgumentException("Both sides must have same size"); 180 | } 181 | 182 | var result = b.Cols == 1 ? Zero3x1() : Zero3x3(); 183 | 184 | for (var i = 0; i < result.Rows; i++) 185 | { 186 | for (var j = 0; j < result.Cols; j++) 187 | { 188 | result[i, j] = a[i, j] - b[i, j]; 189 | } 190 | } 191 | 192 | return result; 193 | } 194 | 195 | public Matrix Inverse() 196 | { 197 | if (Cols != 3) 198 | { 199 | throw new ArgumentException("Matrix must be 3x3"); 200 | } 201 | 202 | var a = this[0, 0]; 203 | var b = this[0, 1]; 204 | var c = this[0, 2]; 205 | var d = this[1, 0]; 206 | var e = this[1, 1]; 207 | var f = this[1, 2]; 208 | var g = this[2, 0]; 209 | var h = this[2, 1]; 210 | var i = this[2, 2]; 211 | 212 | var denom = a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; 213 | return 1 / denom * FromValues(new[,] 214 | { 215 | { e * i - f * h, -b * i + c * h, b * f - c * e }, 216 | { -d * i + f * g, a * i - c * g, -a * f + c * d }, 217 | { d * h - e * g, -a * h + b * g, a * e - b * d } 218 | }); 219 | } 220 | 221 | public Matrix Map(Func func) 222 | { 223 | var result = Cols == 1 ? Zero3x1() : Zero3x3(); 224 | for (var i = 0; i < result.Rows; i++) 225 | { 226 | for (var j = 0; j < result.Cols; j++) 227 | { 228 | result[i, j] = func(this[i, j]); 229 | } 230 | } 231 | 232 | return result; 233 | } 234 | } 235 | } -------------------------------------------------------------------------------- /novideo_srgb/MonitorData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Threading; 6 | using System.Windows; 7 | using EDIDParser; 8 | using EDIDParser.Descriptors; 9 | using EDIDParser.Enums; 10 | using NvAPIWrapper.Display; 11 | using NvAPIWrapper.GPU; 12 | using NvAPIWrapper.Native.Display; 13 | 14 | namespace novideo_srgb 15 | { 16 | public class MonitorData : INotifyPropertyChanged 17 | { 18 | public event PropertyChangedEventHandler PropertyChanged; 19 | 20 | private readonly GPUOutput _output; 21 | private bool _clamped; 22 | private int _bitDepth; 23 | private Novideo.DitherControl _dither; 24 | 25 | private MainViewModel _viewModel; 26 | 27 | public MonitorData(MainViewModel viewModel, int number, Display display, string path, bool hdrActive, bool clampSdr) 28 | { 29 | _viewModel = viewModel; 30 | Number = number; 31 | _output = display.Output; 32 | 33 | _bitDepth = 0; 34 | try 35 | { 36 | var bitDepth = display.DisplayDevice.CurrentColorData.ColorDepth; 37 | if (bitDepth == ColorDataDepth.BPC6) 38 | _bitDepth = 6; 39 | else if (bitDepth == ColorDataDepth.BPC8) 40 | _bitDepth = 8; 41 | else if (bitDepth == ColorDataDepth.BPC10) 42 | _bitDepth = 10; 43 | else if (bitDepth == ColorDataDepth.BPC12) 44 | _bitDepth = 12; 45 | else if (bitDepth == ColorDataDepth.BPC16) 46 | _bitDepth = 16; 47 | } 48 | catch (Exception) 49 | { 50 | } 51 | 52 | Edid = Novideo.GetEDID(path, display); 53 | 54 | Name = Edid.Descriptors.OfType() 55 | .FirstOrDefault(x => x.Type == StringDescriptorType.MonitorName)?.Value ?? ""; 56 | 57 | Path = path; 58 | ClampSdr = clampSdr; 59 | HdrActive = hdrActive; 60 | 61 | var coords = Edid.DisplayParameters.ChromaticityCoordinates; 62 | EdidColorSpace = new Colorimetry.ColorSpace 63 | { 64 | Red = new Colorimetry.Point { X = Math.Round(coords.RedX, 3), Y = Math.Round(coords.RedY, 3) }, 65 | Green = new Colorimetry.Point { X = Math.Round(coords.GreenX, 3), Y = Math.Round(coords.GreenY, 3) }, 66 | Blue = new Colorimetry.Point { X = Math.Round(coords.BlueX, 3), Y = Math.Round(coords.BlueY, 3) }, 67 | White = Colorimetry.D65 68 | }; 69 | 70 | _dither = Novideo.GetDitherControl(_output); 71 | _clamped = Novideo.IsColorSpaceConversionActive(_output); 72 | 73 | ProfilePath = ""; 74 | CustomGamma = 2.2; 75 | CustomPercentage = 100; 76 | } 77 | 78 | public MonitorData(MainViewModel viewModel, int number, Display display, string path, bool hdrActive, bool clampSdr, bool useIcc, string profilePath, 79 | bool calibrateGamma, 80 | int selectedGamma, double customGamma, double customPercentage, int target, bool disableOptimization) : 81 | this(viewModel, number, display, path, hdrActive, clampSdr) 82 | { 83 | UseIcc = useIcc; 84 | ProfilePath = profilePath; 85 | CalibrateGamma = calibrateGamma; 86 | SelectedGamma = selectedGamma; 87 | CustomGamma = customGamma; 88 | CustomPercentage = customPercentage; 89 | Target = target; 90 | DisableOptimization = disableOptimization; 91 | } 92 | 93 | public int Number { get; } 94 | public string Name { get; } 95 | public EDID Edid { get; } 96 | public string Path { get; } 97 | public bool ClampSdr { get; set; } 98 | public bool HdrActive { get; } 99 | 100 | private void UpdateClamp(bool doClamp) 101 | { 102 | if (_clamped) 103 | { 104 | Novideo.DisableColorSpaceConversion(_output); 105 | } 106 | 107 | if (!doClamp) return; 108 | 109 | if (_clamped) Thread.Sleep(100); 110 | if (UseEdid) 111 | Novideo.SetColorSpaceConversion(_output, Colorimetry.RGBToRGB(TargetColorSpace, EdidColorSpace)); 112 | else if (UseIcc) 113 | { 114 | var profile = ICCMatrixProfile.FromFile(ProfilePath); 115 | if (CalibrateGamma) 116 | { 117 | var trcBlack = Matrix.FromValues(new[,] 118 | { 119 | { profile.trcs[0].SampleAt(0) }, 120 | { profile.trcs[1].SampleAt(0) }, 121 | { profile.trcs[2].SampleAt(0) } 122 | }); 123 | var black = (profile.matrix * trcBlack)[1]; 124 | 125 | ToneCurve gamma; 126 | switch (SelectedGamma) 127 | { 128 | case 0: 129 | gamma = new SrgbEOTF(black); 130 | break; 131 | case 1: 132 | gamma = new GammaToneCurve(2.4, black, 0); 133 | break; 134 | case 2: 135 | gamma = new GammaToneCurve(CustomGamma, black, CustomPercentage / 100); 136 | break; 137 | case 3: 138 | gamma = new GammaToneCurve(CustomGamma, black, CustomPercentage / 100, true); 139 | break; 140 | case 4: 141 | gamma = new LstarEOTF(black); 142 | break; 143 | default: 144 | throw new NotSupportedException("Unsupported gamma type " + SelectedGamma); 145 | } 146 | 147 | Novideo.SetColorSpaceConversion(_output, profile, TargetColorSpace, gamma, DisableOptimization); 148 | } 149 | else 150 | { 151 | Novideo.SetColorSpaceConversion(_output, profile, TargetColorSpace); 152 | } 153 | } 154 | } 155 | 156 | private void HandleClampException(Exception e) 157 | { 158 | MessageBox.Show(e.Message); 159 | _clamped = Novideo.IsColorSpaceConversionActive(_output); 160 | ClampSdr = _clamped; 161 | _viewModel.SaveConfig(); 162 | OnPropertyChanged(nameof(Clamped)); 163 | } 164 | 165 | public bool Clamped 166 | { 167 | set 168 | { 169 | try 170 | { 171 | UpdateClamp(value); 172 | ClampSdr = value; 173 | _viewModel.SaveConfig(); 174 | } 175 | catch (Exception e) 176 | { 177 | HandleClampException(e); 178 | return; 179 | } 180 | 181 | _clamped = value; 182 | OnPropertyChanged(); 183 | } 184 | get => _clamped; 185 | } 186 | 187 | public void ReapplyClamp() 188 | { 189 | try 190 | { 191 | var clamped = CanClamp && ClampSdr; 192 | UpdateClamp(clamped); 193 | _clamped = clamped; 194 | OnPropertyChanged(nameof(CanClamp)); 195 | } 196 | catch (Exception e) 197 | { 198 | HandleClampException(e); 199 | } 200 | } 201 | 202 | public bool CanClamp => !HdrActive && (UseEdid && !EdidColorSpace.Equals(TargetColorSpace) || UseIcc && ProfilePath != ""); 203 | 204 | public string GPU => _output.PhysicalGPU.FullName; 205 | 206 | public bool UseEdid 207 | { 208 | set => UseIcc = !value; 209 | get => !UseIcc; 210 | } 211 | 212 | public bool UseIcc { set; get; } 213 | 214 | public string ProfilePath { set; get; } 215 | 216 | public bool CalibrateGamma { set; get; } 217 | 218 | public int SelectedGamma { set; get; } 219 | 220 | public double CustomGamma { set; get; } 221 | 222 | public double CustomPercentage { set; get; } 223 | 224 | public bool DisableOptimization { set; get; } 225 | 226 | public int Target { set; get; } 227 | 228 | public Colorimetry.ColorSpace EdidColorSpace { get; } 229 | 230 | private Colorimetry.ColorSpace TargetColorSpace => Colorimetry.ColorSpaces[Target]; 231 | 232 | public Novideo.DitherControl DitherControl => _dither; 233 | 234 | public string DitherString 235 | { 236 | get 237 | { 238 | string[] types = 239 | { 240 | "SpatialDynamic", 241 | "SpatialStatic", 242 | "SpatialDynamic2x2", 243 | "SpatialStatic2x2", 244 | "Temporal" 245 | }; 246 | if (_dither.state == 2) 247 | { 248 | return "Disabled (forced)"; 249 | } 250 | if (_dither.state == 0 & _dither.bits == 0 && _dither.mode == 0) 251 | { 252 | return "Disabled (default)"; 253 | } 254 | var bits = (6 + 2 * _dither.bits).ToString(); 255 | return bits + " bit " + types[_dither.mode] + " (" + (_dither.state == 0 ? "default" : "forced") + ")"; 256 | } 257 | } 258 | 259 | public int BitDepth => _bitDepth; 260 | 261 | public void ApplyDither(int state, int bits, int mode) 262 | { 263 | try 264 | { 265 | Novideo.SetDitherControl(_output, state, bits, mode); 266 | _dither = Novideo.GetDitherControl(_output); 267 | OnPropertyChanged(nameof(DitherString)); 268 | } 269 | catch (Exception e) 270 | { 271 | MessageBox.Show(e.Message); 272 | } 273 | } 274 | 275 | private void OnPropertyChanged([CallerMemberName] string name = null) 276 | { 277 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); 278 | } 279 | } 280 | } -------------------------------------------------------------------------------- /novideo_srgb/Novideo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.InteropServices; 4 | using EDIDParser; 5 | using Microsoft.Win32; 6 | using NvAPIWrapper.Display; 7 | using NvAPIWrapper.GPU; 8 | 9 | /* 10 | no NDAs violated here! 11 | everything figured out from publicly available information and/or 12 | throwing stuff at NVAPI and observing the results or errors 13 | */ 14 | 15 | namespace novideo_srgb 16 | { 17 | public static class Novideo 18 | { 19 | /* 20 | observed pipeline: content degamma -> content to srgb -> srgb to monitor -> matrix2 -> matrix1 -> monitor gamma 21 | in hardware all the matrix stuff is done with a single matrix, i.e. these four multiplied together 22 | 3x4 matrices cannot be multiplied with each other though, so only the 3x3 parts are combined "properly" 23 | and the offsets are simply added together 24 | */ 25 | [StructLayout(LayoutKind.Sequential)] 26 | private struct Csc 27 | { 28 | public uint version; // 0x1007C for V1, 0x200A0 for V2 29 | 30 | public uint 31 | contentColorSpace; // built-in degamut/degamma transforms, 1 <= x <= 12, default 2 (probably srgb) 32 | 33 | public uint monitorColorSpace; // built-in gamut/gamma transforms, 0 <= x <= 12, default 0 (= csc disabled) 34 | public uint unknown1; // no idea, set to 0 by both get and set functions -> some type of error code? 35 | public uint unknown2; // also no idea, not modified by either function -> unused? 36 | public uint useMatrix1; // 1 to enable 37 | public unsafe fixed float matrix1[3 * 4]; // r/g/b gain and offset 38 | public uint useMatrix2; 39 | 40 | public unsafe fixed float matrix2[3 * 4]; 41 | 42 | // v2 stuff 43 | public unsafe float* degamma; // pointer to degamma part of buffer (= first element) 44 | public unsafe float* regamma; // pointer to regamma part of buffer (= index 0x3000) 45 | 46 | public unsafe float* 47 | buffer; // float array of size 0x6000, contains interleaved rgb degamma followed by regamma 48 | 49 | public int bufferSize; // 0x6000 50 | } 51 | 52 | public struct DitherControl 53 | { 54 | public int state; 55 | public int bits; 56 | public int mode; 57 | public uint bitsCaps; 58 | public uint modeCaps; 59 | } 60 | 61 | [StructLayout(LayoutKind.Sequential)] 62 | private struct Dither 63 | { 64 | public uint version; 65 | public DitherControl ditherControl; 66 | } 67 | 68 | private const uint _NvAPI_GPU_GetColorSpaceConversion = 0x8159E87A; 69 | private const uint _NvAPI_GPU_SetColorSpaceConversion = 0x0FCABD23A; 70 | private const uint _NvAPI_GPU_SetDitherControl = 0x0DF0DFCDD; 71 | private const uint _NvAPI_GPU_GetDitherControl = 0x932AC8FB; 72 | 73 | [DllImport("nvapi64", EntryPoint = "nvapi_QueryInterface")] 74 | private static extern IntPtr NvAPI_QueryInterface(uint id); 75 | 76 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 77 | private delegate int NvAPI_GPU_GetColorSpaceConversion_t(uint displayId, 78 | [MarshalAs(UnmanagedType.Struct)] ref Csc csc); 79 | 80 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 81 | private delegate int NvAPI_GPU_SetColorSpaceConversion_t(uint displayId, 82 | [MarshalAs(UnmanagedType.Struct)] ref Csc csc); 83 | 84 | private static NvAPI_GPU_GetColorSpaceConversion_t NvAPI_GPU_GetColorSpaceConversion; 85 | private static NvAPI_GPU_SetColorSpaceConversion_t NvAPI_GPU_SetColorSpaceConversion; 86 | 87 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 88 | private delegate int NvAPI_GPU_GetDitherControl_t(uint displayId, 89 | [MarshalAs(UnmanagedType.Struct)] ref Dither dither); 90 | 91 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 92 | private delegate int NvAPI_GPU_SetDitherControl_t(uint gpuId, uint outputId, 93 | int state, int bits, int mode); 94 | 95 | private static NvAPI_GPU_GetDitherControl_t NvAPI_GPU_GetDitherControl; 96 | private static NvAPI_GPU_SetDitherControl_t NvAPI_GPU_SetDitherControl; 97 | 98 | public struct ColorSpaceConversion 99 | { 100 | public uint contentColorSpace; 101 | public uint monitorColorSpace; 102 | public float[,] matrix1; 103 | public float[,] matrix2; 104 | } 105 | 106 | public static ColorSpaceConversion GetColorSpaceConversion(GPUOutput output) 107 | { 108 | var displayId = output.PhysicalGPU.GetDisplayDeviceByOutput(output).DisplayId; 109 | 110 | var csc = new Csc { version = 0x1007C }; 111 | var status = NvAPI_GPU_GetColorSpaceConversion(displayId, ref csc); 112 | if (status != 0) 113 | { 114 | throw new Exception("NvAPI_GPU_GetColorSpaceConversion failed with error code " + status); 115 | } 116 | 117 | var result = new ColorSpaceConversion 118 | { 119 | contentColorSpace = csc.contentColorSpace, monitorColorSpace = csc.monitorColorSpace 120 | }; 121 | 122 | for (var i = 0; i < 3; i++) 123 | { 124 | for (var j = 0; j < 4; j++) 125 | { 126 | unsafe 127 | { 128 | if (csc.useMatrix1 == 1) 129 | { 130 | if (result.matrix1 == null) result.matrix1 = new float[3, 4]; 131 | result.matrix1[i, j] = csc.matrix1[i * 4 + j]; 132 | } 133 | 134 | if (csc.useMatrix2 == 1) 135 | { 136 | if (result.matrix2 == null) result.matrix2 = new float[3, 4]; 137 | result.matrix2[i, j] = csc.matrix2[i * 4 + j]; 138 | } 139 | } 140 | } 141 | } 142 | 143 | return result; 144 | } 145 | 146 | public static void SetColorSpaceConversion(GPUOutput output, ColorSpaceConversion conversion) 147 | { 148 | var displayId = output.PhysicalGPU.GetDisplayDeviceByOutput(output).DisplayId; 149 | 150 | var csc = new Csc 151 | { 152 | version = 0x1007C, 153 | contentColorSpace = conversion.contentColorSpace, 154 | monitorColorSpace = conversion.monitorColorSpace 155 | }; 156 | 157 | for (var i = 0; i < 3; i++) 158 | { 159 | for (var j = 0; j < 4; j++) 160 | { 161 | unsafe 162 | { 163 | if (conversion.matrix1 != null) 164 | { 165 | csc.useMatrix1 = 1; 166 | csc.matrix1[i * 4 + j] = conversion.matrix1[i, j]; 167 | } 168 | 169 | if (conversion.matrix2 != null) 170 | { 171 | csc.useMatrix2 = 1; 172 | csc.matrix2[i * 4 + j] = conversion.matrix2[i, j]; 173 | } 174 | } 175 | } 176 | } 177 | 178 | var status = NvAPI_GPU_SetColorSpaceConversion(displayId, ref csc); 179 | if (status != 0) 180 | { 181 | throw new Exception("NvAPI_GPU_SetColorSpaceConversion failed with error code " + status); 182 | } 183 | } 184 | 185 | public static void SetColorSpaceConversion(GPUOutput output, Matrix matrix) 186 | { 187 | SetColorSpaceConversion(output, MatrixToColorSpaceConversion(matrix)); 188 | } 189 | 190 | public static unsafe void SetColorSpaceConversion(GPUOutput output, ICCMatrixProfile profile, 191 | Colorimetry.ColorSpace target, 192 | ToneCurve curve = null, 193 | bool disableOptimization = false) 194 | { 195 | var matrix = profile.matrix.Inverse() * Colorimetry.RGBToPCSXYZ(target); 196 | 197 | if (curve == null) 198 | { 199 | SetColorSpaceConversion(output, MatrixToColorSpaceConversion(matrix)); 200 | return; 201 | } 202 | 203 | var displayId = output.PhysicalGPU.GetDisplayDeviceByOutput(output).DisplayId; 204 | var gamma = new float[2, 1024, 3]; 205 | fixed (float* buffer = gamma) 206 | { 207 | var csc = new Csc 208 | { 209 | version = 0x200A0, 210 | contentColorSpace = 2, 211 | monitorColorSpace = 2, 212 | degamma = buffer, 213 | regamma = buffer + 0x3000 / sizeof(float), 214 | buffer = buffer, 215 | bufferSize = 0x6000, 216 | }; 217 | 218 | double nextIndex = -1; 219 | for (var i = 1; i < 1024; i++) 220 | { 221 | var index = i / 1023d; 222 | 223 | if (!disableOptimization) 224 | { 225 | var curr = i * 255 % 1023; 226 | var next = (i + 1) * 255 % 1023; 227 | 228 | if (nextIndex != -1) 229 | { 230 | index = nextIndex; 231 | nextIndex = -1; 232 | } 233 | else if (next < curr) 234 | { 235 | nextIndex = (i + 1) * 255 / 1023 / 255d; 236 | if (next != 0) 237 | { 238 | index = nextIndex; 239 | } 240 | } 241 | } 242 | 243 | var sample = (float)curve.SampleAt(index); 244 | 245 | for (var j = 0; j < 3; j++) 246 | { 247 | gamma[0, i, j] = sample; 248 | } 249 | } 250 | 251 | for (var i = 0; i < 3; i++) 252 | { 253 | for (var j = 0; j < 3; j++) 254 | { 255 | csc.matrix1[i * 4 + j] = (float)matrix[i, j]; 256 | } 257 | } 258 | 259 | csc.useMatrix1 = 1; 260 | 261 | for (var i = 0; i < 1024; i++) 262 | { 263 | for (var j = 0; j < 3; j++) 264 | { 265 | var value = profile.trcs[j].SampleInverseAt(i / 1023d); 266 | 267 | if (profile.vcgt != null) 268 | { 269 | value = profile.vcgt[j].SampleAt(value); 270 | } 271 | 272 | gamma[1, i, j] = (float)value; 273 | } 274 | } 275 | 276 | var status = NvAPI_GPU_SetColorSpaceConversion(displayId, ref csc); 277 | if (status != 0) 278 | { 279 | throw new Exception("NvAPI_GPU_SetColorSpaceConversion failed with error code " + status); 280 | } 281 | } 282 | } 283 | 284 | public static bool IsColorSpaceConversionActive(GPUOutput output) 285 | { 286 | var csc = GetColorSpaceConversion(output); 287 | switch (csc.monitorColorSpace) 288 | { 289 | // default GPU driver state or explicitly disabled 290 | case 0: 291 | // unity HDR output 292 | case 12 when csc.contentColorSpace == 12 && csc.matrix1 == null && csc.matrix2 == null: 293 | return false; 294 | default: 295 | return true; 296 | } 297 | } 298 | 299 | public static void DisableColorSpaceConversion(GPUOutput output) 300 | { 301 | SetColorSpaceConversion(output, new ColorSpaceConversion { contentColorSpace = 2 }); 302 | } 303 | 304 | public static EDID GetEDID(string path, Display display) 305 | { 306 | try 307 | { 308 | var registryPath = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\DISPLAY\\"; 309 | registryPath += string.Join("\\", path.Split('#').Skip(1).Take(2)); 310 | return new EDID((byte[])Registry.GetValue(registryPath + "\\Device Parameters", "EDID", null)); 311 | } 312 | catch 313 | { 314 | return new EDID(display.Output.PhysicalGPU.ReadEDIDData(display.Output)); 315 | } 316 | } 317 | 318 | private static ColorSpaceConversion MatrixToColorSpaceConversion(Matrix matrix) 319 | { 320 | var csc = new ColorSpaceConversion 321 | { 322 | contentColorSpace = 2, monitorColorSpace = 2, matrix1 = new float[3, 4] 323 | }; 324 | 325 | for (var i = 0; i < 3; i++) 326 | { 327 | for (var j = 0; j < 3; j++) 328 | { 329 | csc.matrix1[i, j] = (float)matrix[i, j]; 330 | } 331 | } 332 | 333 | return csc; 334 | } 335 | 336 | public static DitherControl GetDitherControl(GPUOutput output) 337 | { 338 | var dither = new Dither 339 | { version = 0x10018 }; 340 | var status = NvAPI_GPU_GetDitherControl(output.PhysicalGPU.GetDisplayDeviceByOutput(output).DisplayId, 341 | ref dither); 342 | if (status != 0) 343 | { 344 | throw new Exception("NvAPI_GPU_GetDitherControl failed with error code " + status); 345 | } 346 | 347 | return dither.ditherControl; 348 | } 349 | 350 | public static void SetDitherControl(GPUOutput output, int state, int bits, int mode) 351 | { 352 | var status = NvAPI_GPU_SetDitherControl(output.PhysicalGPU.GPUId, (uint)output.OutputId, state, bits, mode); 353 | if (status != 0) 354 | { 355 | throw new Exception("NvAPI_GPU_SetDitherControl failed with error code " + status); 356 | } 357 | } 358 | 359 | static Novideo() 360 | { 361 | NvAPI_GPU_GetColorSpaceConversion = 362 | Marshal.GetDelegateForFunctionPointer( 363 | NvAPI_QueryInterface(_NvAPI_GPU_GetColorSpaceConversion)); 364 | NvAPI_GPU_SetColorSpaceConversion = 365 | Marshal.GetDelegateForFunctionPointer( 366 | NvAPI_QueryInterface(_NvAPI_GPU_SetColorSpaceConversion)); 367 | NvAPI_GPU_GetDitherControl = 368 | Marshal.GetDelegateForFunctionPointer( 369 | NvAPI_QueryInterface(_NvAPI_GPU_GetDitherControl)); 370 | NvAPI_GPU_SetDitherControl = 371 | Marshal.GetDelegateForFunctionPointer( 372 | NvAPI_QueryInterface(_NvAPI_GPU_SetDitherControl)); 373 | } 374 | } 375 | } -------------------------------------------------------------------------------- /novideo_srgb/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("novideo_srgb")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("novideo_srgb")] 15 | [assembly: AssemblyCopyright("Copyright © 2021")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /novideo_srgb/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace novideo_srgb.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("novideo_srgb.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 65 | /// 66 | internal static System.Drawing.Icon icon { 67 | get { 68 | object obj = ResourceManager.GetObject("icon", resourceCulture); 69 | return ((System.Drawing.Icon)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /novideo_srgb/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /novideo_srgb/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace novideo_srgb.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /novideo_srgb/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /novideo_srgb/RangeRule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Windows.Controls; 5 | using static System.Double; 6 | 7 | namespace novideo_srgb 8 | { 9 | public class RangeRule : ValidationRule 10 | { 11 | public int Min { get; set; } 12 | public int Max { get; set; } 13 | 14 | public override ValidationResult Validate(object valueObj, CultureInfo cultureInfo) 15 | { 16 | if (valueObj == null) return null; 17 | 18 | var valueString = (string)valueObj; 19 | if (valueString.EndsWith(".")) 20 | { 21 | return new ValidationResult(false, "Input must not end in '.'"); 22 | } 23 | 24 | double value = 0; 25 | try 26 | { 27 | if (valueString.Length > 0) 28 | value = Parse(valueString.Replace(',', 'a'), CultureInfo.InvariantCulture); 29 | } 30 | catch (Exception e) 31 | { 32 | return new ValidationResult(false, $"Illegal characters or {e.Message}"); 33 | } 34 | 35 | if (value < Min || value > Max) 36 | { 37 | return new ValidationResult(false, 38 | $"Value must be between {Min} and {Max}"); 39 | } 40 | 41 | return ValidationResult.ValidResult; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /novideo_srgb/SrgbEOTF.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace novideo_srgb 4 | { 5 | public class SrgbEOTF : ToneCurve 6 | { 7 | private double _black; 8 | 9 | public SrgbEOTF(double black) 10 | { 11 | _black = black; 12 | } 13 | 14 | public double SampleAt(double x) 15 | { 16 | if (x >= 1) return 1; 17 | 18 | double result; 19 | if (x <= 0.04045) 20 | { 21 | result = x / 12.92; 22 | } 23 | else 24 | { 25 | result = Math.Pow((x + 0.055) / 1.055, 2.4); 26 | } 27 | 28 | return result * (1 - _black) + _black; 29 | } 30 | 31 | public double SampleInverseAt(double x) 32 | { 33 | if (_black != 0) throw new NotSupportedException(); 34 | if (x >= 1) return 1; 35 | 36 | if (x <= 0.0031308) return 12.92 * x; 37 | return 1.055 * Math.Pow(x, 1 / 2.4) - 0.055; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /novideo_srgb/ToneCurve.cs: -------------------------------------------------------------------------------- 1 | namespace novideo_srgb 2 | { 3 | public interface ToneCurve 4 | { 5 | double SampleAt(double x); 6 | double SampleInverseAt(double x); 7 | } 8 | } -------------------------------------------------------------------------------- /novideo_srgb/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ledoge/novideo_srgb/6d8f875934fe095a5a5c9cfb5bb77e2342000159/novideo_srgb/icon.ico -------------------------------------------------------------------------------- /novideo_srgb/novideo_srgb.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A6A97834-7BE1-474A-B92F-A512DB1D5186} 8 | WinExe 9 | novideo_srgb 10 | novideo_srgb 11 | v4.8 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | true 17 | true 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | true 40 | bin\x64\Debug\ 41 | DEBUG;TRACE 42 | full 43 | x64 44 | 7.3 45 | prompt 46 | true 47 | 48 | 49 | bin\x64\Release\ 50 | TRACE 51 | true 52 | none 53 | x64 54 | 7.3 55 | prompt 56 | true 57 | 58 | 59 | icon.ico 60 | 61 | 62 | 63 | ..\packages\EDIDParser.1.2.5.4\lib\net45\EDIDParser.dll 64 | True 65 | 66 | 67 | ..\packages\NvAPIWrapper.Net.0.8.1.101\lib\net45\NvAPIWrapper.dll 68 | True 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 4.0 84 | 85 | 86 | 87 | 88 | 89 | ..\packages\WindowsDisplayAPI.1.3.0.13\lib\net45\WindowsDisplayAPI.dll 90 | True 91 | 92 | 93 | 94 | 95 | MSBuild:Compile 96 | Designer 97 | 98 | 99 | AboutWindow.xaml 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | MSBuild:Compile 114 | Designer 115 | 116 | 117 | 118 | App.xaml 119 | Code 120 | 121 | 122 | 123 | 124 | 125 | MainWindow.xaml 126 | Code 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | AdvancedWindow.xaml 137 | 138 | 139 | Code 140 | 141 | 142 | True 143 | True 144 | Resources.resx 145 | 146 | 147 | True 148 | Settings.settings 149 | True 150 | 151 | 152 | ResXFileCodeGenerator 153 | Resources.Designer.cs 154 | Designer 155 | 156 | 157 | 158 | SettingsSingleFileGenerator 159 | Settings.Designer.cs 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /novideo_srgb/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------