def RDPBitmapToQtImage(width, height, bitsPerPixel, isCompress, data):
    """
    @summary: Bitmap transformation to Qt object
    @param width: width of bitmap
    @param height: height of bitmap
    @param bitsPerPixel: number of bit per pixel
    @param isCompress: use RLE compression
    @param data: bitmap data
    """
    image = None
    #allocate
    
    if bitsPerPixel == 15:
        if isCompress:
            buf = bytearray(width * height * 2)
            rle.bitmap_decompress(buf, width, height, data, 2)
            image = QtGui.QImage(buf, width, height, QtGui.QImage.Format_RGB555)
        else:
            image = QtGui.QImage(data, width, height, QtGui.QImage.Format_RGB555).transformed(QtGui.QMatrix(1.0, 0.0, 0.0, -1.0, 0.0, 0.0))
    
    elif bitsPerPixel == 16:
        if isCompress:
            buf = bytearray(width * height * 2)
            rle.bitmap_decompress(buf, width, height, data, 2)
            image = QtGui.QImage(buf, width, height, QtGui.QImage.Format_RGB16)
        else:
            image = QtGui.QImage(data, width, height, QtGui.QImage.Format_RGB16).transformed(QtGui.QMatrix(1.0, 0.0, 0.0, -1.0, 0.0, 0.0))
    
    elif bitsPerPixel == 24:
        if isCompress:
            buf = bytearray(width * height * 3)
            rle.bitmap_decompress(buf, width, height, data, 3)
            image = QtGui.QImage(buf, width, height, QtGui.QImage.Format_RGB888)
        else:
            image = QtGui.QImage(data, width, height, QtGui.QImage.Format_RGB888).transformed(QtGui.QMatrix(1.0, 0.0, 0.0, -1.0, 0.0, 0.0))
            
    elif bitsPerPixel == 32:
        if isCompress:
            buf = bytearray(width * height * 4)
            rle.bitmap_decompress(buf, width, height, data, 4)
            image = QtGui.QImage(buf, width, height, QtGui.QImage.Format_RGB32)
        else:
            image = QtGui.QImage(data, width, height, QtGui.QImage.Format_RGB32).transformed(QtGui.QMatrix(1.0, 0.0, 0.0, -1.0, 0.0, 0.0))
    else:
        log.error("Receive image in bad format")
        image = QtGui.QImage(width, height, QtGui.QImage.Format_RGB32)
    return image
def RDPBitmapToQtImage ( width , height , bitsPerPixel , isCompress , data ) : image = None if bitsPerPixel == 15 : if isCompress : buf = bytearray ( width * height * 2 ) rle . bitmap_decompress ( buf , width , height , data , 2 ) image = QtGui . QImage ( buf , width , height , QtGui . QImage . Format_RGB555 ) else : image = QtGui . QImage ( data , width , height , QtGui . QImage . Format_RGB555 ) . transformed ( QtGui . QMatrix ( 1.0 , 0.0 , 0.0 , - 1.0 , 0.0 , 0.0 ) ) elif bitsPerPixel == 16 : if isCompress : buf = bytearray ( width * height * 2 ) rle . bitmap_decompress ( buf , width , height , data , 2 ) image = QtGui . QImage ( buf , width , height , QtGui . QImage . Format_RGB16 ) else : image = QtGui . QImage ( data , width , height , QtGui . QImage . Format_RGB16 ) . transformed ( QtGui . QMatrix ( 1.0 , 0.0 , 0.0 , - 1.0 , 0.0 , 0.0 ) ) elif bitsPerPixel == 24 : if isCompress : buf = bytearray ( width * height * 3 ) rle . bitmap_decompress ( buf , width , height , data , 3 ) image = QtGui . QImage ( buf , width , height , QtGui . QImage . Format_RGB888 ) else : image = QtGui . QImage ( data , width , height , QtGui . QImage . Format_RGB888 ) . transformed ( QtGui . QMatrix ( 1.0 , 0.0 , 0.0 , - 1.0 , 0.0 , 0.0 ) ) elif bitsPerPixel == 32 : if isCompress : buf = bytearray ( width * height * 4 ) rle . bitmap_decompress ( buf , width , height , data , 4 ) image = QtGui . QImage ( buf , width , height , QtGui . QImage . Format_RGB32 ) else : image = QtGui . QImage ( data , width , height , QtGui . QImage . Format_RGB32 ) . transformed ( QtGui . QMatrix ( 1.0 , 0.0 , 0.0 , - 1.0 , 0.0 , 0.0 ) ) else : log . error ( "Receive image in bad format" ) image = QtGui . QImage ( width , height , QtGui . QImage . Format_RGB32 ) return image
@summary: Bitmap transformation to Qt object
    @param width: width of bitmap
    @param height: height of bitmap
    @param bitsPerPixel: number of bit per pixel
    @param isCompress: use RLE compression
    @param data: bitmap data