I need convert image to Data URL (embedding Image) in the Win-application for HTML and I need Data URL (embedding Image) to image.
The data URI scheme is a uniform resource identifier (URI) scheme that provides a way to include data in-line in Web pages as if they were external resources. It is a form of file literal or here document.
Right-click the image's URL (the cursor will turn into a hand) and choose Open link in Resources Panel. Right-click the image in the Resources Panel and choose Copy image as Data URL. Paste the Data URI wherever you need it.
public static string GetDataURL(string imgFile) { return "<img src=\"data:image/" + Path.GetExtension(imgFile).Replace(".","") + ";base64," + Convert.ToBase64String(File.ReadAllBytes(imgFile)) + "\" />"; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With