ID:1363217
 
(See the best response by DarkCampainger.)
I'm trying to get an image object created from a true snapshot of an atom

So if the atom has some overlays and underlays and is facing east, the image object returned is exactly what the atom looked like, underlays and overlays included, during that tick.

Currently, I can either get the overlays, or the object without the overlays, but I can't get both combined. Simply calling var/icon/ic = image(reference) doesn't work...
Oh, and I know there's a way to do this using the hard drive by means of saving. I am looking for a way to do this without that, if there is a way.
Like I said earlier, I wasn't sure that image() would do the job, never heard of that being used for this purpose.

The way I figured it would have to be done, is you'd have to keep track of your layers, and blend() them into the bottom layer sequentially.
It would be very difficult, in some cases, to create a snapshot in that manner because it would require keeping track of every single icon, icon_state, color swap, or other blend operation (or simply holding every single icon object that was ever added to overlays) in order to build the final result.

This is loosely a feature request for having some proc that returns a true snapshot icon object from an atom.
var/obj/Mirror = new/mob(locate(usr.x,usr.y,usr.z))
Mirror.name = "[usr]'s Mirror"
Mirror.icon = usr.icon
Mirror.overlays = usr.overlays
Mirror.underlays = usr.underlays
Mirror.icon_state = usr.icon_state
Mirror.dir = usr.dir


If I understand what you are trying to do this seems to work. But it doesn't update every tick. If your not using something that isn't moving or changing a lot you can run a Proc when it changes to update it or mimic it as an owner to copy what it does. But since it sounds like you've post this before I felt like i should throw my two cents in and see if it helps.
In response to Archfiend Master
Not quite what I'm trying to do... I need either a /image or /icon that contains an atom's true snapshot. By true snapshot I mean exactly what the atom would look like if you took a screenshot of the atom and packed that into a single icon or image. As far as I can tell, there's no way to do this unless you save the object to disk, read it back in, and extract its icon because by default, the internals perform some task of combining all of the overlays and underlays when you save an atom's icon along with the atom.

I'm asking for an equivalent of this task, or a feature added that let us perform this without having to put something on the hard drive.
Best response
You can try using this library:
Get Flat Icon

The only catch is that there isn't a way to detect if an overlay has its direction set to SOUTH or if it inherits its direction from the parent.
In response to DarkCampainger
Interesting, I will have to study exactly how you are pulling this off.. at first glance it looks like you've figured out how to get meaningful info out of overlay entries in the overlays list as well as using Blend() with each component to build the actual snapshot. Nice!
Don't forget that a /image object itself also has an overlays var, just like an atom.

Just out of curiosity, would it be possible to simply do something like image.overlays = atom.overlays? Although, even if that does work, it wouldn't actually be a single image, but I'm not sure why it would need to be, unless you are trying to conserve memory or do something special with it. It just seems like Blend()ing would be slower than simply transferring the actual overlays from the atom to the image, but I could be wrong.

I'm just assuming here, but are you doing this to get "ghost" images of real objects, as part of the implementation for the seamless, unlimited map chunk loading idea?
This is for a flag maker. The flag is composed of glyphs, patterns, and overlays. The flag must be finished off as an actual icon. It is used in a variety of ways throughout the game (like a logo being able to be plastered on to objects)
You could always go with the method of not using overlays at all.

Every time you need to update the icon you'll simply run the updateMobIcon() function or whatever you would call it, it would then read the character's basic mob icon, add the skin-, eye- and hair colors, or other stuff you want to make. After that you do other transformations, which you deem necessary. And you'll set the mob's icon into the result.

This does have it's own problems, but it makes it rather simple to get the mob's snapshot very easily, this does also apply to all atom's but using mob as an example would work quite well as well.

When you don't need to generate the icon more than once you can simply store the icon in a list with it's index being the name of the icon, which makes it easily read-able in the future or other parts of the code.

While it does have the flaws of using a bit more resources depending what it is used for, it does give you the benefit of being able to quickly grab the atom's used look for different things such as projecting illusions or ghosts, even shadows with a simple icon.Flip() and icon.Blend() run.
var/icon/ic = image(reference)

Won't work.

var/image/ic = image(reference)

Will work.

usr.overlays += image(reference)

Will work.
I've decided to go with a method that will keep track of all the parts (and display them as overlays temporarily), then actually draw pixels for the last step to produce the final image.