There is a writeBMPFileNamed: in Form, but I often want snapshots in GIF format. So I wrote a short bon mots to provide similar functionality for GIF. (I keep (Form fromUser) writeGIFfileNamed: 'snapshot.gif' in my Do menu.) Finding myself filing it in for the umpteenth time, I thought someone else might find it useful.
'From Squeak 2.5 of August 6, 1999 on 20 September 1999 at 12:05:48 pm'!
!Form methodsFor: 'fileIn/Out' stamp: 'mjg 9/20/1999 12:05'! writeGIFfileNamed: aFile GIFReadWriter putForm: self onFileNamed: aFile. ! !
-------------------------- Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280 (404) 894-5618 : Fax (404) 894-0673 : guzdial@cc.gatech.edu http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html
Good suggestion, Mark. I'll put this in the Do menu for the next release, combined with a forthcoming feature from David Pennell that provides version-number sequencing of file names.
- D
There is a writeBMPFileNamed: in Form, but I often want snapshots in GIF format. So I wrote a short bon mots to provide similar functionality for GIF. (I keep (Form fromUser) writeGIFfileNamed: 'snapshot.gif' in my Do menu.) Finding myself filing it in for the umpteenth time, I thought someone else might find it useful.
'From Squeak 2.5 of August 6, 1999 on 20 September 1999 at 12:05:48 pm'!
!Form methodsFor: 'fileIn/Out' stamp: 'mjg 9/20/1999 12:05'! writeGIFfileNamed: aFile GIFReadWriter putForm: self onFileNamed: aFile. ! !
Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280 (404) 894-5618 : Fax (404) 894-0673 : guzdial@cc.gatech.edu http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html
There is a writeBMPFileNamed: in Form, but I often want snapshots in GIF format. So I wrote a short bon mots to provide similar functionality for GIF. (I keep (Form fromUser) writeGIFfileNamed: 'snapshot.gif' in my Do menu.) Finding myself filing it in for the umpteenth time, I thought someone else might find it useful.
You betcha it's useful; it's one step toward making PWS into Squeak's third GUI, an alternative to MVC and Morphic (assuming we actually need such a thing).
While you're at it, consider something like writeGIFStream i.e. write the Form to a WriteStream, and return contentsOfEntireFile (or perhaps just the WriteStream itself) without bothering to write to disk. GIFReadWriter>>putForm:onStream: does more-or-less what Form>>writeGIFStream would do; GIFReadWriter>>putForm:onFileNamed: does essentially what Mark's method Form>>writeGIFfileNamed: does.
This sort of thing should be useful in web-inizing traditional applications e.g. rather than display graphical output as an instance of some Form in MVC, put <? SomeForm new loadItWithStuff writeGIFStream ?> on a page of your Swiki; if you go about it the right way, your form will display as an image on the web page. (If you go about it the WRONG way, you get your GIF as a string of ASCII characters.)
As a simple example, consider:
SomeAppropriateClass>>testImage "Generate an arbitrary test Form, write it out as a GIF stream, and return its contents"
| form xtnt stream | xtnt _ 300@300. form _ (Form extent: xtnt depth: Display depth) fromDisplay: (Rectangle origin: 50@50 extent: xtnt). stream _ (WriteStream with: '0' asByteArray) reset. GIFReadWriter putForm: form onStream: stream. ^stream contentsOfEntireFile.
With the corresponding Form method, we could rewrite this as something like:
| xtnt | xtnt _ 300@300. ^(Form extent: xtnt depth: Display depth) fromDisplay: (Rectangle origin: 50@50 extent: xtnt); writeGIFStream.
Now put <? SomeAppropriateClass new testImage ?> all by itself in a file in the \Server\embedded subdirectory of your Swiki, and link to it from some other page. POOF! a piece of Squeak's Display appears in your web browser (provided you've got the Swiki running), even if Squeak itself is minimized.
Now put <? SomeAppropriateClass new testImage ?> all by itself in a file in the \Server\embedded subdirectory of your Swiki, and link to it from some other page. POOF! a piece of Squeak's Display appears in your web browser (provided you've got the Swiki running), even if Squeak itself is minimized.
I just found the code for this. It's, uh, in the image already. <sheepish smile.> Take a look at ScreenshotAction in the PWS classes.
Mark
-------------------------- Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280 (404) 894-5618 : Fax (404) 894-0673 : guzdial@cc.gatech.edu http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html
squeak-dev@lists.squeakfoundation.org