Firts fraction of that bitmap looks like below attachement. All goes fine untill x position hits the pixel different than black, no matter what color it is, it gives Bus Error. But when I change declaration of pixel variable from Uint32 to for example unsigned char, there is no Bus Error. Why does it give an error when pixel is declared as Uint32?
And what confuses me more, is that when I use Super Videl it gives no error even when pixel is Uint32.
Whats the magic behind above behaviour?
Resolution is 640x480x8bit
Code: Select all
Uint32 get_pixel( SDL_Surface *surf, int x, int y )
int pos = 0;
Uint32 pixel = 0;
//unsigned char pixel = 0;
pos = y * surf->pitch + x * surf->format->BytesPerPixel;
printf ( "x: %d y: %d pos: %d surf->pitch: %d surf->format->bpp: %d\n", x, y, pos, surf->pitch, surf->format->BytesPerPixel );
memcpy( &pixel, surf->pixels + pos, surf->format->BytesPerPixel );