diff --git a/samples/AvaloniaSvgSkiaSample/DrawControl.axaml b/samples/AvaloniaSvgSkiaSample/DrawControl.axaml
new file mode 100644
index 00000000..bff55611
--- /dev/null
+++ b/samples/AvaloniaSvgSkiaSample/DrawControl.axaml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/samples/AvaloniaSvgSkiaSample/DrawControl.axaml.cs b/samples/AvaloniaSvgSkiaSample/DrawControl.axaml.cs
new file mode 100644
index 00000000..9dcaf295
--- /dev/null
+++ b/samples/AvaloniaSvgSkiaSample/DrawControl.axaml.cs
@@ -0,0 +1,25 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Media;
+using Avalonia.Svg.Skia;
+
+namespace AvaloniaSvgSkiaSample;
+
+public partial class DrawControl : UserControl
+{
+ public SvgImage Image { get; set; }
+
+ public DrawControl()
+ {
+ InitializeComponent();
+ }
+
+ public override void Render(DrawingContext context)
+ {
+ var center = Bounds.Center;
+ var width = Image.Size.Width / 2;
+ var height = Image.Size.Width / 2;
+ context.DrawImage(Image, new Rect(center.X - 0.5 * width, center.Y - 0.5 * height, width, height));
+ }
+}
+
diff --git a/samples/AvaloniaSvgSkiaSample/MainWindow.axaml b/samples/AvaloniaSvgSkiaSample/MainWindow.axaml
index 66b077a7..d9d83f41 100644
--- a/samples/AvaloniaSvgSkiaSample/MainWindow.axaml
+++ b/samples/AvaloniaSvgSkiaSample/MainWindow.axaml
@@ -3,6 +3,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
+ xmlns:local="clr-namespace:AvaloniaSvgSkiaSample"
mc:Ignorable="d" d:DesignWidth="900" d:DesignHeight="600"
x:Class="AvaloniaSvgSkiaSample.MainWindow"
Width="900" Height="600" WindowStartupLocation="CenterScreen"
@@ -146,6 +147,17 @@
+
+
+
+
+
+
diff --git a/src/Avalonia.Controls.Skia/SKBitmapControl.cs b/src/Avalonia.Controls.Skia/SKBitmapControl.cs
index 418026cd..9eafd0d2 100644
--- a/src/Avalonia.Controls.Skia/SKBitmapControl.cs
+++ b/src/Avalonia.Controls.Skia/SKBitmapControl.cs
@@ -123,7 +123,7 @@ public override void Render(DrawingContext context)
}
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(new SKBitmapDrawOperation(new Rect(0, 0, bounds.Width, bounds.Height), bitmap));
}
diff --git a/src/Avalonia.Controls.Skia/SKBitmapImage.cs b/src/Avalonia.Controls.Skia/SKBitmapImage.cs
index 7bf1c0a9..b8caa04e 100644
--- a/src/Avalonia.Controls.Skia/SKBitmapImage.cs
+++ b/src/Avalonia.Controls.Skia/SKBitmapImage.cs
@@ -46,7 +46,7 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect)
var scaleMatrix = Matrix.CreateScale(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);
var translateMatrix = Matrix.CreateTranslation(-sourceRect.X + destRect.X - bounds.Top, -sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(new SKBitmapDrawOperation(new Rect(0, 0, bounds.Width, bounds.Height), source));
}
diff --git a/src/Avalonia.Controls.Skia/SKPathControl.cs b/src/Avalonia.Controls.Skia/SKPathControl.cs
index 87f92190..6057a50c 100644
--- a/src/Avalonia.Controls.Skia/SKPathControl.cs
+++ b/src/Avalonia.Controls.Skia/SKPathControl.cs
@@ -140,7 +140,7 @@ public override void Render(DrawingContext context)
}
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(
new SKPathDrawOperation(
diff --git a/src/Avalonia.Controls.Skia/SKPathImage.cs b/src/Avalonia.Controls.Skia/SKPathImage.cs
index 59847557..a0234dc8 100644
--- a/src/Avalonia.Controls.Skia/SKPathImage.cs
+++ b/src/Avalonia.Controls.Skia/SKPathImage.cs
@@ -66,7 +66,7 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect)
var scaleMatrix = Matrix.CreateScale(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);
var translateMatrix = Matrix.CreateTranslation(-sourceRect.X + destRect.X - bounds.Top, -sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(new SKPathDrawOperation(new Rect(0, 0, bounds.Width, bounds.Height), source, paint));
}
diff --git a/src/Avalonia.Controls.Skia/SKPictureControl.cs b/src/Avalonia.Controls.Skia/SKPictureControl.cs
index 8a5977a4..8f42637d 100644
--- a/src/Avalonia.Controls.Skia/SKPictureControl.cs
+++ b/src/Avalonia.Controls.Skia/SKPictureControl.cs
@@ -123,7 +123,7 @@ public override void Render(DrawingContext context)
}
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(
new SKPictureDrawOperation(
diff --git a/src/Avalonia.Controls.Skia/SKPictureImage.cs b/src/Avalonia.Controls.Skia/SKPictureImage.cs
index 001608dc..6c69b959 100644
--- a/src/Avalonia.Controls.Skia/SKPictureImage.cs
+++ b/src/Avalonia.Controls.Skia/SKPictureImage.cs
@@ -46,7 +46,7 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect)
var scaleMatrix = Matrix.CreateScale(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);
var translateMatrix = Matrix.CreateTranslation(-sourceRect.X + destRect.X - bounds.Top, -sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(new SKPictureDrawOperation(new Rect(0, 0, bounds.Width, bounds.Height), source));
}
diff --git a/src/Avalonia.Svg.Skia/Svg.cs b/src/Avalonia.Svg.Skia/Svg.cs
index e0ce08e9..e61521a8 100644
--- a/src/Avalonia.Svg.Skia/Svg.cs
+++ b/src/Avalonia.Svg.Skia/Svg.cs
@@ -230,7 +230,7 @@ public override void Render(DrawingContext context)
-sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(
new SvgSourceCustomDrawOperation(
diff --git a/src/Avalonia.Svg.Skia/SvgImage.cs b/src/Avalonia.Svg.Skia/SvgImage.cs
index 87ea5d19..a30b4928 100644
--- a/src/Avalonia.Svg.Skia/SvgImage.cs
+++ b/src/Avalonia.Svg.Skia/SvgImage.cs
@@ -88,7 +88,7 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect)
-sourceRect.X + destRect.X - bounds.Top,
-sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(
new SvgSourceCustomDrawOperation(
diff --git a/src/Avalonia.Svg/Svg.cs b/src/Avalonia.Svg/Svg.cs
index 04e6ad28..693412a2 100644
--- a/src/Avalonia.Svg/Svg.cs
+++ b/src/Avalonia.Svg/Svg.cs
@@ -213,7 +213,7 @@ public override void Render(DrawingContext context)
-sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
if (_avaloniaPicture is { })
{
diff --git a/src/Avalonia.Svg/SvgImage.cs b/src/Avalonia.Svg/SvgImage.cs
index 473d2fa5..27e81caa 100644
--- a/src/Avalonia.Svg/SvgImage.cs
+++ b/src/Avalonia.Svg/SvgImage.cs
@@ -69,7 +69,7 @@ void IImage.Draw(
-sourceRect.X + destRect.X - bounds.Top,
-sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
- using (context.PushTransform(translateMatrix * scaleMatrix))
+ using (context.PushTransform(scaleMatrix * translateMatrix))
{
try
{