I bet you're all pretty excited, huh? I am!
Because here's what's going on....
S2 layers can now register image resources. When update-db.pl runs, it'll register these on-disk (distributed) files and allocate gpics for them, saving a mapping from filename to gpicid.
The unique distributed filename, its width/height, and a mapping of which layer property colors should be assigned to which palette indices is then stored in a layer property.
Theme layers can also do this, and because theme layers can override properties of the layout layer, a theme layer can not only have totally different colors for images, but it can also change the images too
Then, in the S2 code, there's a new site-specific built-in S2 function to retrieve a Picture object given a paletted image spec. S2FotoBilder.pm gets a context from the caller (behind the scenes) and can lookup the color values as they currently are for that style.
Then it returns the image object, after it makes a re-colored image and allocates a upic. Or, rather, adds a stub for it, to be created dynamically when the actual image request comes back in a second.
But right now I'm just returning a goat, because it's not entirely implemented.