Jump to content
  • Advertisement


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


SDL: saving bmp from surface

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, as you can probably tell, the purpose of this function is to rotate a 75x75 pixel image surface and then render it to a surface that is 360*75x75 in size. It seems to just junk out in the middle of it for some reason. Any ideas why?
void BSDL::RotateAndSaveImg(char* filename) {
    const int sprite_size = 75;
    SDL_Surface *surface =
        SDL_CreateRGBSurface (SDL_SWSURFACE, 360*sprite_size, sprite_size, 32, 0x000000ff,
			      0x0000ff00, 0x00ff0000, 0xff000000);

    SDL_Surface *rotated_picture;
    //rotated_picture =	rotozoomSurface(image, (double)angle, 1, smooth);

    SDL_Rect dest;
    dest.y = 0;
    for(int a = 0; a<360; a++) {
        dest.x = sprite_size * a;
        rotated_picture = rotozoomSurface(image, (double)a, 1, 1);
        SDL_BlitSurface(rotated_picture, NULL, surface, &dest);

    //int SDL_SaveBMP(SDL_Surface *surface, const char *file)

    SDL_SaveBMP(surface, filename);
[edited by - Woodsman on June 5, 2004 6:35:24 PM]

Share this post

Link to post
Share on other sites
my bet is that the create surface fails.

Did you notice you''re allocating 360*75*75*4=8 megabytes?

Share this post

Link to post
Share on other sites
Wow. Yeah, I was evidently looking in the very wrong places. In fact it shouldn't have been 360 at all anyway, but thanks a lot. Now I simply have to get it to actually print the surface (it saves as black at present.) Thanks again.

EDIT: Everything working like a charm. Cheers.

[edited by - woodsman on June 5, 2004 6:55:51 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!