[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1599
  • Last Modified:

c# windows CE6 - load bitmap from resource

I am using windows CE 6. VS 2005.
I would like to load a bitmap from a resource..

So instead of
picture1.Image = new bitmap(filename);

...?
0
qicblue
Asked:
qicblue
  • 4
  • 3
1 Solution
 
Jaime OlivaresCommented:
You need something like this:
Assembly assem = Assembly.GetExecutingAssembly();
Stream stream = assem.GetManifestResourceStream("ResourceyourApp.yourimage.jpg");
picture1.Image = Image.FromStream(stream); 

Open in new window

Sometimes it is tricky to determine the name of the resource. Use GetManifestResourceNames to be sure about the proper name.
0
 
qicblueAuthor Commented:
That code won't run. I should have mentioned Im running .NET 2.0
0
 
Jaime OlivaresCommented:
"won't run" won't help. Any error message?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
qicblueAuthor Commented:
System.Drawing.Image does not contain a definition for "FromStream"
0
 
Jaime OlivaresCommented:
try with the following:
Assembly assem = Assembly.GetExecutingAssembly();
Stream stream = assem.GetManifestResourceStream("ResourceyourApp.yourimage.jpg");
picture1.Image = new Bitmap(stream);

Open in new window

0
 
qicblueAuthor Commented:
small correction..

assem.GetManifestResourceStream("ResourceyourApp.subdirectory.yourimage.jpg");
0
 
Jaime OlivaresCommented:
That depends on your specific project
That's why I suggested to verify with GetManifestResourceNames first
Some projects can have bitmaps on their root folder
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now