首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SDL DisplayFormat做矩形

SDL DisplayFormat做矩形
EN

Stack Overflow用户
提问于 2011-12-24 00:51:39
回答 1查看 122关注 0票数 0

总的来说,我是SDL和C++的新手。

然而,当我在图像上执行DisplayFormat以加快blitting速度时,它会使其成为一个矩形。

代码语言:javascript
复制
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时,圆仍然是一个圆。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-24 00:54:23

这是因为您要将图像转换为的显示格式不支持透明像素。您必须将视频模式设置为每像素32位,如下所示:

代码语言:javascript
复制
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface *window = SDL_SetVideoMode(width, height, 32, flags);

// ...

您还需要将SDL_DisplayFormat更改为SDL_DisplayFormatAlpha

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8618597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档