C〓〓中のピクチャー.BYTE[]とbase 64 stringの転換方法


C〓の中にある     
写真はbyte[]に行ってからbase 64 stringに変換します。

Bitmap bmp = new Bitmap(filepath);
  MemoryStream ms = new MemoryStream();
  bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
  byte[] arr = new byte[ms.Length];
  ms.Position = 0;
  ms.Read(arr, 0, (int)ms.Length);
  ms.Close();
string   pic = Convert.ToBase64String(arr);
base 64 stringからbyte[]へ画像の変換:

byte[] imageBytes = Convert.FromBase64String(pic);
//  MemoryStream  
MemoryStream memoryStream = new MemoryStream(imageBytes, 0, imageBytes.Length);
memoryStream.Write(imageBytes, 0, imageBytes.Length);
//    
Image image = Image.FromStream(memoryStream);
現在のデータベース開発中:写真の保存方法は通常CLOBがあります。
BLOB:預かりbyte[]
一般的にはbyte[]がオススメです。画像は直接byte[]に変換できますので、データベースに保存します。
base 64 stringを使うならば、まだbyte[]からbase 64 stringに変換する必要があります。性能をさらに浪費する。
以上のC〓〓中のピクチャー.BYTE[]とbase 64 stringの転換方法は小編がみんなのすべての内容に分かち合うので、みんなに一つの参考をあげることができることを望んで、みんながよけいに私達を支持することをも望みます。