Hello,
Welcome to Microsoft Q&A!
First of all, I've tested the sample you shared. Both of the images will throw exception. The TestImage.heic
will throw InvalidCastException
exception. The TestImageThatWorks.heic
will throw "No suitable transform was found to encode or decode the content" error when calling await wb.SetSourcAsync(resizedStream)
.
Does the code need any modifying or is this a bug in the framework?
Back to the question, I have to say that this behavior is expected. Please take a look at the document for BitmapEncoder Class, in the Remark section, go to the Image formats parts, it is mentioned that the BitmapEncoder
could encode the following formats: JPEG, PNG, GIF, TIFF, BMP, JPEG-XR. And you could check BitmapDecoder Class for the formats it supports as well. HEIC is not the format that the BitmapEncoder supports. So you can't use the BitmapEncoder to process the HEIC image.
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.