总的来说,我是SDL和C++的新手。
然而,当我在图像上执行DisplayFormat以加快blitting速度时,它会使其成为一个矩形。
SDL_Surface* tempImage = NULL;
// The image that will be used (optimized)
image = NULL;
image = IMG_Load( filename.c_str() );
if ( tempImage != NULL )
{
// Create optimization
image = SDL_DisplayFormat( tempImage ); // Makes the circle an rectangle
// Free the old image
SDL_FreeSurface( tempImage );
}为什么会这样呢?如果我不做DisplayFormat,当dont时,圆仍然是一个圆。
发布于 2011-12-24 00:54:23
这是因为您要将图像转换为的显示格式不支持透明像素。您必须将视频模式设置为每像素32位,如下所示:
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface *window = SDL_SetVideoMode(width, height, 32, flags);
// ...您还需要将SDL_DisplayFormat更改为SDL_DisplayFormatAlpha。
https://stackoverflow.com/questions/8618597
复制相似问题