Staredit Network > Forums > Modding Assistance > Topic: How does SC load images?
How does SC load images?
Jun 19 2015, 11:10 pm
By: iCCup.xboi209  

Jun 19 2015, 11:10 pm iCCup.xboi209 Post #1



Can someone tell me how SC loads images from the mpq files? Does it use one of the functions from Storm.dll? Which address is function to load the image is at?



None.

Jun 21 2015, 4:57 pm Neiv Post #2



Do you mean pcx or images.dat/grp images? Pcx images are loaded using storm function #321, SBmpDecodeImage.

Images.dat iscript.bin, and any .lo, and .grp files are loaded to the memory by function located at 004D7180 (1.16.1 address, no arguments, returns nothing), which is called once during the loading screen before main menu. The .grps are not decoded there though, decoding is done every time an image has to be drawn on the screen.



None.

Jun 21 2015, 7:15 pm iCCup.xboi209 Post #3



Oh i just realized i wasn't clear on my first post. I meant the pcx graphics. I don't think I'm looking for the decoding function, something more like loading the file into memory like Load(data.mpq, "Dir1/Dir2/file.pcx)




Jun 21 2015, 8:12 pm Neiv Post #4



Well, all of the files (maybe not .smks) are opened through combination of SFileOpenFileEx and SFileReadFile, is that what you need?
There is an function located at 004D2D10 which does the tedious work and returns a pointer to the file, but it's not used for all pcx files while being used for other unrelated data files:
Quote
004D2D10 = ReadMpqFile(), arg 1 char *chk_path, arg 2 unk, arg 3 unk, arg 4 char *source_file, arg 5 source_line, ecx open_mode, eax dword *out_filesize (Returns void *file)

Some of the pcx files (at least ofire.pcx and other remapping palettes) are just read with the function above and decoded with SBmpDecodeImage, but there is also Storm function #323 SBmpLoadImage, which is used at least when loading the player color pcx.
Can't really tell how it differs - it seems to do both mpq reading and decoding at once, but requires a buffer large enought to fit the uncompressed image, so it is only used when engine knows the image size beforehand?

Also menu images use function #325 SBmpAllocLoadImage, which seems to be the "best" pcx loading function, doing mpq access, memory allocation and and decoding - can't tell what parameters to pass there though.

All of those ways call SFile functions internally though to read from mpqs, if you wish to specify the mpq to read from you'll need to call SFileOpenFileEx by yourself, as the functions mentioned search all of the mpqs that have been loaded with SFileOpenArchive.

..was this even close to what you wished to know?



None.

Jun 22 2015, 1:25 am iCCup.xboi209 Post #5



Yes thank you, I'll look into all of those



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:44 pm]
Ultraviolet -- 1337 ejaculator
[10:29 pm]
ejac1337 -- derp
[07:08 pm]
Slyence -- Well shucks ..
[2021-11-26. : 4:02 am]
O)FaRTy1billion[MM] -- Slyence
Slyence shouted: I could've swore I used to have a colored username.
probably, they did get reset at some point
[2021-11-26. : 4:02 am]
Apos -- :wob:
[2021-11-26. : 12:01 am]
UndeadStar -- 🦃 Just saw a new news 🦃
[2021-11-25. : 6:04 pm]
Slyence -- Meme x2
[2021-11-25. : 12:39 pm]
Moose -- meme
[2021-11-25. : 12:25 pm]
Slyence -- I could've swore I used to have a colored username.
[2021-11-24. : 10:56 pm]
RdeRenato -- xd
Please log in to shout.


Members Online: Oh_Man, Roy, KrayZee