Hi,
I would like to use image segments in 3.9. I need to export a tree of objects to a file and then load the segment into a different image.
Thanks
Hello Brent,
BP> I would like to use image segments in 3.9. BP> I need to export a tree of objects to a file and then load BP> the segment into a different image. never tried across different Versions but a short example:
writing:
writeTrainingsSamples "write the class var TrainingsSamples to a file using ReferenceStreams" | rr | rr := ReferenceStream fileNamed: 'trainingssamples.obj'. rr nextPut: TrainingsSamplesFehlerkategorien trainingsSamples . rr close. rr := nil
reading:
readTrainingsSamples "read the class var TrainingsSamples from a file using ReferenceStreams " | rr | rr := ReferenceStream fileNamed: 'trainingssamples.obj'. TrainingsSamplesFehlerkategorien trainingsSamples: rr next. rr close. rr := nil
hth,
Herbert mailto:herbertkoenig@gmx.net
writing:
writeTrainingsSamples "write the class var TrainingsSamples to a file using ReferenceStreams" | rr | rr := ReferenceStream fileNamed: 'trainingssamples.obj'. rr nextPut: TrainingsSamplesFehlerkategorien trainingsSamples . rr close. rr := nil
reading:
readTrainingsSamples "read the class var TrainingsSamples from a file using ReferenceStreams " | rr | rr := ReferenceStream fileNamed: 'trainingssamples.obj'. TrainingsSamplesFehlerkategorien trainingsSamples: rr next. rr close. rr := nil
Thanks, Interestingly there is not mention in this example of ImageSegment or SmartRefStream. Are these classes abandoned ?
Brent
On 01.05.2009, at 20:29, Brent Pinkney wrote:
writing:
writeTrainingsSamples "write the class var TrainingsSamples to a file using ReferenceStreams" | rr | rr := ReferenceStream fileNamed: 'trainingssamples.obj'. rr nextPut: TrainingsSamplesFehlerkategorien trainingsSamples . rr close. rr := nil
reading:
readTrainingsSamples "read the class var TrainingsSamples from a file using ReferenceStreams " | rr | rr := ReferenceStream fileNamed: 'trainingssamples.obj'. TrainingsSamplesFehlerkategorien trainingsSamples: rr next. rr close. rr := nil
Thanks, Interestingly there is not mention in this example of ImageSegment or SmartRefStream. Are these classes abandoned ?
Brent
I don't think ReferenceStream makes use of ImageSegments.
- Bert -
Hello Brent,
BP> Thanks, BP> Interestingly there is not mention in this example of BP> ImageSegment or SmartRefStream. BP> Are these classes abandoned ?
somewhere in the past I had a problem with using SmartRefStream and it worked with ReferenceStream, so I abandoned SmartRefStream.
And Bert is right, ReferenceStream doesn't use ImageSegment.
If in my examples you just replace ReferenceStream with SmartRefStream the writing still works but the reading doesn't.
Searching the archives I got it working by:
readTrainingsSamples "read the class var TrainingsSamples from a file using ReferenceStreams " | rr | rr := StandardFileStream fileNamed: 'trainingssamples.obj'. TrainingsSamplesFehlerkategorien trainingsSamples: rr fileInObjectAndCode. rr close. rr := nil
Cheers
Herbert mailto:herbertkoenig@gmx.net
The class SMSqueakMap uses image segments. You may find this useful as a starting point.
Image segments are much faster than reference streams, but you need to take care that there are no references pointing from the outside into the graph of objects you are saving (except for globally used objects like symbols). Else, these and all other indirectly referenced objects end up in a reference stream that in the segment.
Cheers, Adrian
On May 2, 2009, at 10:22 , Herbert König wrote:
Hello Brent,
BP> Thanks, BP> Interestingly there is not mention in this example of BP> ImageSegment or SmartRefStream. BP> Are these classes abandoned ?
somewhere in the past I had a problem with using SmartRefStream and it worked with ReferenceStream, so I abandoned SmartRefStream.
And Bert is right, ReferenceStream doesn't use ImageSegment.
If in my examples you just replace ReferenceStream with SmartRefStream the writing still works but the reading doesn't.
Searching the archives I got it working by:
readTrainingsSamples "read the class var TrainingsSamples from a file using ReferenceStreams " | rr | rr := StandardFileStream fileNamed: 'trainingssamples.obj'. TrainingsSamplesFehlerkategorien trainingsSamples: rr fileInObjectAndCode. rr close. rr := nil
Cheers
Herbert mailto:herbertkoenig@gmx.net
On 5/1/09 1:23 PM, "Brent Pinkney" brent@zamail.co.za wrote:
Hi,
I would like to use image segments in 3.9. I need to export a tree of objects to a file and then load the segment into a different image.
Thanks
-- Brent
From SqueakLightII, you have the attached .st.
So you could have MyTree saveOnFileNamed: 'OakTree'.
SqueakLightII could read this and also autoopen a Inspector of any .obj file via drag and drop.
For other images without the SLII logic, you must do
| inputStream anObject | inputStream _ FileStream oldFileNamed: ' OakTree.obj'. anObject _ inputStream fileInObjectAndCode. inputStream close. (Inspector openAsMorphOn: anObject) openInHand
You must know this sure works between same version images , like two different 3.9 based images , but could fail between different images, as 3.10 as example don't have some classes 3.9 have.
SLII have in development logic for you could load "missed classes" from server via DNU.
I hope this helps
Edgar
squeak-dev@lists.squeakfoundation.org