Download a webp image and load to PictureBox.Image

kiwis

Member
Joined
Jan 26, 2025
Messages
5
Programming Experience
Beginner
As the heading says, i'm trying to download a webp image then load it into my picturebox.

This is the code, I get the image but it's now showing

What's wrong?

C#:
HttpClient client = new HttpClient();
string _url = "https://www.mydomain.com/images/" + profile.imageSrc;
_ = getImage(client, _url);


C#:
        private async Task getImage(HttpClient client, string _url)
        {
            byte[] data = await client.GetByteArrayAsync(_url);
            File.WriteAllBytes("image.jpg", data);
            PictureBox1.Image = Image.FromFile(@"image.jpg");
        }
 
Read the documentation:
Managed GDI+ has built-in encoders and decoders that support the following file types:
  • BMP
  • GIF
  • JPEG
  • PNG
  • TIFF

Downloading a .webp file but saving it as a .jpeg doesn't suddenly convert a .webp file into a .jpeg file.
 
Back
Top Bottom