我在GameDv的SDL2上关注this tutorial,我在尝试加载PNG时遇到了此错误。 这是我的代码:
void Game::Init(const char * title, int x_pos, int y_pos, int width, int height, bool fullscreen)
{
int flags = 0;
if (fullscreen) {
flags = SDL_WINDOW_FULLSCREEN;
}
if (SDL_Init(SDL_INIT_EVERYTHING) == 0) {
std::cout << "Subsystems Initialized" << std::endl;
window = SDL_CreateWindow(title, x_pos, y_pos, width, height, flags);
if (window) {
std::cout << "Window Created..." << std::endl;
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer) {
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
std::cout << "Renderer Created..." << std::endl;
}
is_running = 1;
}
SDL_Surface * buf_surface = IMG_Load("assets/potato.png");
std::cout << SDL_GetError() << std::endl;
potato_texture = SDL_CreateTextureFromSurface(renderer, buf_surface);
SDL_FreeSurface(buf_surface);
}
这是错误: libpng错误:IDAT:块数据太大 读取PNG文件时出错。
有什么建议吗? PS这是我第一次发布抱歉,如果我做错了。