gif作为嵌入式资源 [英] gif as embedded resource

查看:134
本文介绍了gif作为嵌入式资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




从我的应用程序中检索图像时遇到一些问题。

这是我的代码:


流imgStream = null;

汇编a = Assembly.GetExecutingAssembly();

imgStream = a.GetManifestResourceStream(" SW_Audit.img_ok.gif");


PBStep1.Image =新的位图(imgStream);


之后我通过这样做来嵌入这个图像:

Project-property-resources -add resource-add现有资源

- " img_ok.gif"

我的应用程序命名空间是SW_Audit。


所以我做错了什么?


非常感谢,


Al。

Hi,

I have some problem to retrieve an image from my application.
Here is my code :

Stream imgStream = null;
Assembly a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream("SW_Audit.img_ok.gif") ;

PBStep1.Image = new Bitmap(imgStream);

before i embedded this image by doing :
Project-property-resources -add resource-add existing resource
-"img_ok.gif"

My application namespace is "SW_Audit".

so what have i done wrong ?

thanks a lot,

Al.

推荐答案

8月13日下午3:48,Alain R. < noem ... @nospam.comwrote:
On Aug 13, 3:48 pm, "Alain R." <noem...@nospam.comwrote:

从我的应用程序中检索图像时遇到一些问题。

这是我的代码:


流imgStream = null;

汇编a = Assembly.GetExecutingAssembly();

imgStream = a.GetManifestResourceStream( " SW_Audit.img_ok.gif");


PBStep1.Image =新的位图(imgStream);


在我嵌入此图片之前做:

项目 - 属性 - 资源 - 添加资源 - 添加现有资源

- " img_ok.gif"


我的应用程序命名空间是SW_Audit。


所以我做错了什么?
I have some problem to retrieve an image from my application.
Here is my code :

Stream imgStream = null;
Assembly a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream("SW_Audit.img_ok.gif") ;

PBStep1.Image = new Bitmap(imgStream);

before i embedded this image by doing :
Project-property-resources -add resource-add existing resource
-"img_ok.gif"

My application namespace is "SW_Audit".

so what have i done wrong ?



很难说:


1)究竟发生了什么?

2)是imgStream null?

3)您是否使用过ildasm / reflector /其他任何东西来查看什么清单

资源实际存在?


Jon

Hard to say:

1) What exactly is happening?
2) Is imgStream null?
3) Have you used ildasm/reflector/anything else to see what manifest
resources are actually present?

Jon


是imgStrem仍等于NULL :-(


Jon Skeet [C#MVP]写道:
Yes imgStrem is still equal to NULL :-(

Jon Skeet [C# MVP] wrote:

8月13日下午3:48,Alain R.< noem ... @ nospam.comwrote:
On Aug 13, 3:48 pm, "Alain R." <noem...@nospam.comwrote:

>我从应用程序中检索图像时遇到了一些问题。
这是我的代码:

Stream imgStream = null;
程序集a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream(" SW_Audit.img_ok.gif");

PBStep1.Image = new Bitmap(imgStream);

之前我通过以下方式嵌入此图像:
项目属性 - 资源 - 添加资源 - 添加现有资源
- " ; img_ok.gif"

我的应用程序命名空间是SW_Audit。

那么我做错了什么?
>I have some problem to retrieve an image from my application.
Here is my code :

Stream imgStream = null;
Assembly a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream("SW_Audit.img_ok.gif") ;

PBStep1.Image = new Bitmap(imgStream);

before i embedded this image by doing :
Project-property-resources -add resource-add existing resource
-"img_ok.gif"

My application namespace is "SW_Audit".

so what have i done wrong ?



很难说:


1)究竟发生了什么?

2)是imgStream null?

3)您是否使用过ildasm / reflector /其他任何东西来查看什么清单

资源实际存在?


Jon


Hard to say:

1) What exactly is happening?
2) Is imgStream null?
3) Have you used ildasm/reflector/anything else to see what manifest
resources are actually present?

Jon





前一段时间我发布了一些代码,请看看档案。


从您的代码我认为问题是因为资源名称shoudl

在前面有命名空间。因此,如果图像被命名为Image1.gif,则名称为
,资源为mynamespace.image1.gif

" Alain R." < no ***** @ nospam.com写信息

新闻:eZ **************** @ TK2MSFTNGP04.phx.gbl ...
Hi,

A time ago I posted some code for exactly this, take a look at the archives.

From your code I think that the problem is cause the resourse name shoudl
have the namespace in front. So if the image is named Image1.gif the name fo
the resource is mynamespace.image1.gif

"Alain R." <no*****@nospam.comwrote in message
news:eZ****************@TK2MSFTNGP04.phx.gbl...




从我的应用程序中检索图像时遇到一些问题。

这是我的代码:


流imgStream = null;

汇编a = Assembly.GetExecutingAssembly();

imgStream = a .GetManifestResourceStream(" SW_Audit.img_ok.gif");

PBStep1.Image = new Bitmap(imgStream);


我嵌入之前这个图像通过这样做:

项目 - 属性 - 资源 - 添加资源 - 添加现有资源 - >

" img_ok.gif"


我的应用程序命名空间是SW_Audit。


所以我做错了什么?


非常感谢,


Al。
Hi,

I have some problem to retrieve an image from my application.
Here is my code :

Stream imgStream = null;
Assembly a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream("SW_Audit.img_ok.gif") ;

PBStep1.Image = new Bitmap(imgStream);

before i embedded this image by doing :
Project-property-resources -add resource-add existing resource ->
"img_ok.gif"

My application namespace is "SW_Audit".

so what have i done wrong ?

thanks a lot,

Al.



这篇关于gif作为嵌入式资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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