用C#显示图像 [英] Image Display in c#

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

问题描述

我的数据库中具有图像数据类型的流字节形式的图像数据,我想显示该图像,请帮助我该怎么做?

实际上,我正在使用基于Web的应用程序,并且希望将图像显示为

ex:
的背景.

I have data of an image in the form of streambytes in my database with image data type, i want to display the image, please help how can i do this?

Actually iam using the Web based application and want to show the image as a background to a

ex:

<table><tbody><tr><td style="background-image:removed(''the image'');"></td></tr></tbody></table>



抱歉,没有给出完整的问题



sorry for not giving the complete problem

推荐答案

This[^] link provides some information that might help you.


搜索
Search Google[^], and you''ll get a ton of answers.

Regards
Espen Harlinn


有点模糊,我会尝试猜测:

将数据读入缓冲区并创建MemoryStream
A bit vague, I''ll attempt a guess:

Read the data into a buffer and create a MemoryStream
byte[] buffer; // read data to this. omitted.
MemoryStream stream = new MemoryStream(buffer);



从流创建位图



Create a Bitmap from the stream

Bitmap bitmap = new Bitmap(stream);



在窗体的Paint事件处理程序中,绘制图像如下:



In the form''s Paint event handler, draw the image thus:

private void Form1_Paint(object sender, PaintEventArgs e)
{
    e.Graphics.DrawImage(bitmap, x, y);
}



x和y是绘制图像的位置的坐标.
(在MSDN中查找每种方法以获取详细信息)



x and y are the coordinates of the place where you draw the image.
(look up each method in MSDN for details)


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

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