通过IMG号码 [英] Pass IMG Number

查看:84
本文介绍了通过IMG号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个C#(aspx或asmx),我传递一个字符串,它返回格式化为图像的字符串

。这将是......


< img src =" http://www.domain.com/sample/123456">

....其中123456将呈现为图形图像。


你能指点我一个例子/样本吗?


_______________________________________________

Thom Little www.tlanet.net Thom Little Associates,Ltd。

解决方案

Image img = Image.FromFile(" .\\blank.jpg");

图形g = Graphics.FromImage(img);

尝试

{

g.DrawString(" Any string" ,new font(" Arial",14),new

SolidBrush(Color.Black),0,0);

this.pictureBox1.Image = img; < br $>
}

终于

{

if(g!= null)

g .Dispose();

}


返回;

这个概念类似于你是在Windows窗体或ASP.Net(因为你好像b $ b似乎想要的)。只需从磁盘加载一些空白图像,使用

Graphics对象写入它,然后将其保存回磁盘或将其序列化为一个字节

流到客户端,等等


-

~~~~~~~~~~~

Ben Rush
< a rel =nofollowhref =http://www.ben-rush.net/blogtarget =_ blank> http://www.ben-rush.net/blog



Thom Little < th ** @ tlanet.netwrote in message

news:eH ************** @ TK2MSFTNGP05.phx.gbl ...
< blockquote class =post_quotes>
>我需要一个C#(aspx或asmx),我传递一个字符串,它返回格式化为图像的字符串

。这将是......


< img src =" http://www.domain.com/sample/123456">

...其中123456将呈现为图形图像。


你能指点我一个例子/样本吗?


_______________________________________________

Thom Little www.tlanet.net Thom Little Associates,Ltd。



感谢您的帮助。


我有的方面尚未看到的是在调用页面

和处理页面之间传递数据。很明显,这个电话看起来很简陋......


< img src =" http://www.domain.com/tool/test.aspx?123456&\">> >

....其中,传统的123456显示为正常的Request.QueryString?


如何在C#处理中定义位图(图形)响应页面?


有没有可以指点我的参考,以便我不浪费你的时间?


_______________________________________________
Thom Little www.tlanet.net Thom Little Associates,Ltd。 />


有很多不同的方法让它工作。


您可以简单地使用您创建的这个新位图(使用我给的代码

你),将它保存到磁盘,并设置一些ASP.net图像的图像url属性

控制指向图像的路径你保存在磁盘上,或者你可以

甚至创建一个自定义将处理图像请求的httphandler和

将提供

图像(内容类型等)所需的标题,位等返回给浏览器


就网上的样本而言,我不确定。我现在没有

的带宽来写一个比我已经做过的更多的样本

也没有真正寻找更深入的一个。


Thom Little < th ** @ tlanet.netwrote in message

news:13 ************* @ news.supernews.com ...


感谢您的帮助。


我还没有看到的方面是在调用页面之间传递数据

和处理页面。很明显,这个电话看起来很简陋......


< img src =" http://www.domain.com/tool/test.aspx?123456&\">> >

...其中只有123456作为正常的Request.QueryString显示?


如何在C#处理页面中定义位图(图形)响应?


有没有可以指点我的参考,这样我就不会浪费你的

时间?


_______________________________________________

Thom Little www.tlanet.net Thom Little Associates,Ltd。



I need a C# (aspx or asmx) that I pass a string and it returns the string
formatted as an image. It would be something like ...

<img src="http://www.domain.com/sample/123456">

.... where 123456 would be rendered as a graphics image.

Can you point me towards an an example/sample?

_______________________________________________
Thom Little www.tlanet.net Thom Little Associates, Ltd.

解决方案

Image img = Image.FromFile(".\\blank.jpg");
Graphics g = Graphics.FromImage(img);
try
{
g.DrawString("Any string", new Font("Arial", 14), new
SolidBrush(Color.Black), 0, 0);
this.pictureBox1.Image = img;
}
finally
{
if (g != null)
g.Dispose();
}

return;
The concept is similar whether you''re on windows forms or ASP.Net (as you
seem to desire). Simply load some blank image from disk, write onto it using
the Graphics object, and then save it back to disk or serialize it as a byte
stream to the client, etc.

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog


"Thom Little" <th**@tlanet.netwrote in message
news:eH**************@TK2MSFTNGP05.phx.gbl...

>I need a C# (aspx or asmx) that I pass a string and it returns the string
formatted as an image. It would be something like ...

<img src="http://www.domain.com/sample/123456">

... where 123456 would be rendered as a graphics image.

Can you point me towards an an example/sample?

_______________________________________________
Thom Little www.tlanet.net Thom Little Associates, Ltd.



Thank you for the help.

The aspect I have yet to see is passing the data between the calling page
and the processing page. Clearly the call looks lie ...

<img src="http://www.domain.com/tool/test.aspx?123456">

.... where apparetnly 123456 shows up as a normal Request.QueryString?

How is the bitmap (graphics) response defined in the C# processing page?

Is there a reference you could point me at so that I don''t waste your time?

_______________________________________________
Thom Little www.tlanet.net Thom Little Associates, Ltd.


There are a myriad of different ways to get it working.

You could simply take this new bitmap you''ve created (using the code I gave
you), save it to disk, and set the image url property of some ASP.net image
control to point to the path of the image you saved on disk, or you could
even create a custom httphandler that will handle a request for an image and
return back to the browser the headers, bits etc. necessary to supply an
image (content-type, etc)

As far as a sample on the net, I''m not sure of one. I don''t have the
bandwidth right now to write up more of a sample than the one I already did
nor really look for a more in depth one.

"Thom Little" <th**@tlanet.netwrote in message
news:13*************@news.supernews.com...

Thank you for the help.

The aspect I have yet to see is passing the data between the calling page
and the processing page. Clearly the call looks lie ...

<img src="http://www.domain.com/tool/test.aspx?123456">

... where apparetnly 123456 shows up as a normal Request.QueryString?

How is the bitmap (graphics) response defined in the C# processing page?

Is there a reference you could point me at so that I don''t waste your
time?

_______________________________________________
Thom Little www.tlanet.net Thom Little Associates, Ltd.



这篇关于通过IMG号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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