zoukankan      html  css  js  c++  java
  • 二进制流的操作收集

    一:转换为byte[]

    1.将Bitmap转换为二进制流

     public static byte[] Bitmap2Byte(Bitmap bitmap)
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    bitmap.Save(stream, ImageFormat.Jpeg);
                    byte[] data = new byte[stream.Length];
                    stream.Seek(0, SeekOrigin.Begin);
                    stream.Read(data, 0, Convert.ToInt32(stream.Length));
                    return data;
                }
            }

    二:将byte[]转换为其他

    1.将byte[]转换为字符串

    string res = System.Text.Encoding.Default.GetString(byteArr);
  • 相关阅读:
    HDU 1058
    Codeforces 349C
    HDU 2602
    HDU 2571
    HDU 2955
    HDU 2084
    HDU 1003
    HDU 1506 & 1505
    POJ 1854
    HDU 2095
  • 原文地址:https://www.cnblogs.com/zhuyapeng/p/5702966.html
Copyright © 2011-2022 走看看