更新时间:2023-10-20 11:19:52
看看 SDL_image 库.它提供了类似IMG_LoadPNG
的功能,可以将图片作为" SDL_Surface加载.
由于您已经在使用SDL,因此它应该非常适合您的程序.
Have a look at the SDL_image library. It offers functions like IMG_LoadPNG
that load your picture "as an" SDL_Surface.
Since you already work with SDL this should fit quite well in your program.
摘录自 SDL_image文档:
// Load sample.png into image
SDL_Surface* image = IMG_Load("sample.png");
if (image == nullptr) {
std::cout << "IMG_Load: " << IMG_GetError() << "\n";
}