# SurfaceConstrains usage

**URL:** <https://discourse.libcinder.org/t/surfaceconstrains-usage/485>\
**Category:** Using Cinder\
**Created:** [January 4, 2017, 4:34pm UTC](https://discourse.libcinder.org/t/surfaceconstrains-usage/485 "2017-01-04T16:34:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![okinp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/okinp/32/161_2.png) [@okinp](https://discourse.libcinder.org/u/okinp)\
**Post date:** [January 4, 2017, 4:34pm UTC](https://discourse.libcinder.org/t/surfaceconstrains-usage/485/1 "2017-01-04T16:34:01Z")

</div>

Hello,

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?

Thanks!

---

<div class="post-metadata">

**Author:** ![andrewfb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/andrewfb/32/2_2.png) [@andrewfb](https://discourse.libcinder.org/u/andrewfb)\
**Post date:** [January 4, 2017, 4:43pm UTC](https://discourse.libcinder.org/t/surfaceconstrains-usage/485/2 "2017-01-04T16:43:03Z")

</div>

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):

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

```

---

<div class="post-metadata">

**Author:** ![okinp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/okinp/32/161_2.png) [@okinp](https://discourse.libcinder.org/u/okinp)\
**Post date:** [January 4, 2017, 4:55pm UTC](https://discourse.libcinder.org/t/surfaceconstrains-usage/485/3 "2017-01-04T16:55:20Z")

</div>

Thanks Andrew! this clarifies it 🙂
