Changeset 1183


Ignore:
Timestamp:
Apr 3, 2012, 1:24:59 AM (9 years ago)
Author:
sam
Message:

sdl: convert any opened image to 8 bit per channel because we don't have
any mechanism yet for uploading exotic formats to the GPU.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/image/codec/sdl-image.cpp

    r962 r1183  
    4040    virtual void *GetData() const;
    4141
     42    static SDL_Surface *Create32BppSurface(ivec2 size);
     43
    4244private:
    4345    SDL_Surface *img;
     
    6365
    6466    size = ivec2(img->w, img->h);
     67
     68    if (img->format->BytesPerPixel != 4)
     69    {
     70        SDL_Surface *tmp = Create32BppSurface(size);
     71        SDL_BlitSurface(img, NULL, tmp, NULL);
     72        SDL_FreeSurface(img);
     73        img = tmp;
     74    }
     75
    6576    format = img->format->Amask ? Image::FORMAT_RGBA : Image::FORMAT_RGB;
    6677
     
    8091}
    8192
     93SDL_Surface *SdlImageData::Create32BppSurface(ivec2 size)
     94{
     95    uint32_t rmask, gmask, bmask, amask;
     96#if SDL_BYTEORDER == SDL_BIG_ENDIAN
     97    rmask = 0xff000000;
     98    gmask = 0x00ff0000;
     99    bmask = 0x0000ff00;
     100    amask = 0x000000ff;
     101#else
     102    rmask = 0x000000ff;
     103    gmask = 0x0000ff00;
     104    bmask = 0x00ff0000;
     105    amask = 0xff000000;
     106#endif
     107
     108    return SDL_CreateRGBSurface(SDL_SWSURFACE, size.x, size.y, 32,
     109                                rmask, gmask, bmask, amask);
     110}
     111
    82112} /* namespace lol */
    83113
Note: See TracChangeset for help on using the changeset viewer.