pywin32: GetSystemPaletteEntries - PullRequest
       3

pywin32: GetSystemPaletteEntries

1 голос
/ 05 января 2011

Есть ли эквивалент GetSystemPaletteEntries для pywin32? если нет, как я могу сделать этот звонок?

1 Ответ

1 голос
/ 05 января 2011

Это работает, возвращая PIL-совместимую палитру:

import ctypes, win32gui
def getPalette(hwnd):
    #hwnd = win32gui.GetDesktopWindow() #if you want desktop window palette?

    hwndDC = win32gui.GetWindowDC(hwnd)

    buff = ctypes.c_buffer("0"*(256*4)) #R, G, B, and flags
    ctypes.windll.gdi32.GetSystemPaletteEntries(hwndDC, 0, 256, buff)

    win32gui.ReleaseDC(hwnd, hwndDC)

    #ignore every 4th entry which is the flags
    res = [ord(x) for i,x in enumerate(buff) if i%4 != 3]
    return res
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...