At 7:43 pm -0300 28/01/03, Ricardo Montiel wrote:
Is good to know where friends are, and thanks for the clear explanation. It
also remind me that I need to take a look to IM QuickDraw volume. If not,
QuickDraw.pm seems to be almost useless.
IM is certainly essential reading, although QuickDraw is actually not nearly so sparsely documented as it seems at first sight.

Beware that the way "WaitNextEvent" works in MacPerl is somewhat different from the way it works in Pascal or 'C'. In MacPerl 'WaitNextEvent' is purely implicit and returns nothing.

To get an understanding of how the whole set of Toolbox modules work and relate to each other you will need to read the code of Windows.pm. Start reading from the *end* of the module, which is where the Event handling procedures are to be found. The whole of the MacPerl Toolbox is an intricate and very ingenious exercise in Event handling. This is specifically a MacPerl issue and IM is no help at all in this matter.

I have sent you (separately) a folder "FormatConversions.sit". In that folder the file "ListOfPictures.plx" was intended originally as a "MacList" tutorial but it nevertheless contains examples of some of the things you might need.

sub launch_gc

Your script will probably need to include a routine of this kind, to avoid the script crashing if GraphicConverter is not running. It is also nice to 'hide' Graphic converter so that format conversions take place invisibly, behind the scenes as it were. The routine uses AppleEvents to launch and hide GraphicConverter.

sub convert_picture

You need a destination for the 'PICT' file -- I have chosen to put it in the 'temp' folder "$ENV{TEMPDIR}". You might want to do something else -- it is a matter of choice.

sub show_picture

Firstly you open the file and discard the first 512 bytes. This space is reserved for data ancillary to the picture itself. Secondly you create a handle to the picture using "PicHandle()". Thirdly, using that handle you find the rectangle containing the 'PICT' using "picFrame". Beware that the frame of 'PICT' images is often offset from zero.

Having got the 'PICT's frame rectangle you can use this to define the boundary of the MacWindow. There is a section in the script under "window" for creating a MacWindow which might be helpful.

Finally you put the picture into the window with "DrawPicture(HANDLE, RECT)"

clean-up

When you close your script you need to dispose properly of any handles you have created. Pointers look after themselves in MacPerl but handles do not. There is for each module a method supplied to be used for handle disposal.

I hope all this is clear and some help for your project.

Alan Fry




Reply via email to