Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to load a picture to Picture Box in windows forms?

I will be getting a base 64 string. I want to convert it to Image and store it in Picture box.

Thanks in advance

What I have tried:

I am able to upload it from path. but i want to convert from base64 to image and store.
this.imageControl.Location = new System.Drawing.Point(0, 50);
            this.imageControl.Size = new System.Drawing.Size(100,100);//1034, 106
            Bitmap image = new Bitmap("C:\\Images\\WWF-1.PNG");
            this.imageControl.Dock = DockStyle.Fill;
            this.imageControl.Image = (Image)image;
Posted
Updated 2-Feb-21 22:42pm
v2

1 solution

So use the Convert.FromBase64String(String) Method (System) | Microsoft Docs[^] to convert it to an array of bytes, then use those to generate your image by creating a stream:
C#
MemoryStream ms = new MemoryStream(bytes);
Image returnImage = Image.FromStream(ms);

Then you can do what you want with it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900