C
C#3y ago
alex

❔ 21,000 Images, Best way to implement a lookup method?

I have 21,000 + images that have to be available for lookup. The images are formatted [item_id].png, and in total is 43mb on disk. Should the best method be to have a lookup that sifts through the directory and string match, or to load them all in memory in a suitable datatype
35 Replies
alex
alexOP3y ago
The lookup is used to get the icon of the given item, and drawn to the gui.
mikernet
mikernet3y ago
Not entirely sure what you are asking or what you mean by "available for lookup" Are you doing something other than showing the image when the item is shown? If so, can you clarify what that is?
Buddy
Buddy3y ago
If you mean lookup by name, maybe search indexing could be of help?
mikernet
mikernet3y ago
Searching the dir by name is fast, the file system already has a name index As long as you are searching by exact name or prefix* and not suffix Use Directory.EnumerateFiles() with a search pattern if you want to match with a wildcard search like filename and possibly get back multiple results, or use File.Exists() if its an exact match search and you're going to be passing the path to something else that opens and loads the file, or just try to open it if you need to open a stream to it right away to show it (and handle the FileNotFoundException in case it wasn't found)
alex
alexOP3y ago
in better context, I have a "market" setup, and the offer panel has an icon, this icon is set by the name/id of the item being sold/bought. there is a total of 26,535 32x32 pngs, would your method above still be suited best? i was asking if i should directory search, then load the image, or load all the images into a suited datatype to iterate and search over instead
callmeefrienddd
7th part c program code is required
mikernet
mikernet3y ago
What type of application is this and how are you showing the image I think you're in the wrong area, this is someone else's help thread Post your own help thread in #help or post in the #help-0 channel
alex
alexOP3y ago
this is a runescape "client", but not client.. it receives data from a Runelite plugin, Runelite being a runescape client that allows plugins to run custom in java. I've setup a socket to send and receive certain bits of info, one of these being the Market Offers, or Grand Exchange for this instance the response of the market offers if (item_id, quantity, sold, price, spent) item_id is used to reference the icon needed, [item_id].png. once the item_id is parsed, i now need to figure out which is the best solution this method occurs 1 time every 10 seconds
alex
alexOP3y ago
alex
alexOP3y ago
to the left of every panel, is a 32,32 picturebox, that is set to the image of the item_id retaining in the market offer
alex
alexOP3y ago
this is the result after we've received the info
alex
alexOP3y ago
i just need to fill the icon of the item being sold/bought
mikernet
mikernet3y ago
Is this WPF or Winforms or something else?
alex
alexOP3y ago
.net winform
mikernet
mikernet3y ago
Not sure where the "searching directory" comes into play here. I assume you're just going to set the image path on a picturebox or whatever
alex
alexOP3y ago
all the images are in 1 dir
mikernet
mikernet3y ago
just do pictureBox.Image = new Bitmap(pathToFile); You dont need to do any dir searching
alex
alexOP3y ago
okay so when i build the project how do i include the dir of images to the build path*
mikernet
mikernet3y ago
Did you add them to the project? The default behavior should be correct, which is setting the build action to content Which will include them in the output
alex
alexOP3y ago
uh, i added them to the ide, not sure about the project
alex
alexOP3y ago
mikernet
mikernet3y ago
Yeah, so do those show up in the bin output?
alex
alexOP3y ago
not there
mikernet
mikernet3y ago
Click on one of the image files in the solution explorer And show me what the properties window shows If the property window isnt open then right click and select properties
alex
alexOP3y ago
mikernet
mikernet3y ago
Dont open the image Just select it, right click, properties
alex
alexOP3y ago
oh i see the option that's what i was looking for
mikernet
mikernet3y ago
Should see something like this
alex
alexOP3y ago
copy to output dir yep ty
mikernet
mikernet3y ago
But build action should be set to content And you dont need to set the output dir setting
alex
alexOP3y ago
build act is content
mikernet
mikernet3y ago
Hmm Alright, change the output to copy if newer then Might be different for winforms projects than other types of projects
alex
alexOP3y ago
set to copy always 1 time, they're in the out dir set to copy if newer now ty for help
mikernet
mikernet3y ago
Np
Accord
Accord3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?