Hi Hannes,
I have implemented this in various ways in my InternetArchive client library—a work in (slow) progress over the last 3+ years. Note I did not realize a similar library had been written for Sophie ten years ago. This one was based on the Python client library which uses the current InternetArchive API.
I finally made it public in its current state here:
Some examples for how to use it live in the IAExample* classes.
The following will display the famous Byte cover and restore the display after a click:
(IAItem named: 'byte-magazine-1981-08' ) displayItemTileJpeg
Anyway, you can find my code in the 'displaying graphics' instance method category of IADownload. Also note that you may be interested in seeing Form class>>#openImageInWindow:
Here is how I implemented some JPEG download & display in Squeak 5.2. These methods are taken from the IADownload and perhaps IAItem classes.
getResponse
"returns a WebResponse object"
^ response := WebClient httpGet: self url.
downloadJpegIntoForm
| s contents jww imageExtent form |
s := ByteArray new writeStream.
s binary.
self getResponse.
response streamTo: s size: response contentLength progress: nil.
response close.
contents := s contents.
(JPEGReadWriter2 understandsImageFormat: (contents readStream))
ifFalse: [^ self error: 'cannot read jpeg'].
jww := JPEGReadWriter2 new.
imageExtent := jww imageExtent: contents.
form := Form extent: imageExtent depth: 32.
jww uncompress: contents into: form doDithering: false.
^ form
displayJpeg
| form |
form := self downloadJpegIntoForm.
Display restoreAfter: [ form displayOn: Display ].
displayJpegInMorph
| form morph |
form := self downloadJpegIntoForm.
morph := BorderedMorph newBounds: (form bounds).
Display restoreAfter: [ form displayOn: Display ].
displayJpegInWindow
| form morph window |
self flag: #seeFormClassSideForUtilityMethod.
form := self downloadJpegIntoForm.
morph := form asMorph.
window := SystemWindow labelled: 'image'.
window
" addMorphCentered: (form asMorph);"
addMorph: (form asMorph) frame: (0.0@0.0 corner: 1.0@1.0) .
" addMorph: (form asMorph) fullFrame: (SystemWindow menuBoxFrame) ."
window
openInWorldExtent: (form extent scaleBy: 1.2 @ 1.2).
Let me know if I can help further. I believe there is also code in there for displaying downloaded GIFs and animated GIFs but I could be wrong.
Best,
Tim