将图片更改为字符串 [英] Change Image in to String

查看:86
本文介绍了将图片更改为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将图像转换为字符串

Is there is a way to convert image to a string

推荐答案

Try
Try
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;
  }
}


参考链接:-将图像转换为字符串 [


Reference Link :- Convert Image to String[^]


这篇关于将图片更改为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆