I'm requesting a proc that converts /icon objects into a base64 text string. (Or alternatively, give the ability to save an icon to the filesystem)
Currently, the built-in savefile system already stores icons in base64 encoding, but in order to retreive that, you need to use ExportText, and parse the mark-up. But no one seems to have a parser, and thus it's not quite possible.
This is useful for a couple reasons. The first of which being that there's no built-in way to create icon files. Best one could do is story them inside of a savefile.
And second; in this way we can interact with other applications that accept base64 strings of images.
Alternatively, we could have a function that actually saves an icon file to the filesystem (and not just one that sends it to the user.
| |||||||
Oct 1 2014, 12:56 pm
|
|
What's the difference between saving an icon file and sending it to a client to be saved? Who's saving it, and where?
|
Currently, if you create an icon at runtime, the only way to save that new icon is by saving it to a savefile. But there's no direct way to interact with other applications using that icon, for things like modifying it or sending it to an outside server.
For the most part, I'm suggesting a way to actually return the icon information in a usable format, such as an actual file, or a base64 string. |
In response to RageFury33
|
|
You can save an /icon as a .dmi using ftp()...?
|
I think you can also do the same thing with browse_rsc(I,F) i nwhich I is the icon object and F is the file to save it to.
proc/SaveIcon(client/C, icon/I, F) |
Does this help you out? What it does is convert all pixels of the icon to a large string of hex codes using IconToHex(). To convert it back, we would use HexToIcon().
proc/IconToHex(icon/I, S="") You can save pretty much any icon you'd like. Careful though, because it only saves a static image, and not an actual DMI. An example: var/icon/i = icon('SomeIcon.dmi') |
If you just want to save the icon inside the project directory, you can also use fcopy():
fcopy(fcopy_rsc(myDynamicIcon),"out.dmi")
I can't remember when the fcopy_rsc() is necessary, though. Also, I thought the savefile format already stored the icon as base-64, so if you actually wanted that you could probably store it in a savefile and then load it back as text (might have to trim off some markup at the start/end). Or use savefile.ExportText(). |