FW--PICTURE CONVERT
来源:互联网 发布:最新域名升级访问中 编辑:程序博客网 时间:2024/06/07 13:06
using System.IO;
从图片写入文本文件!
private void button1_Click(object sender, System.EventArgs e)
{
FileStream fs = null;
BinaryReader br = null;
StreamWriter sw = null;
try
{
fs = new FileStream("aa.bmp",FileMode.Open,FileAccess.Read);
br = new BinaryReader(fs);
sw = new StreamWriter("bb.txt");
int length = (int)fs.Length;
while(length > 0)
{
byte tempByte = br.ReadByte();
int tempInt =Convert.ToInt32(tempByte);
string tempStr = Convert.ToString(tempInt,16);
sw.WriteLine(tempStr);
length--;
}
}
catch(Exception exce)
{
MessageBox.Show(exce.Message);
}
finally
{
sw.Close();
br.Close();
fs.Close();
}
}
从文本中读取,并还原成图片!
private void button2_Click(object sender, System.EventArgs e)
{
FileStream fs = null;
BinaryWriter bw = null;
StreamReader sr = null;
try
{
fs = new FileStream("cc.bmp",FileMode.Create,FileAccess.Write);
bw = new BinaryWriter(fs);
sr = new StreamReader("bb.txt");
while(sr.Peek() != -1)
{
string tempStr = sr.ReadLine();
int tempInt = Convert.ToInt16(tempStr,16);
byte tempByte = Convert.ToByte(tempInt);
bw.Write(tempByte);
}
}
catch(Exception exce)
{
MessageBox.Show(exce.Message);
}
finally
{
sr.Close();
bw.Close();
fs.Close();
}
}
从图片写入文本文件!
private void button1_Click(object sender, System.EventArgs e)
{
FileStream fs = null;
BinaryReader br = null;
StreamWriter sw = null;
try
{
fs = new FileStream("aa.bmp",FileMode.Open,FileAccess.Read);
br = new BinaryReader(fs);
sw = new StreamWriter("bb.txt");
int length = (int)fs.Length;
while(length > 0)
{
byte tempByte = br.ReadByte();
int tempInt =Convert.ToInt32(tempByte);
string tempStr = Convert.ToString(tempInt,16);
sw.WriteLine(tempStr);
length--;
}
}
catch(Exception exce)
{
MessageBox.Show(exce.Message);
}
finally
{
sw.Close();
br.Close();
fs.Close();
}
}
从文本中读取,并还原成图片!
private void button2_Click(object sender, System.EventArgs e)
{
FileStream fs = null;
BinaryWriter bw = null;
StreamReader sr = null;
try
{
fs = new FileStream("cc.bmp",FileMode.Create,FileAccess.Write);
bw = new BinaryWriter(fs);
sr = new StreamReader("bb.txt");
while(sr.Peek() != -1)
{
string tempStr = sr.ReadLine();
int tempInt = Convert.ToInt16(tempStr,16);
byte tempByte = Convert.ToByte(tempInt);
bw.Write(tempByte);
}
}
catch(Exception exce)
{
MessageBox.Show(exce.Message);
}
finally
{
sr.Close();
bw.Close();
fs.Close();
}
}
- FW--PICTURE CONVERT
- Convert Picture or Video to ascii
- fw
- Android: Failed to convert @drawable/picture into a drawable
- Android: failed to convert @drawable/picture into a drawable
- picture
- picture
- picture
- Picture
- picture
- picture
- Picture
- picture
- Picture
- Picture
- picture
- 【Picture】
- Picture
- list_del 分析
- dispatch_async 与 dispatch_get_global_queue
- C++中Static作用和使用方法
- URLConnection的连接、超时、关闭用法总结
- 6410内核移植
- FW--PICTURE CONVERT
- jvm原理及优化
- JAVA基础:JAVA Array 类介绍
- 【BACnet】2.bacnet-stack-0.8.0工程的makefile结构
- MTBF、MTTR、MTTF
- 湫湫系列故事——减肥记I<完全背包>
- list_del 分析2
- 1. 遥控器-华科尔Devo7e 改造成为支持 dsm2/dsmx 的多制式遥控器
- Erlang epmd的角色以及使用(转载自系统技术非业余研究)