在弹出窗口中显示图像 [英] showing image in pop up

查看:88
本文介绍了在弹出窗口中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字节变量

I have a byte variable

Public img As Byte() = Nothing


我正在从sql server数据库中获取图像(二进制数据)

我以这种方式从javascript
通过querystring传递它


and i am taking image (binary data) in this from sql server database

I am passing it through querystring in this way from javascript

var img = ''<%= img %>'';
window.showModalDialog("cli_image.aspx?Client_img=" + img + " ", '''', WinSettings);


并以这种方式重新绑起来


and retieving it in this way

Dim bt As Byte()=New System.Text.ASCIIEncoding().GetBytes(Context.Request.QueryString("Client_img"))
Response.BinaryWrite(bt)


但它只显示system.byte []它应显示image


but it is showing onle system.byte[] it should show image

推荐答案

示例:
int width,height;//设置一些宽度高度
DataRow dr;////假设您在dr.
中有来自db的数据 System.Drawing.Image img =(System.Drawing.Image)imgConverter.ConvertFrom(((Byte [])dr ["img_person"]);
位图bmp =新位图(img,新大小(宽度,高度));
Response.ContentType ="image/GIF";//gif或其他格式
bmp.Save(Response.OutputStream,ImageFormat.Gif);//gif或其他格式

在弹出窗口的page_load事件中执行此操作.请记住,这是响应内容.因此,您将只有一幅图像的整个页面.如果您要在页面中显示多张图像,则无法按原样工作.您可能需要做比较.方式.
example:
int width, height;//set some widht & height
DataRow dr;//assume you have data from db in dr.
System.Drawing.Image img = (System.Drawing.Image)imgConverter.ConvertFrom((Byte[])dr["img_person"]);
Bitmap bmp = new Bitmap(img, new Size(width, height));
Response.ContentType = "image/GIF";//gif or other format
bmp.Save(Response.OutputStream, ImageFormat.Gif);//gif or other format

do this in popup''s page_load event. Remember this is Response content. So you will have whole page with just one image. If you would like to display multiple images in a page this does not work as is. You may have to do diff. way.


这篇关于在弹出窗口中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆