SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[FEATURE] SKImage.FromEncodedData that prevents image from being lazy loaded

Open ggolda opened this issue 1 year ago • 0 comments

Is your feature request related to a problem?

This proposal is related to these 2 bugs/caveats of skia: https://github.com/mono/SkiaSharp/issues/1097 https://github.com/mono/SkiaSharp/issues/445

TLDR; in some cases calling PeekPixels on SKImage results in null references returned from a function due to how it works.

Describe the solution you would like

Would be great to have an optional parameter for SKImage.FromEncodedData(path, ensurePixelData: true) that accepts a new boolean parameter ensurePixelData that tells Skia to bypass it's lazy loading functionality for SKImages.

Similar to the public SKImage ToRasterImage (bool ensurePixelData); implementation.

Describe alternatives you have considered

Currently the only alternative is to copy pixels into a preallocated buffer object which is really inefficient in some complex scenarios.

Additional context

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

ggolda avatar Oct 30 '23 20:10 ggolda