[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Problem with pygame.image.load() and a gzip.open() stream



On 2/17/07, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
GzipFile could be subclassed to providing a seek() method that takes a
dummy whence argument.

Lenard's suggestion seems to work great:
------------------------
import gzip
import pygame

class GzipImageFile(gzip.GzipFile):
  def seek(self, offset, whence=0):
      assert(whence == 0)
      gzip.GzipFile.seek(self, offset)

fid = GzipImageFile('test.bmp.gz','rb')
theimg = pygame.image.load(fid)
fid.close()

print theimg.get_size()