Merge pull request #57 from jedediah/master

Use pure Python PNG loader instead of pygame.load
This commit is contained in:
David Vierra 2012-03-11 18:33:57 -07:00
commit 6b11355182
2 changed files with 13 additions and 42 deletions

View File

@ -29,7 +29,7 @@ import zipfile
from cStringIO import StringIO
from datetime import datetime
from pygame import image, display
from pygame import image, display, Surface
import png
import config
import release
@ -382,27 +382,6 @@ def loadAlphaTerrainTexture():
def loadPNGData(filename_or_data):
# if filename[1:4] != "PNG":
if isinstance(filename_or_data, basestring):
filename_or_data = os.path.join(mcplatform.dataDir, filename_or_data)
filename_or_data = filename_or_data.encode(sys.getfilesystemencoding())
else:
# path = numpy.fromstring(filename, 'uint8')
pass
try:
img = image.load(filename_or_data)
img = img.convert_alpha()
data = numpy.fromstring(img.get_buffer().raw, 'uint8')
w, h = img.get_size()
data.shape = (h, w, 4) # xxx 32-bit images
format = GL.GL_BGRA
except Exception, e:
print repr(e), "while using pygame to load an image"
reader = png.Reader(filename_or_data)
(w, h, data, metadata) = reader.read_flat()
data = numpy.array(data, dtype='uint8')
@ -415,13 +394,6 @@ def loadPNGData(filename_or_data):
if data.shape[2] < 4:
data = numpy.insert(data, 3, 255, 2)
format = GL.GL_RGBA
if format == GL.GL_BGRA:
temp = numpy.array(data[:, :, 0])
data[:, :, 0] = data[:, :, 2]
data[:, :, 2] = temp
return w, h, data

View File

@ -121,7 +121,6 @@ def main():
data_files = get_data_files('fonts', 'toolicons') + [
('', [
'history.txt',
'README.html',
'favicon.png',
'terrain-classic.png',