❔ 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
The lookup is used to get the icon of the given item, and drawn to the gui.
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?
If you mean lookup by name, maybe search indexing could be of help?
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)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
7th part c program code is required
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
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
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
this is the result after we've received the info
i just need to fill the icon of the item being sold/bought
Is this WPF or Winforms or something else?
.net winform
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
all the images are in 1 dir
just do
pictureBox.Image = new Bitmap(pathToFile);
You dont need to do any dir searchingokay
so when i build the project
how do i include the dir of images
to the build path*
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
uh, i added them to the ide, not sure about the project
Yeah, so do those show up in the bin output?
not there
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
Dont open the image
Just select it, right click, properties
oh i see the option
that's what i was looking for
Should see something like this
copy to output dir
yep
ty
But build action should be set to content
And you dont need to set the output dir setting
build act is content
Hmm
Alright, change the output to copy if newer then
Might be different for winforms projects than other types of projects
set to copy always 1 time, they're in the out dir
set to copy if newer now
ty for help
Np
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.