Thread: FIBITMAP to SDL_Surface?

  1. #1
    Registered User
    Join Date
    Aug 2010

    Question FIBITMAP to SDL_Surface?

    I'm having problems converting a FIBITMAP to SDL_Surface.

    heres the function:

    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 01:01 AM.

  2. #2
    Join Date
    Jul 2009
    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
Website Security Test