[Extension] Limit Colour Component Levels

This is mainly just a learning exercise and I missed this kind of functionality from Pro Motion.
It’s my first extension, first time playing with Lua and I’m sure someone’s already done something along these lines, but it’s possible that someone might find a use for it.

Limit Colour Component Levels extension allows you to limit the number of possible values for each colour component such as older system systems with less than 8 bits per colour channel.
Works on indexed and RGB images, though really slow on RGB.

Two commands one with GUI and one without GUI to reapply last settings (I’ve assigned them the the Ctrl+Shift+L and Ctrl+L shortcuts).
They’ll show up in the Edit > FX menu (I have to restart Aseprite after installing extension for them to appear, not sure if that’s normal or I stuffed something up).

Scale option chooses between explicit Number of levels or Bits per component.
Range option changes the resulting value for each level, Stretch being the most useful, stretching to the full component range and other options resulting in different clipped ranges.
Setting a component to 0 levels leaves it unchanged (default for alpha).