I'm using SKIA Sharp to generate some images, however when profiling the encoding part takes in my opinion way too long.
The image has about 10-100 points, 30-140 lines in polygons and 2-20 rectangles (nothing really fancy). The total image generation takes 0.6 seconds - 2 seconds (depending on the number of elements).
The code below takes in about 90-95% of the calculation time. I think this is way too much for a simple png (or am I mistaken?). Is that normal or am I doing something wrong?
public byte[] GetPNG()
{
using SKImage? image = Surface.Snapshot();
using SKData? data = image.Encode(SKEncodedImageFormat.Png, 50); // <<--- This one
MemoryStream target = new MemoryStream();
data.SaveTo(target);
return target.ToArray();
}