c# - Memorystream - OutOfMemoryException -
it might question has been answered before, found no solution problem.
i trying convert bitmap bytearray using memory stream, when out of memory exception, , can't figure out , going wrong. below can find code, , grateful insight on topic.
static byte[] convertbmptobytearray(string imagefilepath) { bitmap bmpimg = (bitmap)bitmap.fromfile(imagefilepath); try { using (memorystream ms = new memorystream()) { bmpimg.save(ms, imageformat.bmp); return ms.toarray(); } } catch(exception e) { console.writeline(e.stacktrace); return null; } }
Comments
Post a Comment