how to add image from resource to html code


hello.

i'm working on program displays output on webbrowser control.

to compose text, create long string concatenating html tags , data need display. sometimes, need add image html output. 

this part of html creation, add image:

html += "<img src=\"image1.png\" width=\"113\" height=\"113\" border=\"0\">";   

the project has existing images in resource folder. how use these resource files image's source pointed resources folder?

thanks.

hi jaybeev,

  welcome msdn forum support.

 

you need load resource stream.

bitmap bmp = new bitmap(   system.reflection.assembly.getentryassembly().     getmanifestresourcestream("myproject.resources.myimage.png"));

if want know resource names in assembly, go with:

string[] = system.reflection.assembly.getentryassembly().   getmanifestresourcenames();  foreach (string 1 in all) {     messagebox.show(one); }

  besides way solve problem, try using rescourcemanager same functionalities.

  can reference image following way:

image myimage = resources.myimage;

if want make copy of image, you'll need following:

bitmap bmp = new bitmap(resources.myimage);

don't forget dispose of bmp when you're done it.  if don't know name of resource image @ compile-time, can use resource manager:

resourcemanager rm = resources.resourcemanager; bitmap myimage = (bitmap)rm.getobject("myimage");

the benefit of resourcemanager can use resources.myimage out of scope, or want dynamically access resources.  additionally, works sounds, config files, etc.

   related information has issued @ load image resources in c#. hope you.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'