All pastes #991822 Raw Edit

set_pixel_color

public c v1 · immutable
#991822 ·published 2008-04-21 12:11 UTC
rendered paste body
void		set_pixel_color(SDL_Surface *s, int x, int y, unsigned int c){  int		bpp;  int		byte;  unsigned char	*data;  bpp = s->format->BytesPerPixel;  data = (unsigned char *)(s->pixels) + y * s->pitch + x * bpp;  byte = 0;#if SDL_BYTEORDER == SDL_BIG_ENDIAN  while (byte < bpp)  {    data[byte] = c >> ((bpp - 1 - byte) * 8);    byte++;  }#else  while (byte < bpp)  {    data[byte] = c >> (byte * 8);    byte++;  }#endif  return ;}