I have two images in the form of (somewhat):
我有两张(有点)的图片:
<img src="data: base64, OIJQWEFOIJQWEFOIJQWEF..." />
<img src="data: base64, OIJQWEFOIJQWEFOIJQWEF..." />
I have no choice in the matter, these images are always going to be set as base64 data.
我在这个问题上没有选择,这些图像总是被设置为base64数据。
If I were to POST these using some client side magic, how can I convert the strings to actual images?
如果我使用客户端魔法发布这些,我如何将字符串转换成实际的图像?
public ActionResult Combine(string imageA, string imageB)
{
// imageA and imageB would be the strings.
return View();
}
1 个解决方案
#1
2
Use Convert.FromBase64String
method.
This method:
使用转换。FromBase64String方法。这个方法:
Converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array.
将指定的字符串(将二进制数据编码为base-64位数字)转换为等效的8位无符号整数数组。
Then you can use WebImage
class from System.Web.Helpers.dll
assembly to convert byte array to actual image and perform some manipulations on it.
然后可以使用system . web . helper类中的WebImage类。将字节数组转换为实际图像并对其执行一些操作的dll程序集。
#1
2
Use Convert.FromBase64String
method.
This method:
使用转换。FromBase64String方法。这个方法:
Converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array.
将指定的字符串(将二进制数据编码为base-64位数字)转换为等效的8位无符号整数数组。
Then you can use WebImage
class from System.Web.Helpers.dll
assembly to convert byte array to actual image and perform some manipulations on it.
然后可以使用system . web . helper类中的WebImage类。将字节数组转换为实际图像并对其执行一些操作的dll程序集。