Question WebP in picturebox

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
509
Programming Experience
3-5
Can you load a .webp image into picturebox?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,570
Location
Sydney, Australia
Programming Experience
10+
A WinForms PictureBox will only load an Image object, so it will only load image data that will generate such an object. WEBP exists for the web, so the answer is basically "no". You'd need to convert that data to a more common format and then load that. The alternative would be to use a WebView2 control on your form to actually load a web document, i.e. the WEBP image.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,570
Location
Sydney, Australia
Programming Experience
10+
Here you go, I tested it. This will load on form load event.

Simple solution: pictureBox1.LoadAsync("http://google.com/test.png") 'Just put the link address here

I admire your enthusiasm but the OP is specifically asking how to load a WEBP image, not a PNG image. The WinForms PictureBox control only supports those image formats that can be loaded into a System.Drawing.Image object. That does include PNG but it doesn't include WEBP.
 

Rythorian77

Member
Joined
Nov 23, 2021
Messages
17
Programming Experience
10+
Can you load a .webp image into picturebox?

After falling into the rabbit hole (per say) in researching this, for starters bitmap doesn't support .WebP images, but there are libraries that do: http://webp.codeplex.com/

Most webP wrappers are written in C#. There are code converters that convert C# to VB.Net, but I have never tested it with this issue you face. Exposes simple decoding API and encoding API, advanced decoding and Encoding API (with stadistis of compresion), Get version library and WebPGetFeatures (info of any WebP file). Exposed get PSNR, SSIM or LSIM distortion metrics. Found at: WebP library for C#

The wrapper is in safe managed code in one class. No need external dll except libwebp_x86.dll and libwebp_x64.dll (included v6.1). The wrapper work in 32, 64 bit or ANY (auto swith to the apropiate library).

Conclusion:
You could however design a simple program to download the .WebP image from a url, convert it to png, jpg, etc and then use bitmap to display it in your picturebox. I wish I had a better answer for you. I will continue my efforts to aid you in this trying to find a better solution. I'm sorry I couldn't be more helpful. Happy Thanksgiving.
 
Top Bottom