A single channel of image data, either a color channel of a Surface or a grayscale image. Implicitly shared object.

A Channel can be thought of as a grayscale image, and frequently is simply that. Its name comes from the most common use case, which is to represent a single color channel of an image, such as the red, green, blue or alpha channel of a Surface. To acquire one of these color channels from a Surface, use getChannelRed(), getChannelBlue(), getChannelGreen() or getChannelAlpha().

Channel rChan = surf.getChannelRed(); // references just the red values of surf's pixels


The code below constructs a Channel which is a grayscale image independent of a Surface that is 640x480 pixels:

Channel chan( 640, 480 );

You can also construct a Channel using an ImageSource, such as the result of loadImage(). In the code below, \a myImage will hold a grayscale version of the PNG file stored at the relative path "myImage.png":

Channel myImage = loadImage( "myImage.png" );

Channels come in two primary configurations, the traditional 8-bits unsigned integer represented by Channel8u, and a 32-bit float version suitable for high dynamic range images, represented by Channel32f. Channel is a short-hand synonym for Channel8u.


Public Member Functions

  • operator= (const ChannelT &rhs)
  • operator= (ChannelT &&rhs)
  • operator ImageSourceRef () const

Static Public Member Functions


Protected Attributes

  • int32_t
    mWidth
  • int32_t
    mHeight
  • uint8_t
    mIncrement
  • ptrdiff_t
    mRowBytes
  • T *
    mData
  • std::shared_ptr< T >
    mDataStore