分类 图片 下的文章

Bitmap 转 base64



    public string BitmapToBase64(Bitmap bitmap)
    {
        string base64str = "";
        using (MemoryStream ms1 = new MemoryStream())
        {
            bitmap.Save(ms1, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] arr1 = new byte[ms1.Length];
            ms1.Position = 0;
            ms1.Read(arr1, 0, (int)ms1.Length);
            ms1.Close();
            base64str = Convert.ToBase64String(arr1);
        }
        return base64str;
    }