1212
1313using SkiaSharp ;
1414using TheArtOfDev . HtmlRenderer . Adapters ;
15- using SKSvg = SkiaSharp . Extended . Svg . SKSvg ;
16-
15+ using Svg . Skia ;
1716
1817namespace TheArtOfDev . HtmlRenderer . SkiaSharp . Adapters
1918{
@@ -25,8 +24,7 @@ internal sealed class ImageAdapter : RImage
2524 /// <summary>
2625 /// the underlying image. This may be either a bitmap (_image) or an svg (_svg).
2726 /// </summary>
28- private SKImage _image ;
29-
27+ private SKImage ? _image ;
3028 private readonly SKSvg ? _svg ;
3129
3230 /// <summary>
@@ -42,36 +40,31 @@ public ImageAdapter(SKSvg svg)
4240 _svg = svg ;
4341 }
4442
45-
4643 /// <summary>
4744 /// the underline SkiaSharp image.
4845 /// </summary>
4946 public SKImage Image
5047 {
5148 get
52- {
53- if ( _image == null && _svg != null )
49+ {
50+ if ( _image == null && _svg ? . Picture != null )
5451 {
5552 //Render the image from the picture, as this is being used in a texture brush.
56- _image = SKImage . FromBitmap ( new SKBitmap ( ( int ) _svg . CanvasSize . Width , ( int ) _svg . CanvasSize . Height ) ) ;
53+ _image = SKImage . FromPicture ( _svg . Picture , _svg . Picture . CullRect . Size . ToSizeI ( ) ) ;
5754 }
55+
5856 return _image ;
5957 }
6058 }
6159
62- /// <summary>
63- /// Picture if this represents a structured image, eg, SVG.
64- /// </summary>
65- public SKPicture Picture { get ; set ; }
66-
6760 public override double Width
6861 {
69- get { return _image ? . Width ?? ( ( int ? ) _svg ? . CanvasSize . Width ) ?? 0 ; }
62+ get { return _image ? . Width ?? _svg ? . Picture ? . CullRect . Width ?? 0 ; }
7063 }
7164
7265 public override double Height
7366 {
74- get { return _image ? . Height ?? ( ( int ? ) _svg ? . CanvasSize . Height ) ?? 0 ; }
67+ get { return _image ? . Height ?? _svg ? . Picture ? . CullRect . Height ?? 0 ; }
7568 }
7669
7770 public override void Dispose ( )
@@ -82,7 +75,6 @@ public override void Dispose()
8275
8376 internal void DrawImage ( SKCanvas canvas , SKRect dstRect , SKRect ? srcRect = null )
8477 {
85-
8678 if ( _svg != null )
8779 {
8880 //TODO: support the overload that passes a source rect. Using Matrix overload perhaps?..
0 commit comments