首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >pywin32: GetSystemPaletteEntries

pywin32: GetSystemPaletteEntries
EN

Stack Overflow用户
提问于 2011-01-05 23:53:51
回答 1查看 161关注 0票数 1

有没有用于pywin32的等价物GetSystemPaletteEntries?如果没有,我怎么打这个电话?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-06 00:26:15

这是可行的,返回一个与PIL兼容的调色板:

代码语言:javascript
运行
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4606075

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档