0
private AdvancedColorInfo advancedColorInfo = new AdvancedColorInfo();

I have tried the above code, but get this error:

“AdvancedColorInfo doesn't contain a constructor that takes 0 arguments.”

I am trying to use the method IsHdrMetadataFormatCurrentlySupported, so I need to create an instance of the AdvancedColorInfo class.

I tried changing the UWP Windows version that is mentioned in the documentation but no luck.

How do I get an instance of AdvancedColorInfo?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
prem
  • 27
  • 6
  • Are you calling https://learn.microsoft.com/en-us/uwp/api/windows.graphics.display.displayinformation.getadvancedcolorinfo ? – mjwills Mar 22 '19 at 11:13
  • i am calling this one https://learn.microsoft.com/en-us/uwp/api/windows.graphics.display.advancedcolorinfo – prem Mar 22 '19 at 11:19
  • I am not getting any constructor signature suggestion. – prem Mar 22 '19 at 11:23
  • Press F12 on it and look at the metadata – NibblyPig Mar 22 '19 at 11:30
  • No constructor is there in class definition. Only methods and props are there – prem Mar 22 '19 at 11:34
  • 1
    There's a clue! The constructor may be private. Therefore to construct an instance of it there could be a static method, e.g. `AdvancedColorInfo.Create()` or it could be derived from another class. – NibblyPig Mar 22 '19 at 13:38

1 Answers1

1

To get an AdvancedColorInfo you don't new them up directly.

Instead, you need to:

var displayInfo = DisplayInformation.GetForCurrentView();
var colorInfo = displayInfo.GetAdvancedColorInfo();
var isHDRSupported = colorInfo.IsHdrMetadataFormatCurrentlySupported(yourFormatPassInHere);

The first method call is a static call to get the DisplayInformation. The second is to get the AdvancedColorInfo from the DisplayInformation.

mjwills
  • 23,389
  • 6
  • 40
  • 63