Пример #1
0
 def rawtile_data_rot(self, udata):
     """Alazane's Method of rotating the Maptile to a 44x44 bitmap
     a bit buggy d'oh."""
     image = StandardSurface()
     image.new((44, 44))
     xstart = 0
     ystart = 1
     i = 0
     while xstart <= 44:
         x = xstart
         y = ystart
         while (x <= 44) and (y >= 0):
             image.dot((x, y), rgb555_rgb(udata[i]))
             image.dot((x + 1, y), rgb555_rgb(udata[i]))
             image.dot((x, y + 1), rgb555_rgb(udata[i]))
             i += 1
             x += 1
             y -= 1
         if ystart < 43:
             ystart += 2
         elif ystart == 43:
             ystart += 1
             xstart += 1
         else:
             xstart += 2
     return image
Пример #2
0
def get_image_from_rawtile_udata(udata, surface=None):
    """generates a map image from unpacked data"""
    image = surface
    # print len(udata)
    if not surface:
        image = StandardSurface()
        image.new((44, 44))
    o = 0
    for y in xrange(22):
        p = y + 1
        pixels = udata[o : o + p * 2]
        # spiegels = whole_data[ len(whole_data) / 2 + o: o + p * 2 - 1 ]
        for x in xrange(len(pixels)):
            image.dot((21 - y + x, y), rgb555_rgb(pixels[x]))
        o += len(pixels)
    for y in xrange(22):
        realy = 22 + y
        numx = 44 - y * 2
        pixels = udata[o : o + numx]
        for x in xrange(len(pixels)):
            image.dot((x + y, realy), rgb555_rgb(pixels[x]))
        o += len(pixels)
    return image
Пример #3
0
def image_from_tex_udata( udata = None ):
    if udata:
        size = 0
        if len(udata) == 0x4000: # 0x8000 bytes! 
            size = 128
        elif len(udata) == 0x1000:
            size = 64
        if not size:
            raise Exception( "Unknown Size!" + str(len(udata)))
        image = StandardSurface()
        image.new((size, size))
        for y in xrange(size):
            for x in xrange(size):
                image.dot( (x, y), rgb555_rgb(udata[ y * size + x ]) )
        return image
Пример #4
0
def get_image_from_runtile_udata(udata, surface=None):
    """generates image object from unpacked data."""
    if udata:
        # prepare header data
        width = udata[0]
        height = udata[1]
        if (width >= 1024) or (width <= 0) or (height <= 0) or (height >= 1024):
            return None
        if surface:
            image = surface
        else:
            image = StandardSurface()
            image.new((width, height))
        lstart = udata[2 : 2 + height]
        udata = udata[2 + height :]
        x = 0
        y = 0
        o = y
        while y < height:
            xoffset = udata[lstart[y] + o]
            xrun = udata[lstart[y] + o + 1]
            # print "xrun %s xoffset %s" % (xrun, xoffset)
            o += 2
            if (xoffset + xrun) >= 2048:
                pass
            elif (xoffset + xrun) != 0:
                x += xoffset
                for i in xrange(xrun):
                    if (x + i) < width:
                        try:
                            image.dot((x + i, y), rgb555_rgb(udata[lstart[y] + o + i]))
                        except:
                            print "Ooops"
                x += xrun
                o += xrun
            else:
                x = 0
                y += 1
                o = 0
        return image
Пример #5
0
 def get_rgb(self, num):
     """returns a trip-tuple with (r,g,b)"""
     if self.cache:
         return self.cache[num]
     rgb = self.data[ num : num + 1 ][0]
     return rgb555_rgb(rgb)