From bbb2da107ec710b5fb7aae35e5a71c4e9f8dc32a Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Thu, 25 Feb 2010 23:35:49 +0100 Subject: [PATCH] Textures aren't compressed from Murmur 1.2.2 onwards anymore. just need to figure out the format now :/ see #79 --- pyweb/mumble/MumbleCtlIce.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pyweb/mumble/MumbleCtlIce.py b/pyweb/mumble/MumbleCtlIce.py index 1bfcb7c..e0568be 100644 --- a/pyweb/mumble/MumbleCtlIce.py +++ b/pyweb/mumble/MumbleCtlIce.py @@ -135,8 +135,11 @@ def MumbleCtlIce( connstring, slicefile=None, icesecret=None ): if murmurversion == (1, 1, 8): return MumbleCtlIce_118( connstring, meta ); - elif murmurversion[:2] == (1, 2): + elif murmurversion[:2] == (1, 2) and murmurversion[:3] < 2: return MumbleCtlIce_120( connstring, meta ); + + else: + return MumbleCtlIce_122( connstring, meta ); class MumbleCtlIce_118(MumbleCtlBase): @@ -493,3 +496,31 @@ class MumbleCtlIce_120(MumbleCtlIce_118): def setACL(self, srvid, channelid, acls, groups, inherit): return self._getIceServerObject(srvid).setACL( channelid, acls, groups, inherit ); + +class MumbleCtlIce_122(MumbleCtlIce_120): + @protectDjangoErrPage + def getTexture(self, srvid, mumbleid): + texture = self._getIceServerObject(srvid).getTexture(mumbleid) + if len(texture) == 0: + raise ValueError( "No Texture has been set." ); + imgdata = "" + for idx in range( 0, len(texture)-4, 4 ): + bgra = unpack( "4B", texture[idx:idx+4] ); + imgdata += pack( "4B", bgra[2], bgra[1], bgra[0], bgra[3] ); + # return an 600x60 RGBA image object created from the data + return Image.fromstring( "RGBA", ( 88, 60 ), imgdata ); + + @protectDjangoErrPage + def setTexture(self, srvid, mumbleid, infile): + # open image, convert to RGBA, and resize to 600x60 + img = Image.open( infile ).convert( "RGBA" ).transform( ( 88, 60 ), Image.EXTENT, ( 0, 0, 88, 60 ) ); + # iterate over the list and pack everything into a string + bgrastring = ""; + for ent in list( img.getdata() ): + # ent is in RGBA format, but Murmur wants BGRA (ARGB inverse), so stuff needs + # to be reordered when passed to pack() + bgrastring += pack( "4B", ent[2], ent[1], ent[0], ent[3] ); + # finally call murmur and set the texture + self._getIceServerObject(srvid).setTexture(mumbleid, bgrastring) + +