Inform the user of libgd and system limitations when applicable.
This is necessary, because libgd may fail, or print some unintelligible message when these limits are reached. Known limitations: - libgd refuses to create images larger than approx INT_MAX (2^31-1) pixels (a little over 46300x46300), even on 64-bit systems. - on a 32-bit system, in practise, the largest size that can be generated is a little over 24100x24100 pixels.master
parent
c1f2df705b
commit
62f004ae0a
|
@ -603,6 +603,21 @@ void TileGenerator::createImage()
|
|||
pictHeight += (tileBorderZLimit - tileBorderZStart) * m_tileBorderSize;
|
||||
}
|
||||
|
||||
// Print some useful messages in cases where it may not be possible to generate the image...
|
||||
long long pixels = static_cast<long long>(pictWidth + m_border) * (pictHeight + m_border);
|
||||
// Study the libgd code to known why the maximum is the following:
|
||||
long long max_pixels = INT_MAX - INT_MAX % pictHeight;
|
||||
if (pixels > max_pixels) {
|
||||
cerr << "WARNING: Image will have " << pixels << " pixels; the PNG graphics library will refuse to handle more than approximately " << INT_MAX << std::endl;
|
||||
}
|
||||
// Estimated approximate maximum was determined by trial and error...
|
||||
// (24100x24100 succeeded; 24200x24200 failed)
|
||||
#define ESTIMATED_MAX_PIXELS_32BIT (24100*24100L)
|
||||
else if (sizeof(void *) == 4 && pixels > ESTIMATED_MAX_PIXELS_32BIT) {
|
||||
cerr << "WARNING: Image will have " << pixels << " pixels; The maximum achievable on a 32-bit system is approximately " << ESTIMATED_MAX_PIXELS_32BIT << std::endl;
|
||||
}
|
||||
#undef ESTIMATED_MAX_PIXELS_32BIT
|
||||
|
||||
m_image = gdImageCreateTrueColor(pictWidth + m_border, pictHeight + m_border);
|
||||
if (!m_image) {
|
||||
ostringstream oss;
|
||||
|
|
Loading…
Reference in New Issue