How to get or calculate true background color of code comments in a VS2022 extension
I am creating an extension to add comment formatting in HTML but I have some difficulties with background color.
example : Comment background color specified in user fonts and colors settings : #FF4040 (255,64,64)
Comment background color measured with screenshot :
=> #D94040 (217,64,64) with plain text background color : black
=> #FF6666 (255,102,102) with plain text background color : white
All of these methods return #FF4040
IVsFontAndColorStorage.GetItem( PredefinedClassificationTypeNames.Comment, colorInfo );
TextFormattingRunProperties.BackgroundBrush for IClassificationTypeRegistryService.GetClassificationType( PredefinedClassificationTypeNames.Comment );
IVsUIShell5.GetThemedColor(ref Category, Microsoft.VisualStudio.PlatformUI.EnvironmentColors.EnvironmentBackgroundBrushKey.Name, (uint)__THEMEDCOLORTYPE.TCT_Background); for Microsoft.VisualStudio.PlatformUI.CommonDocumentColors.Category
Microsoft.VisualStudio.Shell.VsColors.GetCurrentThemedColorValues().Keys.Where(ca => ca.Name.Contains("Comment") );
I did not find how to use these methods :
ImageThemingUtilities.ThemePixel()
ImageThemingUtilities.ThemePixelWithExtraContrast()
ImageThemingUtilities.TransformLuminosity()
I was able to find the equation of the luminance :
CommentBackgroundColorRealLuminance = CommentBackgroundColorSettingsLuminance + (( PlainTextBackgroundSettingsLuminance - CommentBackgroundColorSettingsLuminance) / 5 )
but the saturation equation seems not linear.
I would use some help with that.
Thank you for your answers