Fixed crash when creating an empty sf::Image

This commit is contained in:
Laurent Gomila 2012-05-10 22:48:02 +02:00
parent 5207930169
commit ac43578f75

View File

@ -45,6 +45,8 @@ m_size(0, 0)
////////////////////////////////////////////////////////////
void Image::create(unsigned int width, unsigned int height, const Color& color)
{
if (width && height)
{
// Assign the new size
m_size.x = width;
m_size.y = height;
@ -62,13 +64,21 @@ void Image::create(unsigned int width, unsigned int height, const Color& color)
*ptr++ = color.b;
*ptr++ = color.a;
}
}
else
{
// Create an empty image
m_size.x = 0;
m_size.y = 0;
m_pixels.clear();
}
}
////////////////////////////////////////////////////////////
void Image::create(unsigned int width, unsigned int height, const Uint8* pixels)
{
if (pixels)
if (pixels && width && height)
{
// Assign the new size
m_size.x = width;