当前位置: 代码迷 >> C# >> C# 图片 转 C语言数组文件解决思路
  详细解决方案

C# 图片 转 C语言数组文件解决思路

热度:547   发布时间:2016-05-05 05:32:16.0
C# 图片 转 C语言数组文件
求大神指导图片转化成C语言数组
类似这种
const unsigned char gImage_11[6786] = { 0X00,0X01,0XF0,0X00,0XE2,0X00, 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00, 0X00,0X00,0X00,0X03,0XBF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X00,0X00, 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00, 0X00,0X02,0XBF,0XFB,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,。。。。。。

------解决思路----------------------
private IEnumerable<string> Get(string filename)
{
    using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
    {
        using (BinaryReader br = new BinaryReader(fs))
        {
            int length = (int)fs.Length;
            while (length > 0)
            {
                byte tempByte = br.ReadByte();
                yield return Convert.ToString(tempByte, 16);
                length--;
            }
        }
    }
}


代码凑活着看吧
  相关解决方案