def HPIX(self,pixel):
		""" Half-Byte Packing for 4-Bit and Pixel Data Handler """
		if self.bpp == 4:
			if self.buf == "":
				self.buf = chr(pixel<<4)
			else:
				self.buf = chr(ord(self.buf) | pixel)
				self.tmp.write(self.buf)
				self.buf = ""
		else:
			self.tmp.write(chr(pixel))
 Half-Byte Packing for 4-Bit and Pixel Data Handler 
recipes/Python/577379_BIRLE_Decoder/recipe-577379.py