我不能使用OutputStream或任何其他类型的流,但不能创建System.IO.Stream
的实例。
System.IO.Stream s = new System.IO.Stream();
bmpObj.Compress(Bitmap.CompressFormat.Jpeg, 100, s);
有解决方案吗?我无法以这种方式将图像写入存储。
答案 0 :(得分:1)
Stream
是一个抽象类-您需要使用MemoryStream
或FileStream
using (System.IO.Stream outStream = System.IO.File.Create(targetFile))
{
bmpObj.Compress(Bitmap.CompressFormat.Png, 100, outStream);
}