# Raw video with alpha channel

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

Alpha channel mode produces a per-pixel alpha mask alongside the raw video frame, which you can use to remove the background or composite the user over custom content.

## Turn on alpha channel mode

Not every device can produce an alpha mask, so check support before enabling it. Confirm the device supports alpha channel mode with `isDeviceSupportAlphaChannelMode`, and that the session currently allows it with `canEnableAlphaChannelMode`. Then turn it on with `enableAlphaChannelMode`, and read the current state with `isAlphaChannelModeEnabled`.

```cpp
IZoomVideoSDKVideoHelper* pVideoHelper = m_pVideoSDK->getVideoHelper();

if (pVideoHelper->isDeviceSupportAlphaChannelMode() && pVideoHelper->canEnableAlphaChannelMode())
{
    pVideoHelper->enableAlphaChannelMode(true);
}

bool isOn = pVideoHelper->isAlphaChannelModeEnabled();
```

## Read the alpha mask

With alpha channel mode on, the alpha mask arrives alongside the YUV planes in `onRawDataFrameReceived`. Read it with `GetAlphaBuffer` and `GetAlphaBufferLen` on the `YUVRawDataI420` frame. For the full subscription and frame-reading flow, see [Receive raw data](/docs/video-sdk/linux/raw-data/receive-raw-data/#receive-raw-video-data).

```cpp
void CExampleRenderer::onRawDataFrameReceived(YUVRawDataI420* data_)
{
    char* alphaBuffer = data_->GetAlphaBuffer();
    unsigned int alphaLen = data_->GetAlphaBufferLen();
    // Composite the frame using the alpha mask.
}
```

## Alpha channel callbacks

The SDK calls `onVideoAlphaChannelStatusChanged` when alpha channel mode turns on or off.

```cpp
void CExampleListener::onVideoAlphaChannelStatusChanged(bool isAlphaModeOn)
{
    // Respond to the alpha channel mode change.
}
```
