I have a game where I basically encode parts (rectangles) of a larger image over and over, saving the results in a database....to be read back and repeated over and over. This may occur thousands of times. I don't do any manipulation of the starting image...just copy small rectangles around. After each iteration, I get the bytes from the surface to save in a database.
bytes = surface.Snapshot().Encode(SKEncodedImageFormat.Jpeg, 100).ToArray();
I've noticed that even after maybe 10 iterations of loading, copying, encoding, saving, the jpeg result begins to lose some clarity and definitely a lose of color vibrance. I am using a 100% quality.
If I change the encoding to SKEncodedImageFormat.Png, the end result is great...just like the original image. Unfortunately, the png encoding takes significantly longer and the resulting file size is 3 times the size of the jpeg.
It seems to be the result of the surface Encode method. Any ideas how I can get a better encoding quality with Jpeg?
Maybe there is some way using SkiaSharp that I'm not aware of to copy a rectangle from a source set of bytes to another set of bytes without having to encode the surface.