« DWG Export Filename | Main | Bottom Face of a Wall »

August 14, 2009

Comments

Hi Jeremy,

Just though i would provide an alternaitve to retrieving a resource bitmap:

System.Windows.Media.Imaging.BitmapSource GetEmbeddedImage(string Name)
{
try
{
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
Stream imgStream = a.GetManifestResourceStream(Name);
return System.Windows.Media.Imaging.BitmapFrame.Create(imgStream);
}
catch
{
return null;
}
}

forgot to mention that this retrieves an embedded resource.. i.e. has it's build action set to "Embedded Resource"

Dear Krispy,

Thank you very much for the suggestion! It is ever so nice to receive a comment making a suggestion instead of asking a question every now and then!

Cheers, Jeremy.

no problem, just another note, the "Name" argument is the fully qualified name, i.e. includes the application namespace etc.
for example, my applications namespace is "MyNamespace" and i have an image "MyImage.png" you would call the function like this:
MyPushButton.LargeImage = GetEmebeddedImage("MyNamespace.MyImage.png");

Dear Krispy,

Thank you very much once again for additional hint, and yet another non-question!

I used your ideas to create a new post:

http://thebuildingcoder.typepad.com/blog/2009/11/ribbon-embed-image.html

Cheers, Jeremy.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource