C
C#2y ago
boom

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