分类: LINUX
2006-05-26 10:19:18
|
提示 #1: 如果你需要多次显示某个图片,你可以调用 SDL_DisplayFormat()将图片转换成屏幕的格式,从而提高blit的速度。 提示 #2: |
例程:void ShowBMP(char *file, SDL_Surface *screen, int x, int y)
{
SDL_Surface *image;
SDL_Rect dest;
/* 将BMP文件加载到一个surface*/
image = SDL_LoadBMP(file);
if ( image == NULL ) {
fprintf(stderr, "无法加载 %s: %s\n", file, SDL_GetError());
return;
}
/* Blit到屏幕surface。onto the screen surface.
这时不能锁住surface。
*/
dest.x = x;
dest.y = y;
dest.w = image->w;
dest.h = image->h;
SDL_BlitSurface(image, NULL, screen, &dest);
/* 刷新屏幕的变化部分 */
SDL_UpdateRects(screen, 1, &dest);
}
|