2

I have an 8-bit colour depth surface and some 8-bit colours, and I set the surface up like this:

self.surf = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT)).convert(8)
self.surf.set_palette(self.colours)

I tried to make the display 8-bit so I wouldn't have to blit the surface to it as I wondered if I could just set the pixels on the display screen directly. First I tried:

screen = pygame.display.set_mode(size = (SCREEN_WIDTH, SCREEN_HEIGHT), depth = 8)

and

pygame.display.set_palette(self.colours)

But it said:

pygame.error: Display mode is not colormapped

So I tried:

self.surf = pygame.display.get_surface().convert(8)
self.surf.set_palette(self.colours)

and:

self.surf.set_at((i, index), the_colour)

But nothing seems to work. Is there a way to address the display directly similar to how you can with a surface and set_at?

marienbad
  • 1,461
  • 1
  • 9
  • 19

1 Answers1

1

This is a backwards compatibility bug in pygame 2. https://github.com/pygame/pygame/issues/991.

You could get around this by downgrading to pygame 1.9.6, but I would recommend staying on pygame 2 to take advantage of all the new features.

Starbuck5
  • 1,649
  • 2
  • 7
  • 13
  • Interestingly, if I do: `screen_surf = pygame.display.get_surface().convert(8) print('get depth = {}'.format(screen_surf.get_bitsize()))` it shows bit depth as 8! – marienbad May 14 '21 at 06:19