loading multiple images for later use

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2008
Posts: 47
Reputation: ctrl-alt-del is an unknown quantity at this point 
Solved Threads: 0
ctrl-alt-del ctrl-alt-del is offline Offline
Light Poster

loading multiple images for later use

 
0
  #1
Mar 5th, 2009
Hi all,

I've been working with C# for some time now, even created a Mastermind-game yesterday to learn some stuff (Mastermind is a very nice training project by the way, I really had fun coming up with solutions)

But while that I ran across a problem that I haven't been able to sort out. In my program I used 3 images to display in a picturebox, a red orb, an orange orb and a red orb. They were there to display wether the user was on the right track in the game.
But I couldn't for the life of me figure out how to get them compiled in the program without actually using them first!
I ended up creating 3 hidden pictureboxes with the images, this worked beautifully and nobody was the wiser, but I would still like to do this the right way (and learn by doing so)

Now I have found out about the resources thing (I'm using Visual Studio 2008 by the way) and this seemed like just what I needed.... But how the heck do I access those files after importing them?!

I've found this link from microsoft:
http://support.microsoft.com/kb/319292
which seems to address my problem, but it seems incredibly more complicated then it should be in my eyes.


So my question is this:
I have multiple images I want to address but can't use them in an initial load, so how do I compile them in with the program, and how do I access them afterwards?

Thanks for reading and helping all!


(P.S. Am I just being blind or has the search-function vanished on the forum?)
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: loading multiple images for later use

 
0
  #2
Mar 5th, 2009
Long as you add them as resources you can use them
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 47
Reputation: ctrl-alt-del is an unknown quantity at this point 
Solved Threads: 0
ctrl-alt-del ctrl-alt-del is offline Offline
Light Poster

Re: loading multiple images for later use

 
0
  #3
Mar 5th, 2009
Thanks for the reply.

But how do I address them? (Name is es_red_orb.png in the resourceslist)
I've tried:
this.es_red_orb.png
this.es_red_orb
Mastermind.es_red_orb.png
Mastermind.es_red_orb

and every other conceivable way!

Also, i've set the properties of the files I need to embedded resource (MS-site told me to)

Again, thanks for replying!
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 44
Reputation: hieuuk is an unknown quantity at this point 
Solved Threads: 4
hieuuk hieuuk is offline Offline
Light Poster

Re: loading multiple images for later use

 
0
  #4
Mar 5th, 2009
Hi, now there are 2 ways to do thing like that.
First do it like LizR said. So you could import it into resources. Then you could Access it by: Properties.Resources.ImageName

Second, you could load all the picture in the bitmap variables. By bitmap a = new bitmap(filepath); Then change the image picture point to this bitmap. You could check the code in one of my tutorial: http://www.hieu.co.uk/post/2008/12/0...lide-show.aspx
.Net Developer - 3D Game Designer
My Portfolio/Blog: http://www.hieu.co.uk
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 47
Reputation: ctrl-alt-del is an unknown quantity at this point 
Solved Threads: 0
ctrl-alt-del ctrl-alt-del is offline Offline
Light Poster

Re: loading multiple images for later use

 
0
  #5
Mar 5th, 2009
FANTASTIC!!

The Properties.Resources.<imagename> worked splendid!

Thank you very much!

(Will be checking out some of those tuts as well I think )

Both of you thanks for your time and answers!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC