1

我将灰度图像转换为 numpy 数组。我正在尝试在 sdl2 窗口表面上渲染此图像。

sdl2.ext.init()
self.window = sdl2.ext.Window("Hello World!", size=(W, H)) 
self.window.show()
self.events = sdl2.ext.get_events()
    for event in self.events:
        if event.type == sdl2.SDL_QUIT:
            exit(0)
self.windowsurface = sdl2.SDL_GetWindowSurface(self.window.window)
self.windowArray = sdl2.ext.pixels2d(self.windowsurface.contents)
self.windowArray[:] = frame[:,:,1].swapaxes(0,1)
self.window.refresh()

现在我看到蓝色形式的图像。我想将它渲染为灰度图像。我也尝试探索 sdl2.ext.colorpalettes 但没有成功。

如何在 sdl2 窗口表面上显示灰度 numpy 数组

4

0 回答 0