SurfaceConstrains usage


I guess this is super trivial, but it doesn’t make much sense to me.

If I try to create a Surface8uRef from an ImageSourceRef with BGRX channel order, the surface that is created has a channel order of RGBA.

How would I use ‘SurfaceConstrains’ to tell Surface8u::create to create one with BGRX??

Is this possible or should I just use Surface::setChannelOrder to fix the channel order after creation?


You could definitely just copy after the fact, but if you wanted to use SurfaceConstraints to get it in one go, it would be roughly this (untested):

class ForceBgrx : public SurfaceConstraints {
    SurfaceChannelOrder getChannelOrder( bool alpha ) const override
    { return SurfaceChannelOrder::BGRX; }
Surface8u s( imageSource, ForceBgrx() );

Thanks Andrew! this clarifies it :slight_smile: