Loading a picture file Image.FromFile VS FileStream

后端 未结 4 1846
清酒与你
清酒与你 2020-12-19 08:59

I must admit that I never understood what are the streams are all about- I always thought it\'s an internet thing. But now I run into a code that used a stream to load a fil

4条回答
  •  时光取名叫无心
    2020-12-19 09:27

    If you want to deal with image files, of course the second solution is better. In your first section, you have Bitmap bitmap = new Bitmap(fileStream); you know that an image file is not always Bitmap, it also can be JPEG/PNG/TIFF and so on. While Image.FromFile is quite professional to deal with image files with different extensions.

    Generally speaking, FileStream is common at file issues, while Image.FromFile is more particular at image files. It depends on what kind of files you are going to deal with.

提交回复
热议问题