Hi,

In the discussion about the QListWidget[1] I saw something that happens to me 
also with the QImage conversion from 12 bits to 8. Remember that I have a 
problem showing grayscaled images[2] I need to say that the data needs to be 
process and it means the solution cannot be simply acquire the pictures in 8 
bits.

Right now I write a loop for the list and then convert to the array of 
unsigned chars need by the QImage. It means touch each element two times. The 
code is:
        #input: values list of the image
        #output: array of unsigned chars for the QImage
        def convertfrom(self,image,bits):
                if self._debug:
                        print "[PyImageViewer]convertfrom():"+str(int(bits*8))
                if depth == 1: # 8 bit grayscale
                        barfoo = image
                elif depth == 1.5: # 12 bits unpacket
                        bar,barfoo = image,[]
                        for i in range(len(bar)):
                                barfoo.append(bar[i].__lshift__(4))#shift to 
loss 4 less significant bits
                        #barfoo = bar
                elif depth == 2: # 16 bits
                        bar,barfoo = image,[]
                        for i in range(len(bar)):
                                barfoo.append(bar[i].__lshift__(8))#shift to 
loss 4 less significant bits
                        #barfoo = bar
                else:
                        raise "Not supported depth"
                return array.array('B',barfoo).tostring()

I am not sure but this tostring() call at the end, maybe means another third 
touch of all the elements to make it worst.

Sano kaj liber!

/Sergi.

[1] http://www.riverbankcomputing.com/pipermail/pyqt/2008-April/019142.html 
[2] http://www.riverbankcomputing.com/pipermail/pyqt/2008-April/019130.html
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to