/icon objects versus the raw data in Developer Help
|
|
I ran into this problem after creating a cropping proc for user-uploaded icons, and after a bit of experimenting it finally dawned on me that the "raw" file data differs from the content of an /icon object:
#define INPUT "default.input1" #define OUTPUT "default.output1"
mob var icon/display_icon = null verb set_icon_raw(i as icon) usr.display_icon = i set_icon_object(i as icon) usr.display_icon = icon(i) speak(t as text) world << output("<img src=\"\ref[usr.display_icon]\">[usr.name]: [t]",OUTPUT)
|
Obviously I'd assume this distinction is intentional, but the kind of situation as above creates problems because I can't find any way to turn the /icon object back into file data. I know it's automagically converted back to the necessary file data when assigned to atom.icon and other vars, but how can I accomplish the same when these vars aren't involved?
This is the cropping proc I was referring to:
proc icon_crop(a,m_x=96,m_y=96) if(!isnull(a)) var icon/i = icon(a) icon_x = i.Width() icon_y = i.Height() if(icon_x > m_x || icon_y > m_y) i.Crop(1,1,min(icon_x,m_x),min(icon_y,m_y)) return i return null
|
This function can't be accomplished without turning it into an /icon object, so I run into the problem described above.
|
Just a thought.
Edit: I've never personally had this problem myself.