Jump to content
  • Advertisement
Sign in to follow this  
Selacius

[.net] Displaying All Images In A Folder + C#

This topic is 4145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Just go through each file in the folder and load it into a pictureBox.

DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] files = di.GetFiles("*.*");

foreach (FileInfo file in files)
{
pictureBox1.Image = Bitmap.FromFile(file.FullName);
}


Share this post


Link to post
Share on other sites
Quote:
Original post by Headkaze
Just go through each file in the folder and load it into a pictureBox.

DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] files = di.GetFiles("*.*");

foreach (FileInfo file in files)
{
pictureBox1.Image = Bitmap.FromFile(file.FullName);
}


don't even need the "*.*" file specifier, just call GetFiles();

Share this post


Link to post
Share on other sites
Thats perfect, but what I am trying to do is well. Display all the images as a graphic (combining them all), making this graphic the image of a picturebox, then having a onmousedown command which depending on the image selected, will change the image on the map. Basically its a continuation of my map editor program I've asked questions for before. So now that I have the code to display the images, I need to think of a way to give each image its own id value. Or somehow figure out how say I select the image located at 1,2 and there are 4 images per row, then the image I selected would be the 5th image in the folder, and it would select the 5th image and display it for me.
Get my drift?

Share this post


Link to post
Share on other sites
That's a whole separate question.

You're saying that you want to have a big map view, and be able to click on one of the "tiles" and have it dig down to the higher res image?

If it were me, I would derive a new control from the PictureBox, which allows for the adding/compositing of images, and resolves mouseclicks into image selection.

Share this post


Link to post
Share on other sites
Kinda but not really. I've already gotten a system in place that displays my set of tiles (the map) in a picturebox. And an event that when I click on a specific tile in that picture box it will fill in a group of text boxes with the relevant data for that tile. What I want to do now, is have a seperate picturebox full of all the tiles available for that map (the tiles are separated into their component locations, example all the tiles which can be used for world maps are in a world folder). And when I click on a tile in the new picturebox, it will replace the tile already selected from the map. Basically I need to figure out how to give the tiles in the picturebox (the 2nd one with the images from the folder), a unique ID so that when I click on the image, it can figure out which tile exactly was clicked. I think I could potentially do it with a 2 dimensional array. Probably would be the easiest.

Share this post


Link to post
Share on other sites
Sounds like you would like to make a sorta sprite sheet of all your sprites, then when you click it, it would choose which tile you clicked and give you the relevent information. Well, actually, I would personally put all my tiles into 1 texture/bitmap anyways and then just show that.

http://www.ziggyware.com/weblinks.php?cat_id=12

That link is to SpriteSheetTool, it will let you choose which tiles to add, make a bounding box for ya if ya want, then export out 1 bitmap of all your tiles and a file describing font name, bounding box (if you chose to use it), tile location in the bitmap, etc.

If you use that program, you can just load up the bitmap. Then the text file and use the data from it to find out which tile was clicked.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!