We are migrating from SyntaxEditor version 287 to 400. When using TextViewDrawContext.DrawImage, the glyph has artifact ringing where the transparent background meets the image contents. I have tried using the TextViewDrawContext.PlatformRenderer to access GDI directly, but get a System.InvalidOperationException: 'Object is currently in use elsewhere.' Is there a way to make drawn glyphs render in higher quality?
internal class ErrorLineIndicatorTag : IndicatorClassificationTagBase
{
private static readonly IClassificationType ErrorIndicatorLineClassificationType = new ClassificationType("Error Line Indicator");
private static readonly IClassificationType ErrorIndicatorLineNoHighlightClassificationType = new ClassificationType("Error Line Indicator No Highlight");
private readonly Image m_image;
private readonly bool m_highlight;
static ErrorLineIndicatorTag()
{
AmbientHighlightingStyleRegistry.Instance.Register(ErrorIndicatorLineClassificationType, new HighlightingStyle { Background = Color.FromArgb(40, Color.Firebrick), BorderColor = Color.FromArgb(40, Color.DarkRed), BorderKind = LineKind.Solid, BackgroundSpansVirtualSpace = true });
AmbientHighlightingStyleRegistry.Instance.Register(ErrorIndicatorLineNoHighlightClassificationType, new HighlightingStyle());
}
public ErrorLineIndicatorTag(bool highlight)
{
m_highlight = highlight;
var imageSize = (int) (16 * ImageLists.DpiScale);
m_image = ImageLists.GetImage("Error");
}
public override IClassificationType ClassificationType { get { return m_highlight ? ErrorIndicatorLineClassificationType : ErrorIndicatorLineNoHighlightClassificationType; } }
public override void DrawGlyph(TextViewDrawContext context, ITextViewLine viewLine, TagSnapshotRange<IIndicatorTag> tagRange, Rectangle bounds)
{
if (bounds.Width > bounds.Height)
context.DrawImage(new Point((bounds.Width - bounds.Height) / 2 + bounds.X, bounds.Y), m_image);
else
context.DrawImage(new Point(bounds.X, (bounds.Height - bounds.Width) / 2 + bounds.Y), m_image);
}
}