如何将本地图片转换成二进制数据存入远程数据库
1个回答
展开全部
/图片转游答成侍磨颤二进制
public byte[] getBytes(string filePath)
{
System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
byte[] imgData = new byte[fs.Length];
fs.Read(imgData, 0, (int)fs.Length);
return imgData;
}
/老败/二进制转成图片
private System.Drawing.Image convertByteToImg(byte[] imgData)
{
System.IO.MemoryStream ms = new System.IO.MemoryStream(imgData);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
return img;
public byte[] getBytes(string filePath)
{
System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
byte[] imgData = new byte[fs.Length];
fs.Read(imgData, 0, (int)fs.Length);
return imgData;
}
/老败/二进制转成图片
private System.Drawing.Image convertByteToImg(byte[] imgData)
{
System.IO.MemoryStream ms = new System.IO.MemoryStream(imgData);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
return img;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询