0

i wanna convert the image in the picture box to base64 String.

private void btnCapture_Click(object sender, EventArgs e)
    {
        frmaccount.pbID.Image = (Bitmap)pbCapture.Image.Clone();//this is the image i wanna Convert to base64
        device.Stop();
        this.Dispose();
    }

PS. the image is taken from my camera and i want to save it as base64 String.

Sim Sim
  • 15
  • 9

1 Answers1

0

You can convert your image to a byte[] first

ImageConverter converter = new ImageConverter();
var bytes = (byte[])converter.ConvertTo((Bitmap)pbCapture.Image, typeof(byte[]));

and then to a base64 string

string base64String = Convert.ToBase64String(imageBytes);
Dominik
  • 1,623
  • 11
  • 27