如何将图像转换为字符串 [英] How to convert image to string

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

问题描述

HI,

我试图在C-Sharp,asp.net中将图像转换为字符串,并在登录页面中检查用户名和图像列,请向我发送fileuplod编码的完整信息.

在这里,我添加了编码,让我知道错误在哪里,并尽快纠正我.



I tried to convert image to string in C-Sharp ,asp.net and also check the username and image column in login page please sent me condition of fileuplod coding fully.

Here I Added my coding let me where is error and rectify me ASAP.

if (TextBox1.Text !=  FileUpload1.PostedFile.FileName)
      {
          Response.Redirect("default.aspx");

推荐答案

此函数将BMP转换为String
This function convert BMP to String
public string ConvertImage(Bitmap tempBitmap)
{
MemoryStream objStream = new MemoryStream();
tempBitmap.Save(objStream, ImageFormat.Jpeg);
return Convert.ToBase64String(objStream.ToArray());
}



以及下面如何调用上面的函数



and how you call above function is mention below

public void convert_BMP_into_String()
{
Bitmap obj_Bitmap = new Bitmap(@"C:\temp.jpg");
string temp_String = ConvertImage(obj_Bitmap);
StreamWriter sw = new StreamWriter(@"C:\temp.text", false);
sw.Write(temp_String);
sw.Close();
}


[ ^ ]和 Convert-Image-binary-format [^ ]


http://www.dailycoding.com/Posts/convert_image_to_base64_string_and_base6464_string_to_image.aspx [ http://social.msdn.microsoft.com/Forums/zh/csharpgeneral/thread/ad34be7a-0fbf-4385-a79f-6ee43bba4d29 [
http://waleedelkot.blogspot.com/2009/08/how-to-convert-image-to-string-using-c.html[^]



http://www.dailycoding.com/Posts/convert_image_to_base64_string_and_base64_string_to_image.aspx[^]


http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/ad34be7a-0fbf-4385-a79f-6ee43bba4d29[^]


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

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