I am trying to get 48x48 or 256x256 icons from files on Windows and are facing what seems like a dead end. At the moment I have a HICON descriptor (since PySides QFileIconProvider returns only 32x32 icons) in python, which I would like to show in the pyside window, but functions like QPixmap.fromHICON / HBITMAP are not implemented and also seem to have been removed from source since Qt 4.8 (?). In addition, I try not to save the icon in the file.
So, is there a way to get HICON, or perhaps any other things you can include it in, with any PySide object?
EDIT: I tried to just rewrite the old function from the WinHBITMAP function in python, but that is not great. I'm not sure how I can translate the src string in python, and I don't even know how to change the value of the memory buffer returned by QImage.scanLine ()
for (int y=0; y<h; ++y) { QRgb *dest = (QRgb *) image.scanLine(y); const QRgb *src = (const QRgb *) (data + y * bytes_per_line); for (int x=0; x<w; ++x) { dest[x] = src[x] | mask; } }
I am currently creating PyCBITMAP from HICON with win32api and retrieving a list of bits.
for y in range(0, hIcon.height): dest = i.scanLine(y) src = bitmapbits[y*hIcon.widthBytes:(y*hIcon.widthBytes)+hIcon.widthBytes] for x in range(0, hIcon.width): dest[x] = bytes(ctypes.c_uint32(src[x] | 0))
As a result of "ValueError: unable to resize memoryview object"
The source for the function can be found here: http://www.qtcentre.org/threads/19188-Converting-from-HBitmap-to-a-QPixmap?p=94747#post94747
source share