我正在尝试使用 Ajax 更新图像 scr,首先在控制器中:
public ActionResult GenerateMIPImage(float pX = 0, float pY = 0, float pZ = 0)
{
FileContentResult result;
...
im.SetViewPlane(new Point3D(pX, pY, pZ), new Vector3D(0, 0, 1), new Vector3D(0, 1, 0));
...
objImage = im.Bitmap(outputSize, PixelFormat.Format24bppRgb, m);
using (var memStream = new MemoryStream())
{
objImage.Save(memStream, ImageFormat.Png);
result = this.File(memStream.GetBuffer(), "image/png");
}
return result;
}
我第一次使用以下方式显示图像:
<img src='<%=Url.Action("GenerateMIPImage")%>' alt="" id="dImage"/>
然后我使用这个 Ajax 来更改其中一个变量:
$('#Zup').click(function () {
pointZF++;
// alert(pointZF);
$.ajax({
url: '/Home/GenerateMIPImage',
type: 'POST',
data: {
pX: pointXF,
pY: pointYF,
pZ: pointZF
},
success: function (data) {
dImage.src = data;
},
error: function () {
}
});
});
图像消失,当它检查它的属性时,我得到:
http://localhost:59601/�PNG
我会很感激你的建议,在此先感谢。