void Texture::SurfaceChannelOrderToDataFormatAndType( const SurfaceChannelOrder &sco, GLint *dataFormat, GLenum *type ) { switch( sco.getCode() ) { case SurfaceChannelOrder::RGB: *dataFormat = GL_RGB; *type = GL_UNSIGNED_BYTE; break; case SurfaceChannelOrder::RGBA: case SurfaceChannelOrder::RGBX: *dataFormat = GL_RGBA; *type = GL_UNSIGNED_BYTE; break; case SurfaceChannelOrder::BGRA: case SurfaceChannelOrder::BGRX: *dataFormat = GL_BGRA; *type = GL_UNSIGNED_BYTE; break; #if ! defined( CINDER_GLES ) case SurfaceChannelOrder::BGR: *dataFormat = GL_BGR; *type = GL_UNSIGNED_BYTE; break; case SurfaceChannelOrder::ARGB: *dataFormat = GL_BGRA; *type = GL_UNSIGNED_INT_8_8_8_8; break; #endif // ! defined( CINDER_GLES ) default: throw TextureDataExc( "Invalid channel order" ); // this is an unsupported channel order for a texture break; } }
Gdiplus::PixelFormat surfaceChannelOrderToGdiplusPixelFormat( const SurfaceChannelOrder &sco, bool premultiplied ) { switch( sco.getCode() ) { case SurfaceChannelOrder::BGR: return PixelFormat24bppRGB; break; case SurfaceChannelOrder::BGRX: // untested code path return PixelFormat32bppRGB; break; case SurfaceChannelOrder::BGRA: return ( premultiplied ) ? PixelFormat32bppPARGB : PixelFormat32bppARGB; break; default: return PixelFormatUndefined; } }