#### Archived

This topic is now archived and is closed to further replies.

# What's wrong with this code?!

This topic is 5699 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

  Uint8 *pixels = (Uint8*)dest_surface->pixels;
Uint8 *oldpixels = (Uint8*)src_surface->pixels;

pixels[CurrentDestX * dest_surface->format->BytesPerPixel  + CurrentDestY * dest_surface->pitch] = oldpixels[CurrentDestX  * src_surface->format->BytesPerPixel + CurrentDestY * src_surface->pitch];  
The surfaces are SDL surfaces, btw. I want to copy one surface onto another. Don''t say I could just use blit, cause I know that. I''m trying to write code that will smooth a scaled surface, but I can''t even get this little bit of code to work. What''s happening is if I have that X * Bpp stuff, the surface is completely black. If I get rid of the Bpp part, it draws 1/4 of the surface, starting from the left side. It draws all the vertical part, but stops 1/4 of the way over. What''s wierd is that the 1/4 part it draws is drawn perfectly, not distorted like it should be if its not moving over far enough in memory.

##### Share on other sites
It will only copy the first byte of each pixel...

Joakim Asplund
http://megajocke.cjb.net