reneschulte / WriteableBitmapEx

Collection of extension methods for the XAML WriteableBitmap
MIT License
533 stars 121 forks source link

Strange compression/deformation when drawing concentric circles #75

Open chris-crowther opened 2 years ago

chris-crowther commented 2 years ago

Thanks for the excellent library!

When drawing concentric circles on a wide image using DrawEllipseCentered the outer circles appear compressed/deformed.

using (writeableBitmap.GetBitmapContext())
{
    var centreX = (int) (writeableBitmap.Width / 2D);
    var centreY = (int) (writeableBitmap.Height / 2D);

    for (int i = 1; i <= 100; i++)
    {
        var radius = i * 50;
        writeableBitmap.DrawEllipseCentered(centreX, centreY, radius, radius, ConvertColor(Colors.Red));
    }
}

The bitmap is passed to a WPF image control with Stretch="None".

image

zgabi commented 2 years ago

The bigger circles are not even drawn: image

After changing all the ints to long in DrawEllipseCentered: image

I changed the following: image

(I don't know how this type change affects the performance... on a 64 bit CPU it should not be a problem)

NOTE: My screenshots are scaled.. in the original size they are perfect circles.