C# Load JPG file, extract BitmapImage

前端 未结 1 347
滥情空心
滥情空心 2021-01-11 09:29

I am trying to extract a BitmapImage from a JPG. This is the code I have:

FileStream fIn = new FileStream(sourceFileName, FileMode.Open); // source JPG
Bitma         


        
1条回答
  •  时光说笑
    2021-01-11 10:21

    Try this:

    public void Load(string fileName) 
    {
    
        using(Stream BitmapStream = System.IO.File.Open(fileName,System.IO.FileMode.Open ))
        {
             Image img = Image.FromStream(BitmapStream);
    
             mBitmap=new Bitmap(img);
             //...do whatever
        }
    }
    

    Or you can just do this (source):

    Bitmap myBmp = Bitmap.FromFile("path here");
    

    0 讨论(0)
提交回复
热议问题