-
-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
Im trying to render some svg in an avlaonia app like so:
private void SvgImagePropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (sender is null) return;
if (e.Property == Avalonia.Svg.Skia.Svg.BoundsProperty)
{
var parent = _svgImage.FindAncestorOfType<Panel>();
if (parent is null) return;
Console.WriteLine(parent.Bounds.Height);
var height = parent.Bounds.Height;
var width = parent.Bounds.Width;
if (height > 0)
{
var ver = new Verovio();
ver.LoadFile("/home/noble/Projects/Schubert_Lindenbaum.mei");
ver.SetOption("pageHeight", height.ToString());
ver.SetOption("pageWidth", width.ToString());
var svg = ver.RenderToSvg();
Console.WriteLine(Encoding.UTF8.GetString(svg));
Dispatcher.UIThread.Post(() =>
{
_svgImage.Source = Encoding.UTF8.GetString(svg);
});
}
}
}
This freezes the UI thread until the svg is "done" loading and it is still not rendered onto the control. The svg is quite complex but renders on web browsers fine. The control:
<Svg HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name = "svgImage" />
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request