You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SDL_image初始化失败求助:找不到libpng16-16.dll模块

SDL2 Image Loading Failure: Can't Load BMP File Even After Successful Initialization

I've spent an hour trying to fix this error, searching Stack Overflow and other websites for solutions with no luck. I'm really stuck and need urgent help to get back to learning SDL2.

Software & Library Versions I'm Using:

  • SDL2-2.0.12
  • SDL2_image-2.0.5
  • Visual Studio Community 2019

Problematic Code Section:

bool CApp::OnInit() {
	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
		return false;
	} else {
		std::cout << "SDL was initialized!!!" << std::endl;
	}
	// The window for the game.
	Surf_Window = SDL_CreateWindow("SDL2 Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screenWidth, screenHeight, 0);
	if (Surf_Window == NULL) {
		return false;
	} else {
		std::cout << "Main Window was initialized!!!" << std::endl;
		//Initialize PNG loading
		int imgFlags = IMG_INIT_PNG;
		if (!(IMG_Init(imgFlags) & imgFlags)) {
			printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
			return false;
		} else {
			std::cout << "SDL_image was initialized!!!" << std::endl;
			//Get window surface
			Surf_Display = SDL_GetWindowSurface(Surf_Window);
			if (Surf_Display == NULL) {
				return false;
			}
		}
	}
	// Fill the window with White color.
	SDL_FillRect(Surf_Display, NULL, SDL_MapRGB(Surf_Display->format, 0xFF, 0xFF, 0xFF));
	// The image surface we load.
	const char* image = "data/images/bgHomeScreen.bmp";
	Surf_Test = CApp::OnLoad("data/images/bgHomeScreen.bmp");
	//CSurface::OnLoad(Surf_Test, image);
	if (Surf_Test == NULL) {
		printf("Unable to load image %s! SDL Error: %s\n", "data/images/bgHomeScreen.bmp", SDL_GetError());
		return false;
	}
	SDL_UpdateWindowSurface(Surf_Window);
	SDL_Delay(2000);
	return true;
}

Additional Context:

I've included screenshots of my project settings for reference.

I need to resolve this image loading error so I can continue learning SDL2.

内容的提问来源于stack exchange,提问作者Aeryes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 23:42:56