texture: in case of ImageData contain width/height to 0, just create a fake 1x1 texture to prevent crash.

This commit is contained in:
Mathieu Virbel 2012-05-01 22:49:58 +02:00
parent 2df010e711
commit 6fd5c43ffa
1 changed files with 7 additions and 1 deletions

View File

@ -534,6 +534,7 @@ def texture_create_from_data(im, mipmap=False):
cdef int width = im.width
cdef int height = im.height
cdef int allocate = 1
cdef int no_blit = 0
cdef Texture texture
# optimization, if the texture is power of 2, don't allocate in
@ -551,12 +552,17 @@ def texture_create_from_data(im, mipmap=False):
if gl_get_version_major() < 3:
mipmap = False
if width == 0 or height == 0:
height = width = 1
allocate = 1
no_blit = 1
texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate)
if texture is None:
return None
texture._source = im.source
texture.blit_data(im)
if no_blit == 0:
texture.blit_data(im)
return texture