将图像转换为base64的工具(tool to convert images to base64)

编程入门 行业动态 更新时间:2024-10-25 06:20:00
将图像转换为base64的工具(tool to convert images to base64)

我可以下载到我的Windows机器上的任何可用工具,我可以使用它将图像转换为基础64图像? 我正在使用visual studio 2010并试用这个插件,但我不能让它工作(不能得到图像的基础64的选项),不幸的是因为我真的喜欢它的工作方式。

我更喜欢本地的东西,而不是上传到网站,让他们转换图像。

any tools available that I can download to my windows machine that I can use to convert images to base 64 images? I am working with visual studio 2010 and tried this plugin but I cant get it working (dont get the option to get base 64 of image) unfortunately as I really like the way its suppose to work.

I would prefer something locally than uploading to a website and letting them convert the images.

最满意答案

如果您有Visual Studio,为什么不拼凑一个可以为您执行此操作的快速应用程序?

public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format) { using (MemoryStream ms = new MemoryStream()) { // Convert Image to byte[] image.Save(ms, format); byte[] imageBytes = ms.ToArray(); // Convert byte[] to Base64 String string base64String = Convert.ToBase64String(imageBytes); return base64String; } } public Image Base64ToImage(string base64String) { // Convert Base64 String to byte[] byte[] imageBytes = Convert.FromBase64String(base64String); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); // Convert byte[] to Image ms.Write(imageBytes, 0, imageBytes.Length); Image image = Image.FromStream(ms, true); return image; }

If you have Visual Studio why not toss together a quick app which can do this for you?

public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format) { using (MemoryStream ms = new MemoryStream()) { // Convert Image to byte[] image.Save(ms, format); byte[] imageBytes = ms.ToArray(); // Convert byte[] to Base64 String string base64String = Convert.ToBase64String(imageBytes); return base64String; } } public Image Base64ToImage(string base64String) { // Convert Base64 String to byte[] byte[] imageBytes = Convert.FromBase64String(base64String); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); // Convert byte[] to Image ms.Write(imageBytes, 0, imageBytes.Length); Image image = Image.FromStream(ms, true); return image; }

更多推荐

本文发布于:2023-07-31 01:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340565.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   图像   工具   convert   images

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!