Skip to main content

Module edit

Module edit 

Source
Expand description

Editing an opened .clip (R12): layer pixels, layer properties, adding and removing layers, and the stored preview.

Each change is made in the in-memory database and external chunks, so ClipFile::save writes a consistent file: new external chunks are listed in ExternalChunk with their offsets, and replaced chunks are dropped. Layer pixels are written to every mipmap level (each level is the one above halved with a 2×2 box, as CSP makes them).

New rows get their MainId from ElemScheme.MaxIndex (the largest id handed out so far), and new layers are built like the ones CSP makes: a mipmap of canvas-sized levels halved until the canvas fits in 128 pixels (at least 4 levels), and a 512 × 512 thumbnail offscreen. As in CSP’s own files, offscreens that hold nothing yet name an external chunk that is not stored.

Enums§

NewLayer
The kinds of layer ClipFile can add.

Functions§

mipmap_sizes
Sizes of a new layer’s mipmap levels: the canvas halved (rounded down) until it fits in 128 pixels, with at least 4 levels.
new_external_id
A new external chunk id: “extrnlid” and a UUID as 32 upper-case hex digits.
new_uuid
16 random bytes shaped as a version 4 UUID (CSP’s ids are UUIDs).