可变二进制最大图像
我将图像存储在数据库的 varbinary(max)
字段中。
我尝试在我的表单上显示图像。我尝试了很多不同的方法,但没有显示出来。
这是我的代码:
//I am adding an image in my form
Ext.Net.Image image = new Ext.Net.Image();
image.ID = "imgShow";
FormLayout1.Items.Add(image);
byte[] buffer = q.TckLogo;
MemoryStream memStream = new MemoryStream();
memStream.Write(buffer, 0, buffer.Length);
// it is giving error because of FromStream
image.items.Add(Image.FromStream(memStream));
如何在表单中显示我的图像?
我正在使用 Ext.Net (Coolite)。
I am storing images in database in a varbinary(max)
field.
I am try to show an image on my form. I've tried many different ways but it did not show it.
This is my Code:
//I am adding an image in my form
Ext.Net.Image image = new Ext.Net.Image();
image.ID = "imgShow";
FormLayout1.Items.Add(image);
byte[] buffer = q.TckLogo;
MemoryStream memStream = new MemoryStream();
memStream.Write(buffer, 0, buffer.Length);
// it is giving error because of FromStream
image.items.Add(Image.FromStream(memStream));
How can I display my image in my form?
I am using Ext.Net (Coolite).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Web 应用程序中,图像控件有一个
ImageUrl
属性,指向某个将返回图像的服务器端脚本。我不熟悉 Ext.Net.Image ,但我想您需要使用 http 处理程序来提供图像:然后让您的图像控制指向此通用处理程序:
In a web application, image controls have an
ImageUrl
property pointing to some server side script which will return the image. I am not familiar withExt.Net.Image
but I suppose that you need to use a http handler to serve the image:and then have your image control point to this generic handler:
我不清楚 Ext.Net 是什么,或者您为什么使用它,但 FromStream 用法表明您对
System.Drawing.Image.FromStream
;但是,该事件没有实际意义,因为您不应使用 Web 应用程序中的 System.Drawing。如果您只是尝试将图像返回给客户端,那么在许多情况下您根本不需要处理它 - 只需将 BLOB 通过网络发送给客户端即可。不相关,但正如 Jon 指出的那样,您还尝试从 MemoryStream 的末尾读取。
It isn't clear to me what Ext.Net is here, or why you are using it, but the FromStream usage suggests you are confusing is with
System.Drawing.Image.FromStream
; however, event that is moot as you shouldn't use System.Drawing from a web app. If you are just trying to return an image to the client, you shouldn't have to process it at all in many cases - just throw the BLOB down the wire to the client.Unrelated, but as Jon notes you're also trying to read from the end of a MemoryStream.