How can I convert image url to system.drawing.image

前端 未结 6 949
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 06:53

I\'m using VB.Net I have an url of an image, let\'s say http://localhost/image.gif

I need to create a System.Drawing.Image object from that

6条回答
  •  情话喂你
    2020-12-13 07:34

    You can use HttpClient and accomplish this task async with few lines of code.

    public async Task GetImageFromUrl(string url)
        {
            var httpClient = new HttpClient();
            var stream = await httpClient.GetStreamAsync(url);
            return new Bitmap(stream);
        }
    

提交回复
热议问题