FIBITMAP to SDL_Surface?

This is a discussion on FIBITMAP to SDL_Surface? within the C++ Programming forums, part of the General Programming Boards category; I'm having problems converting a FIBITMAP to SDL_Surface. heres the function: Code: SDL_Surface *FiBitmapToSdlSurface(FIBITMAP *fb) { int h = FreeImage_GetHeight(fb), ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Question FIBITMAP to SDL_Surface?

    I'm having problems converting a FIBITMAP to SDL_Surface.

    heres the function:

    Code:
    SDL_Surface *FiBitmapToSdlSurface(FIBITMAP *fb) {
       int h = FreeImage_GetHeight(fb), w = FreeImage_GetWidth(fb);
       SDL_Surface* surf = SDL_CreateRGBSurfaceFrom(FreeImage_GetBits(fb),
          w, h, 32, w * 3, 0xff0000, 0x00ff00, 0x0000ff, 0);
       return surf;
    }
    It gives me a surface of the specified size, but the image is all messed up.

    Help would be appreciated.
    Last edited by Erin100280; 09-05-2010 at 02:01 AM.

  2. #2
    msh
    msh is offline
    Novice
    Join Date
    Jul 2009
    Posts
    568
    Have you tried using FreeImage_GetBPP(), FreeImage_GetRedMask(),
    FreeImage_GetGreenMask() and FreeImage_GetBlueMask(), as recommended by the documentation of FreeImage_GetBits(), instead of hardcoded values as you appear to be doing?

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21