SKImage.Encode in Bmp returns null
See original GitHub issueWhen trying to encode an image in Bmp, it always returns null.
I tried using different values for the quality from 0 to 100, knowing that anyway it does not make sense to have a quality in bmp, I actually thought it would just ignore it.
Here’s a sample that returns null.
var bitmap = SKBitmap.Decode(File.OpenRead(filename));
var image = SKImage.FromBitmap(bitmap);
var data = image.Encode(SKEncodedImageFormat.Bmp, 100); // null
Any idea how to make it work? I would like to avoid using the Bitmap.Bytes as the goal is to be able to also use other encoding format.
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
SkiaSharp SkData is null after Encoding Image
ico the Encoded method returns a null SkData which naturally results in skData. AsStream() exploding in a NullReferenceException. var data = ...
Read more >SKImage.Encode Method (SkiaSharp)
Returns the SKData wrapping the encoded image. Remarks. The quality is a suggestion, and not all formats (for example, PNG) respect or support...
Read more >SkImage Class Reference - Skia
If the image does not already has its contents in encoded form, return NULL. Note: to force the image to return its contents...
Read more >SkImage Class Reference
Returns original SkImage if decoded in raster bitmap, or if encoded in a stream. Returns nullptr if backed by GPU texture and copy...
Read more >include/core/SkImage.h - skia
SkImage is returned if bitmap is valid. Valid SkBitmap parameters include: ... static sk_sp<SkImage> DecodeToRaster(const void* encoded, size_t length,.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just had issue where I needed to decode Webp image using SkiaSharp and convert it to Bmp format. Since SkiaSharp Encode is not supported I used BmpSharp as workaround. Maybe someone will find this useful (I almost created new issue for this.)
Disclaimer : I’m author of BmpSharp
I just saw the answer from Hal Canary. So I’m gonna use PNG instead. Even though the problem is not solved for BMP, I have a pretty good solution instead.
Thanks a lot for your inquiry.