过年了,散分并分享两段诸位可能用的上的源代码

Jinwmmail 2008-01-26 09:43:56
做一个框架,少用点数据类,比如只用字符串,整型,短整型,浮点型 就可满足常用需要,如果要处理图像呢?


public static string GetStringFromImage(Image image)
{
if (image == null) return "";

MemoryStream stream = new MemoryStream();
image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
stream.Position = 0;
byte[] data = new byte[stream.Length];
stream.Read(data, 0, (int)stream.Length);
stream.Close();
return System.Convert.ToBase64String(data, 0, data.Length);
}

public static Image GetImageFromString(string str)
{
ImageInfo _ImageInfo = new ImageInfo();
if (String.IsNullOrEmpty(str)) return _ImageInfo;

byte[] bitmapData = new byte[str.Length];
bitmapData = Convert.FromBase64String(str);
MemoryStream streamBitmap = new MemoryStream(bitmapData);
Image image = Image.FromStream(streamBitmap);
return image;
}



另求BCB 高手翻译成C++ Builder5.0 代码,另开贴给分200
...全文
717 126 打赏 收藏 转发到动态 举报
写回复
用AI写文章
126 条回复
切换为时间正序
请发表友善的回复…
发表回复
weishijian 2008-01-29
  • 打赏
  • 举报
回复
学习c#操纵PDA中。愁啊!
yellowknight 2008-01-29
  • 打赏
  • 举报
回复
收下
lantaoshajs17 2008-01-29
  • 打赏
  • 举报
回复
学习
sdyt91 2008-01-29
  • 打赏
  • 举报
回复
收下!努力学习C#!!
deknight 2008-01-29
  • 打赏
  • 举报
回复
不管咋地,先接分
狐狸丫丫 2008-01-29
  • 打赏
  • 举报
回复
好东西,收下了
lord_is_layuping 2008-01-29
  • 打赏
  • 举报
回复
接分
消瘦的锁骨浩 2008-01-29
  • 打赏
  • 举报
回复
学习了
谢谢楼主
新年快乐!
AptSnail 2008-01-29
  • 打赏
  • 举报
回复
好人啊,
收藏了

祝兄弟们新年快乐!
guoqiangone 2008-01-29
  • 打赏
  • 举报
回复
学习 接分
ylwd2005 2008-01-29
  • 打赏
  • 举报
回复
楼主慷慨,谢谢啦
ou108 2008-01-29
  • 打赏
  • 举报
回复
jf
jf
fj
ikuaifenglea 2008-01-29
  • 打赏
  • 举报
回复
人真多 学习了
starlessnt 2008-01-29
  • 打赏
  • 举报
回复
学习 接分
春天的气息 2008-01-28
  • 打赏
  • 举报
回复
比较典型的图像读取方式,UP
netnpc 2008-01-28
  • 打赏
  • 举报
回复
学习 and JF
christioner 2008-01-28
  • 打赏
  • 举报
回复
MARK..以后可能会用到
liaocaitian 2008-01-28
  • 打赏
  • 举报
回复
学习中...............
next
接分,
heqi915 2008-01-28
  • 打赏
  • 举报
回复
接分,
heqi915 2008-01-28
  • 打赏
  • 举报
回复
接分,
加载更多回复(104)

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧