Eng:Scratch File Format (1.4)/Fixed-format Objects


 * ''This is part of a technical description of the file format.

Fixed-format Objects are Objects with a fixed structure. This means they have a fixed number of fields (each with a fixed type). Their structure cannot change between versions, unlike User-class Objects.

They include basic data types: such as Color, String (text value), Point, Rectangle, Array, and Dictionary. The full list below is sorted by.

Structure
Their structure is described here.

They have classIDs between 1 and 98.

9 String, 10 Symbol, 11 ByteArray

 * : 32-bit unsigned integer
 * : length many bytes.

12 SoundBuffer

 * : 32-bit unsigned integer
 * : (length * 2) many bytes.

13 Bitmap

 * : 32-bit unsigned integer
 * : (length * 4) many bytes.

14 UTF8

 * : 32-bit unsigned integer
 * : length many bytes.

[15-19 reserved for non-pointer objects]

20 Array, 21 OrderedCollection, 22 Set, 23 IdentitySet
These are assorted Arrays, like lists of objects.
 * : 32-bit unsigned integer
 * : length many fields (usually References, I think).

24 Dictionary, 25 IdentityDictionary
Dictionaries are collections of keys mapped to values.
 * : 32-bit unsigned integer
 * : length many key, value pairs.

[26-29 reserved for collections]

30 Color

 * 2 bits of padding
 * : 10-bit integer
 * : 10-bit integer
 * : 10-bit integer

31 TranslucentColor
Same structure as Color, but also includes:
 * : 8-bit unsigned integer

32 Point

 * : field
 * : field

33 Rectangle
4 fields

34 Form
Forms are rectangular arrays of pixels, used for holding images.


 * : dimensions of the image
 * : how many bits are used to specify the color at each pixel.
 * : a Bitmap (or ByteArray). Has different internal structure depending on depth.
 * at depth : contains 32-bit color values.
 * : 8-bit integer
 * : 8-bit integer
 * : 8-bit integer
 * : 8-bit integer
 * : 8-bit integer
 * : 8-bit integer

35 ColorForm
Same fields as Form, but also includes:
 * : an array used to decode the bits bitmap.

From a [ post] by nXIII:

"Form stores 32-bit words (split these into bytes to avoid arithmetic rounding errors) compressed into a ByteArray, decompressed in both the static & instance methods of Bitmap. These correspond to pixel values in the Form's depth, look into Color's static methods (I think #pixelValue:depth:) ColorForm stores bytes containing color array indices (remember to subtract one from this because Squeak arrays are 1-based) which are also compressed. These point to colors in the colors array, which has 2^depth colors. For some reason, I had to render ColorForms in rows, and Forms in columns (this might be a bug in my code, though)." "ColorForms end up with a ByteArray of indices in their colors array (which has 2^depth colors in it). Forms end up with an array of colors of the Form's depth."

[36-98 reserved]