mirror of
https://github.com/SFML/SFML.git
synced 2024-11-29 06:41:05 +08:00
Fixed crash when creating an empty sf::Image
This commit is contained in:
parent
5207930169
commit
ac43578f75
@ -44,6 +44,8 @@ m_size(0, 0)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Image::create(unsigned int width, unsigned int height, const Color& color)
|
void Image::create(unsigned int width, unsigned int height, const Color& color)
|
||||||
|
{
|
||||||
|
if (width && height)
|
||||||
{
|
{
|
||||||
// Assign the new size
|
// Assign the new size
|
||||||
m_size.x = width;
|
m_size.x = width;
|
||||||
@ -63,12 +65,20 @@ void Image::create(unsigned int width, unsigned int height, const Color& color)
|
|||||||
*ptr++ = color.a;
|
*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)
|
void Image::create(unsigned int width, unsigned int height, const Uint8* pixels)
|
||||||
{
|
{
|
||||||
if (pixels)
|
if (pixels && width && height)
|
||||||
{
|
{
|
||||||
// Assign the new size
|
// Assign the new size
|
||||||
m_size.x = width;
|
m_size.x = width;
|
||||||
|
Loading…
Reference in New Issue
Block a user