c# - Parameter is not valid using MemoryStream -
c# - Parameter is not valid using MemoryStream -
i need convert byte array image type. byte array contains raw image , image valid. have tried solution net still getting error:
parameter not valid.
following code:
byte[] arr = file.readallbytes(@"c:\users\aa\desktop\image.raw"); memorystream ms = new memorystream(arr,0,arr.length); ms.seek(0, seekorigin.begin); image img = image.fromstream(ms); ms.dispose(); i have tried with:
using(memorystream ms = new memorystream(arr,0,arr.length)) { //my code }
the documentation image.fromstream missing relevant part exist in image.fromfile documentation:
managed gdi+ has built-in encoders , decoders back upwards next file types:
bmp gif jpeg png tiffyour file isn't in 1 of types, you'll need figure out way convert file accepted type first. depending on needs, might acceptable utilize tool imagemagick's convert utility perform conversion automatically, , read in result of conversion.
c#
Comments
Post a Comment