Compare commits

...

2 Commits
v0.182 ... srgb

Author SHA1 Message Date
Serge
27cd55bd4c Merge branch 'main' into srgb 2024-03-05 15:31:12 +01:00
Serge
aeef62afa4 sRGB and Custom gammas support 2024-03-05 15:21:26 +01:00
4 changed files with 1595 additions and 260 deletions

1202
app/Display/CCD.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,56 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace GHelper.Display
{
enum VisualMode
{
Default,
Racing,
Scenery,
RPG,
FPS,
Cinema,
Eyecare,
Vivid
}
public class ScreenControl
{
public const int MAX_REFRESH = 1000;
public static int activeProfile = 0;
public static DisplayGammaRamp? gammaRamp;
private GammaRamp GetGamma(VisualMode mode)
{
ushort[] GammaR, GammaG, GammaB;
switch (mode)
{
case VisualMode.Racing:
GammaR = new ushort[] { 0, 256, 512, 768, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5888, 6144, 6400, 6656, 6912, 7168, 7424, 7680, 8192, 8448, 8704, 8960, 9216, 9472, 9728, 9984, 10240, 10496, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12288, 12544, 12800, 13056, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 15104, 15360, 15360, 15616, 15872, 16128, 16384, 16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18688, 18944, 19200, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21760, 22016, 22272, 22528, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25856, 26112, 26368, 26368, 26624, 26880, 27136, 27392, 27648, 27904, 28160, 28416, 28672, 28928, 29184, 29440, 29696, 29952, 30208, 30208, 30464, 30720, 30976, 31232, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49664, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 51968, 52224, 52736, 52992, 53248, 53504, 53760, 54016, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344, 57600, 57856, 58112, 58368, 58624, 59136, 59392, 59648, 59904, 60160, 60416, 60672, 60928, 61184, 61440, 61696, 61952, 62208, 62464, 62720, 62976, 63488, 63744, 64000, 64256, 64512, 64768, 65024, 65280};
GammaG = new ushort[] { 0, 256, 512, 768, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5888, 6144, 6400, 6656, 6912, 7168, 7424, 7680, 8192, 8448, 8704, 8960, 9216, 9472, 9728, 9984, 10240, 10496, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12288, 12544, 12800, 13056, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 15104, 15360, 15360, 15616, 15872, 16128, 16384, 16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18688, 18944, 19200, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21760, 22016, 22272, 22528, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25600, 25856, 26112, 26368, 26624, 26880, 27136, 27392, 27648, 27904, 28160, 28160, 28416, 28672, 28928, 29184, 29440, 29696, 29952, 30208, 30464, 30464, 30720, 30976, 31232, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41984, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 51968, 52224, 52480, 52736, 52992, 53248, 53504, 53760, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344, 57600, 57856, 58112, 58368, 58624, 58880, 59136, 59392, 59648, 59904, 60160, 60416, 60672, 60928, 61184, 61440, 61696, 61952, 62208, 62464, 62720, 62976, 63232, 63488, 63744, 64000, 64256};
GammaB = new ushort[] { 0, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400, 6656, 6912, 7168, 7424, 7680, 7936, 8192, 8448, 8704, 8960, 9216, 9216, 9472, 9728, 9984, 10240, 10496, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12032, 12288, 12544, 12800, 13056, 13312, 13312, 13568, 13824, 14080, 14336, 14592, 14592, 14848, 15104, 15360, 15616, 15872, 16128, 16384, 16640, 16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18944, 19200, 19200, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21504, 21760, 22016, 22272, 22528, 22784, 23040, 23296, 23552, 23808, 23808, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25600, 25856, 26112, 26368, 26624, 26880, 27136, 27392, 27392, 27648, 27904, 28160, 28416, 28672, 28928, 29184, 29184, 29440, 29696, 29952, 30208, 30464, 30720, 30976, 31232, 31232, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36096, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49664, 49920, 50176, 50432, 50688, 50944, 50944, 51200, 51456, 51712, 51968, 52224, 52480, 52736, 52992, 53248, 53504, 53760, 54016, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56576, 56832, 57088, 57344, 57600, 57856, 58112, 58368, 58624, 58880, 59136, 59392, 59648, 59904, 60160, 60416};
break;
case VisualMode.Scenery:
GammaR = new ushort[] { 7424, 7680, 8192, 8448, 8704, 8960, 9216, 9472, 9728, 9984, 10240, 10496, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12288, 12544, 12800, 13056, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 15104, 15360, 15360, 15616, 15872, 16128, 16384, 16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18688, 18944, 19200, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21760, 22016, 22272, 22528, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25856, 26112, 26368, 26368, 26624, 26880, 27136, 27392, 27648, 27904, 28160, 28416, 28672, 28928, 29184, 29440, 29696, 29952, 30208, 30208, 30464, 30720, 30976, 31232, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49664, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 51968, 52224, 52736, 52992, 53248, 53504, 53760, 54016, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344, 57600, 57856, 58112, 58624, 59136, 59392, 59648, 59904, 60160, 60416, 60672, 60928, 61184, 61440, 61696, 61952, 62208, 62464, 62720, 62976, 63488, 63744, 64000, 64256, 64512, 64768, 65024, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280, 65280};
GammaG = new ushort[] { 7424, 7680, 8192, 8448, 8704, 8960, 9216, 9472, 9728, 9984, 10240, 10496, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12288, 12544, 12800, 13056, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 15104, 15360, 15360, 15616, 15872, 16128, 16384, 16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18688, 18944, 19200, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21760, 22016, 22272, 22528, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25600, 25856, 26112, 26368, 26624, 26880, 27136, 27392, 27648, 27904, 28160, 28160, 28416, 28672, 28928, 29184, 29440, 29696, 29952, 30208, 30464, 30464, 30720, 30976, 31232, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49664, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 52224, 52480, 52736, 52992, 53248, 53504, 53760, 54016, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344, 57600, 58112, 58368, 58624, 58880, 59136, 59392, 59648, 59904, 60160, 60672, 60928, 61184, 61440, 61696, 61952, 62208, 62464, 62720, 62976, 63232, 63488, 63744, 64000, 64256, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512};
GammaB = new ushort[] { 6912, 7168, 7424, 7680, 7936, 8192, 8448, 8704, 8960, 9216, 9472, 9472, 9728, 9984, 10240, 10496, 10752, 11008, 11264, 11264, 11520, 11776, 12032, 12288, 12544, 12800, 13056, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 14848, 15104, 15360, 15616, 15872, 16128, 16384, 16640, 16896, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18944, 19200, 19456, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21760, 21760, 22016, 22272, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25856, 25856, 26112, 26368, 26624, 26880, 27136, 27392, 27648, 27648, 27904, 28160, 28416, 28672, 28928, 29184, 29440, 29440, 29696, 29952, 30208, 30464, 30720, 30976, 31232, 31488, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 34048, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49664, 49664, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 51968, 52224, 52480, 52736, 52992, 53248, 53504, 53760, 54016, 54272, 54528, 54784, 55296, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344, 57600, 57856, 58112, 58368, 58624, 58880, 59136, 59136, 59392, 59648, 59904, 60160, 60416, 60672, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928, 60928};
break;
default:
GammaR = new ushort[] { 0, 256, 512, 768, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5888, 6144, 6400, 6656, 6912, 7168, 7424, 7680, 8192, 8448, 8704, 8960, 9216, 9472, 9728, 9984, 10240, 10496, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12288, 12544, 12800, 13056, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 15104, 15360, 15360, 15616, 15872, 16128, 16384, 16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18688, 18944, 19200, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21760, 22016, 22272, 22528, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25856, 26112, 26368, 26368, 26624, 26880, 27136, 27392, 27648, 27904, 28160, 28416, 28672, 28928, 29184, 29440, 29696, 29952, 30208, 30208, 30464, 30720, 30976, 31232, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49664, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 51968, 52224, 52736, 52992, 53248, 53504, 53760, 54016, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344, 57600, 57856, 58112, 58368, 58624, 59136, 59392, 59648, 59904, 60160, 60416, 60672, 60928, 61184, 61440, 61696, 61952, 62208, 62464, 62720, 62976, 63488, 63744, 64000, 64256, 64512, 64768, 65024, 65280 };
GammaG = new ushort[] { 0, 256, 512, 768, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5888, 6144, 6400, 6656, 6912, 7168, 7424, 7680, 8192, 8448, 8704, 8960, 9216, 9472, 9728, 9984, 10240, 10496, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12288, 12544, 12800, 13056, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 15104, 15360, 15360, 15616, 15872, 16128, 16384, 16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18688, 18944, 19200, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21760, 22016, 22272, 22528, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25600, 25856, 26112, 26368, 26624, 26880, 27136, 27392, 27648, 27904, 28160, 28160, 28416, 28672, 28928, 29184, 29440, 29696, 29952, 30208, 30464, 30464, 30720, 30976, 31232, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41984, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 51968, 52224, 52480, 52736, 52992, 53248, 53504, 53760, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344, 57600, 57856, 58112, 58368, 58624, 58880, 59136, 59392, 59648, 59904, 60160, 60416, 60672, 60928, 61184, 61440, 61696, 61952, 62208, 62464, 62720, 62976, 63232, 63488, 63744, 64000, 64256 };
GammaB = new ushort[] { 0, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400, 6656, 6912, 7168, 7424, 7680, 7936, 8192, 8448, 8704, 8960, 9216, 9216, 9472, 9728, 9984, 10240, 10496, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12032, 12288, 12544, 12800, 13056, 13312, 13312, 13568, 13824, 14080, 14336, 14592, 14592, 14848, 15104, 15360, 15616, 15872, 16128, 16384, 16640, 16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18944, 19200, 19200, 19456, 19712, 19968, 20224, 20480, 20736, 20992, 21248, 21504, 21504, 21760, 22016, 22272, 22528, 22784, 23040, 23296, 23552, 23808, 23808, 24064, 24320, 24576, 24832, 25088, 25344, 25600, 25600, 25856, 26112, 26368, 26624, 26880, 27136, 27392, 27392, 27648, 27904, 28160, 28416, 28672, 28928, 29184, 29184, 29440, 29696, 29952, 30208, 30464, 30720, 30976, 31232, 31232, 31488, 31744, 32000, 32256, 32512, 32768, 33024, 33280, 33536, 33792, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36096, 36352, 36608, 36864, 37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39424, 39680, 39936, 40192, 40448, 40704, 40960, 41216, 41472, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056, 45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152, 49408, 49664, 49920, 50176, 50432, 50688, 50944, 50944, 51200, 51456, 51712, 51968, 52224, 52480, 52736, 52992, 53248, 53504, 53760, 54016, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56576, 56832, 57088, 57344, 57600, 57856, 58112, 58368, 58624, 58880, 59136, 59392, 59648, 59904, 60160, 60416 };
break;
}
return new GammaRamp(GammaR, GammaG, GammaB);
}
public void AutoScreen(bool force = false)
{
if (force || AppConfig.Is("screen_auto"))
@@ -24,6 +66,68 @@ namespace GHelper.Display
}
}
public bool GetSRGB()
{
var screenName = ScreenNative.FindLaptopScreen();
if (screenName is null) return false;
bool userProfiles = CCD.GetUsePerUserDisplayProfiles(screenName);
var defaultProfile = CCD.GetDisplayDefaultColorProfile(screenName);
return defaultProfile is not null && defaultProfile.ToLower().Contains("srgb") && userProfiles;
}
public void ToggleSRGB()
{
var screenName = ScreenNative.FindLaptopScreen();
if (screenName is null) return;
bool userProfiles = CCD.GetUsePerUserDisplayProfiles(screenName);
if (!userProfiles) CCD.SetUsePerUserDisplayProfiles(screenName, true);
var profiles = CCD.GetDisplayColorProfiles(screenName);
var defaultProfile = CCD.GetDisplayDefaultColorProfile(screenName);
Debug.WriteLine($"Default Profile {screenName}: {defaultProfile}");
bool isSRGB = defaultProfile is not null && defaultProfile.ToLower().Contains("srgb") && userProfiles;
bool changed = false;
foreach (var profile in profiles)
{
Debug.WriteLine(profile);
if (!changed && !isSRGB && profile.ToLower().Contains("srgb"))
{
CCD.SetDisplayDefaultColorProfile(screenName, profile);
changed = true;
}
if (!changed && isSRGB && !profile.ToLower().Contains("srgb"))
{
CCD.SetDisplayDefaultColorProfile(screenName, profile);
changed = true;
}
}
if (!changed)
{
if (isSRGB) CCD.SetUsePerUserDisplayProfiles(screenName, false);
else
{
var profile = Application.StartupPath + "ASUS_sRGB.icm";
CCD.AddDisplayColorProfile(screenName, profile, true, false);
}
}
//var colorparams = CCD.GetColorParams(screenName);
//Debug.WriteLine($"{colorparams.MaxLuminance} = {colorparams.RedPointX},{colorparams.RedPointY} {colorparams.GreenPointX},{colorparams.GreenPointY} {colorparams.BluePointX},{colorparams.BluePointY}");
//CCD.SetMinMaxLuminance(0, 0.6, 0.6, screenName);
}
public void SetBrightness(int brightness = -1)
{
if (!AppConfig.IsOLED()) return;
@@ -45,18 +149,20 @@ namespace GHelper.Display
try
{
var handle = ScreenNative.CreateDC(screenName, screenName, null, IntPtr.Zero);
if (gammaRamp is null)
if (true || gammaRamp is null)
{
var gammaDump = new GammaRamp();
if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaDump))
{
gammaRamp = new DisplayGammaRamp(gammaDump);
//Logger.WriteLine("Gamma R: " + string.Join("-", gammaRamp.Red));
//Logger.WriteLine("Gamma G: " + string.Join("-", gammaRamp.Green));
//Logger.WriteLine("Gamma B: " + string.Join("-", gammaRamp.Blue));
Logger.WriteLine("GammaR = {" + string.Join(", ", gammaRamp.Red) + "};");
Logger.WriteLine("GammaG = {" + string.Join(", ", gammaRamp.Green) + "};");
Logger.WriteLine("GammaB = {" + string.Join(", ", gammaRamp.Blue) + "};");
}
}
return;
if (gammaRamp is null || !gammaRamp.IsOriginal())
{
Logger.WriteLine("Not default Gamma");
@@ -68,7 +174,8 @@ namespace GHelper.Display
Logger.WriteLine("Brightness " + bright.ToString() + ": " + result);
} catch (Exception ex)
}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
}

525
app/Settings.Designer.cs generated

File diff suppressed because it is too large Load Diff

View File

@@ -257,6 +257,15 @@ namespace GHelper
panelPerformance.Focus();
InitBrightness();
checkSRGB.Checked = screenControl.GetSRGB();
checkSRGB.CheckedChanged += CheckSRGB_CheckedChanged;
}
private void CheckSRGB_CheckedChanged(object? sender, EventArgs e)
{
screenControl.ToggleSRGB();
}
public void InitBrightness()