本文整理汇总了C++中GImage::byte方法的典型用法代码示例。如果您正苦于以下问题:C++ GImage::byte方法的具体用法?C++ GImage::byte怎么用?C++ GImage::byte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GImage
的用法示例。
在下文中一共展示了GImage::byte方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setIcon
void SDLWindow::setIcon(const GImage& image) {
alwaysAssertM((image.channels == 3) ||
(image.channels == 4),
"Icon image must have at least 3 channels.");
#ifdef G3D_WIN32
alwaysAssertM((image.width == 32) && (image.height == 32),
"Icons must be 32x32 on windows.");
#endif
uint32 amask = 0xFF000000;
uint32 bmask = 0x00FF0000;
uint32 gmask = 0x0000FF00;
uint32 rmask = 0x000000FF;
if (image.channels == 3) {
// Take away the 4th channel.
amask = 0x00000000;
}
int pixelBitLen = image.channels * 8;
int scanLineByteLen = image.channels * image.width;
SDL_Surface* surface =
SDL_CreateRGBSurfaceFrom((void*)image.byte(), image.width, image.height,
pixelBitLen, scanLineByteLen,
rmask, gmask, bmask, amask);
alwaysAssertM((surface != NULL),
"Icon data failed to load into SDL.");
// Let SDL create mask from image data directly
SDL_WM_SetIcon(surface, NULL);
SDL_FreeSurface(surface);
}