On Jul 27, 2007, at 3:14 PM, Christiaan Hofman wrote:
On 27 Jul 2007, at 11:54 PM, Daniel Jalkut wrote:
On Jul 27, 2007, at 5:29 PM, Mike Zornek wrote:
What should the type be?
Are there any example Cocoa apps out there that have image
attributes?
You've run up against the frustration of where AppleScript's types
end and custom app-defined types begin.
If you look inside iChat's dictionary, you find that it defines
TIFF Picture as essentially backed up by "NSData".
Not sure what this means for how (or if) scripters can usefully
manipulate the TIFF Picture with data from outside of the app (e.g.
from a disk file).
Generally I think what you would do is expose a class like "TIFF
Picture" such that it included a property like "data path" or
something, so users could do something like "make new TIFF Picture
with properties {data path:myPictureFilePath}".
I'm pretty rough on this stuff myself, though.
I haven't tried this myself, but I guess you need to declare the
TIFF Picture type as a value type, declare it in the .sdef as
something like:
(I'm not sure the TIFF code, it must be consistent with other
occurrences of this type though). I think that if you have an
accessor for the TIFF data of the image this could work.
That works just fine -- in fact, it's what iChat does these days --
but that wasn't really Daniel's question. Given that declaration, you
can copy images around within iChat -- say, from one buddy to another
-- but setting the image to an image from some random file is, er,
harder. The basic problem is that AppleScript doesn't have any real
"image" value type of its own. You could probably fake it by reading
from a TIFF file "as «class TIFF»", which should give you a data blob
value of a sort that iChat will accept. (Haven't tried it myself,
though, and it's not exactly what you'd call obvious in any case.)