Closed codefrau closed 8 months ago
Implemented the primitive in e20591b9f7ccf1b9ac26c17e34be16bacfdff94e (for non-Spur images).
It's working correctly according to ImageSegment>>deepCopyTest:
.
However, while saving an Etoys project succeeds now, loading it back in still fails with an error. Since loading existing projects works fine, the problem must be in saving.
I assume there is a bug in writing the SmartRefStream
. This could be the same issue as mentioned in https://github.com/codefrau/SqueakJS/issues/146#issuecomment-1707438662 where saving a Scratch Project works only if the sounds are removed.
The actual error happens when loading a Bitmap from the Etoys project's SmartRefStream
. I don't know the error in Scratch but sounds are related to binary objects too so that seems to be an area worth investigating.
The load error happens when the ImageSegment
's WordArrayForSegment
is read from the SmartRefStream
because there are not enough bytes. E.g. a project just containing an ellipse is written as a 6520 byte segment (i.e. the WordArray
created by storeImageSegment()
). But when loading it, the byteSize
is read correctly as 6520
but only 3269 bytes are available before the end of the stream.
That means for some reason, storing of the ImageSegment
's WordArray
in the SmartRefStream
failed, or maybe it was cut short when writing it to the zip (.pr
files are actually .zip
files containing the actual project and other files).
Fixed the file writing bug in d94aaedcda6abdd99da485319ef112d71854b79d. The segment is stored as words in the file but primitiveFileWrite took the word count as bytes so it only stored the first quarter of the segment. Works in release 1.1.0.
ImageSegment store primitive is missing