c# - Base64 image to WPF image source error No imaging component suitable -
i trying decode base64 image , place wpf image source. however, code using has error of:
no imaging component suitable finish operation found.
i have double-checked base64 string have is, in fact, right base64 encoding using online base64 decoder know not that.
my code:
byte[] binarydata = convert.frombase64string(desc.icon_path); memorystream ms = new memorystream(binarydata, 0, binarydata.length); ms.write(binarydata, 0, binarydata.length); system.drawing.image image = system.drawing.image.fromstream(ms, true); icon.source = towpfimage(image); ms.dispose(); public bitmapimage towpfimage(system.drawing.image img) { memorystream ms = new memorystream(); img.save(ms, system.drawing.imaging.imageformat.bmp); bitmapimage ix = new bitmapimage(); ix.begininit(); ix.cacheoption = bitmapcacheoption.onload; ix.streamsource = ms; ix.endinit(); homecoming ix; }
what doing incorrect?
i dont think need ms.write line you? if you'll need set ms.position = 0 after write. because after write stream position @ end.
c# wpf base64 imagesource
No comments:
Post a Comment