26 lines
702 B
C#
26 lines
702 B
C#
using System.Drawing;
|
|
using System.IO;
|
|
|
|
namespace ShadowStream.Modules;
|
|
|
|
|
|
public class JasonToString
|
|
{
|
|
public Bitmap Base64StringToBitmap(string base64String)
|
|
{
|
|
byte[] imageBytes = Convert.FromBase64String(base64String);
|
|
using (MemoryStream ms = new MemoryStream(imageBytes))
|
|
{
|
|
return new Bitmap(ms);
|
|
}
|
|
}
|
|
public string BitmapToBase64String(Bitmap bitmap)
|
|
{
|
|
using (MemoryStream ms = new MemoryStream())
|
|
{
|
|
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // Save as PNG to MemoryStream
|
|
byte[] imageBytes = ms.ToArray();
|
|
return Convert.ToBase64String(imageBytes);
|
|
}
|
|
}
|
|
} |