943,715 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 2070
  • C# RSS
Mar 5th, 2009
0

loading multiple images for later use

Expand Post »
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?)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
ctrl-alt-del is offline Offline
65 posts
since Jul 2008
Mar 5th, 2009
0

Re: loading multiple images for later use

Long as you add them as resources you can use them
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Mar 5th, 2009
0

Re: loading multiple images for later use

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!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
ctrl-alt-del is offline Offline
65 posts
since Jul 2008
Mar 5th, 2009
0

Re: loading multiple images for later use

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
Reputation Points: 11
Solved Threads: 4
Light Poster
hieuuk is offline Offline
44 posts
since Nov 2008
Mar 5th, 2009
0

Re: loading multiple images for later use

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!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
ctrl-alt-del is offline Offline
65 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Lock Folder in C#
Next Thread in C# Forum Timeline: FileNet P8 4.0 .NET API





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC