ImageList for high-resolution images??

  • Thread starter Thread starter Vaughn
  • Start date Start date
V

Vaughn

Is there some way I can save images (bigger than 16x16 pixels) so they don't
reside as physical files on the HDD? I'm working on a screensaver but I want
to include all my images in my executable instead of having them reside in
the hard disk.
Since I use a pictureBox and the image comes from a file at runtime (eg.
pictureBox1.Image = Image.FromFile (path); ), more computer-literate users
can delete the image, copy another image with the same name, and view the
new image. And I want to avoid that.

Thanks,
Vaughn
 
You can embed images as resources in your assembly.

/res:ImageFile.bmp

Then you can grab the resource stream using
Assembly.GetManifestResourceStream(...)
and reconstruct your bitmaps in memory.
 
Hi,

Include the images in the project. Set the "Build action" (file property) to
"Embedded resource" and use "Assembly.GetManifestResourceStream()" to fetch
the image runtime.

Erik
 
Thanks for the reply.
I have framework v1.0 . Would it work with this version also? Since this is
the first time I work with images, I'm not sure how to embed the image into
my project as resources. I also don't know how to set the Build Action to
"Embedded resource".

Thanks,
Vaughn
 
It will work with 1.0 but I strongly reccommend that you upgrade to 1.1 as
soon as possible.

Add the bitmap object to your solution and then select "Build
action"="Embedded Resource" in the properties pane.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com
 
Thanks for the info. I was able to add it.
But once I add it, how can I access it? The name of the image in the
solution is test.jpg and I want to use it as the image for a pictureBox
control (eg. pictureBox1.Image = test.jpg;).

Thanks again,
Vaughn
 
Back
Top