public static FPData StrToFPData(string strArray) { FPData fPData = new FPData(); int num = 0; string[] array = FPArray.SplitString(strArray); for (int i = 0; i < array.Length; i++) { string text2 = fPData[num] = array[i]; num++; } return(fPData); }
public static string Base64ToImg(string base64str, string filename) { try { string directoryName = Path.GetDirectoryName(filename); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } if (base64str.StartsWith("data:image/")) { base64str = FPArray.SplitString(base64str, 2)[1]; } byte[] buffer = Convert.FromBase64String(base64str); MemoryStream memoryStream = new MemoryStream(buffer); Bitmap bitmap = new Bitmap(memoryStream); if (File.Exists(filename)) { File.Delete(filename); } ImageFormat format = ImageFormat.Png; if (base64str.StartsWith("data:image/jpeg")) { format = ImageFormat.Jpeg; } else if (base64str.StartsWith("data:image/gif")) { format = ImageFormat.Gif; } bitmap.Save(filename, format); memoryStream.Close(); return(""); } catch (Exception ex) { return("转换失败:" + ex.Message); } }