AuburnSounds / gamut

Image encoding and decoding library for D. Detailed layout control. Experimental codec QOIX.
Boost Software License 1.0
41 stars 2 forks source link

LayoutOptions to control allocations. #9

Closed p0nce closed 2 years ago

p0nce commented 2 years ago

The LayoutOptions would be an optional struct, allowing to control sitting of the pixel data.

In Dplug, OwnedImage has different constraints that can be combined.

- rowAlignment 
- xMultiplicity
- trailingSamples

This wouldn't be kept after allocation. Cloning would not preserve those constraints.... unless it is kept through a pointer? I don't think borders should be in.

Image decoders should return an allocation made from a given LayoutOptions.

The need is that some image processing need to access by 4, on aligned boundaries. dplug:canvas also need 3 trailing bytes after each line.

p0nce commented 2 years ago

Mmmm we can store that as flags into the Image, in order to stay self-contained: So it is 2 bits for extra "gap" pixels, 2 bits for multiplicity, and 3 for scanline alignment. The only flag combination that ensures to be gapless is 0.

p0nce commented 2 years ago

Basically we can use whatever the decoder can already provide as automatic conversion (for example, stb_image can force to 1/2/3/4 channels and do 8-bit/10-bit conversion at the row level), and then support other flags with convertTo, which is itself trained to see cases that needs nothing to do.

What we cannot do for now is force "gapless" contraint.

p0nce commented 2 years ago
p0nce commented 2 years ago

Basically works.