Posts ID:264640 Favorites Creations
ID:264640

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:
 //small little test project#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("[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.
 #1 Jan 31 2010, 5:02 pm You could temporarily fcopy() the file to a temporary directory then use the created file to do whatever you need before deleting it. Just a thought. Edit: I've never personally had this problem myself.
 #2 Jan 31 2010, 5:22 pm fcopy_rsc()
 #3 Jan 31 2010, 9:34 pm In response to Garthor (#2) Garthor wrote: fcopy_rsc() D'oh. I sorta figured the solution was simple.