mirror of
https://github.com/minetest/minetestmapper.git
synced 2024-12-26 19:00:37 +01:00
Support all image formats offered by libgd
This commit is contained in:
parent
b16f93f183
commit
75599e8569
13
Image.cpp
13
Image.cpp
@ -103,12 +103,9 @@ void Image::drawCircle(int x, int y, int diameter, const Color &c)
|
|||||||
|
|
||||||
void Image::save(const std::string &filename)
|
void Image::save(const std::string &filename)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(filename.c_str(), "wb");
|
const char *f = filename.c_str();
|
||||||
if(!f) {
|
if (gdSupportsFileType(f, 1) == GD_FALSE)
|
||||||
std::ostringstream oss;
|
throw std::runtime_error("Image format not supported by gd");
|
||||||
oss << "Error writing image file: " << std::strerror(errno);
|
if (gdImageFile(m_image, f) == GD_FALSE)
|
||||||
throw std::runtime_error(oss.str());
|
throw std::runtime_error("Error saving image");
|
||||||
}
|
|
||||||
gdImagePng(m_image, f); // other formats?
|
|
||||||
fclose(f);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user