Open
Description
Description
Hi,
We utilize the SkiaSharp library within one of our commercial DevExpress products to offer cross-platform drawing and printing functionalities.
Upon executing the code below, we notice a discrepancy in the resulting figure compared to the one generated using GDI+ functionality.
Although I am not sure whether this behavior is a bug, I would greatly appreciate any suggestions or recommendations on how to resolve this issue.
Code
SKPoint[] points = new SKPoint[] {
new SKPoint(-6388600, 3162518),
new SKPoint(-6010237, 6388600),
new SKPoint(639, 40),
new SKPoint(639, 40),
};
using (SKBitmap bmp = new SKBitmap(650, 350)) {
using (SKCanvas canvas = new SKCanvas(bmp))
using (SKPaint paint = new SKPaint())
using (SKPath path = new SKPath()) {
paint.Style = SKPaintStyle.Stroke;
paint.StrokeWidth = 2;
paint.StrokeMiter = 10;
paint.Color = SKColors.Red;
canvas.Clear(SKColors.White);
path.MoveTo(points[0]);
path.CubicTo(points[1], points[2], points[3]);
canvas.DrawPath(path, paint);
}
string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "skia.png");
using (FileStream stream = File.OpenWrite(savePath))
using (SKPixmap pixmap = bmp.PeekPixels()) {
const int compression = 5;
SKPngEncoderOptions options = new SKPngEncoderOptions(SKPngEncoderFilterFlags.None, zLibLevel: compression);
using (SKManagedWStream skStream = new SKManagedWStream(stream, false))
pixmap.Encode(skStream, options);
}
}
Expected Behavior
This is the result we obtain when we call GDI+ methods:
using (Image image = new Bitmap(650, 350)) {
using (Graphics graphics = Graphics.FromImage(image)) {
PointF[] points = new PointF[] {
new PointF(-6388600, 3162518),
new PointF(-6010237, 6388600),
new PointF(639, 40),
new PointF(639, 40),
};
graphics.Clear(Color.White);
graphics.DrawBeziers(new Pen(Color.Red, 2), points);
}
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "gdi+.png");
image.Save(path, ImageFormat.Png);
}
Actual Behavior
This is the result with SkiaSharp:
Version of SkiaSharp
3.116.0 (Current)
Last Known Good Version of SkiaSharp
Other (Please indicate in the description)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
No response
Devices
No response
Relevant Screenshots
No response
Relevant Log Output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Assignees
Type
Projects
Status
New
Activity