开发者

pywin32: GetSystemPaletteEntries

开发者 https://www.devze.com 2023-02-02 08:32 出处:网络
Is there an 开发者_如何学Goequivalent of GetSystemPaletteEntries for pywin32? if not, how can I make this call?This works, returning a PIL-compatible palette:

Is there an 开发者_如何学Goequivalent of GetSystemPaletteEntries for pywin32? if not, how can I make this call?


This works, returning a PIL-compatible palette:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号