Changeset 690


Ignore:
Timestamp:
Feb 22, 2011, 4:52:38 PM (9 years ago)
Author:
sam
Message:

Create a fake Image if SDL_image is not available, so that we can test
stuff anyway.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/image.cpp

    r688 r690  
    4141#if defined USE_SDL
    4242    SDL_Surface *img;
     43#else
     44    uint8_t *dummy;
    4345#endif
    4446};
     
    6870    data->format = data->img->format->Amask ? FORMAT_RGBA : FORMAT_RGB;
    6971#else
    70     data->size = 0;
    71     data->format = FORMAT_UNKNOWN;
     72    data->size = 256;
     73    data->format = FORMAT_RGBA;
     74    data->dummy = (uint8_t *)malloc(256 * 256 * 4 * sizeof(*data->dummy));
     75    uint8_t *parser = data->dummy;
     76    for (int j = 0; j < 256; j++)
     77        for (int i = 0; i < 256; i++)
     78        {
     79            *parser++ = ((i ^ j) & 1) * 0xff;
     80            *parser++ = (uint8_t)i;
     81            *parser++ = (uint8_t)j;
     82            *parser++ = (((i >> 4) ^ (j >> 4)) & 1) * 0xff;
     83        }
    7284#endif
    7385}
     
    8597void * Image::GetData() const
    8698{
     99#if defined USE_SDL
    87100    return data->img->pixels;
     101#else
     102    return data->dummy;
     103#endif
    88104}
    89105
    90106Image::~Image()
    91107{
    92 #if defined USE_LOL
     108#if defined USE_SDL
    93109    SDL_FreeSurface(data->img);
     110#else
     111    free(data->dummy);
    94112#endif
    95113    delete data;
Note: See TracChangeset for help on using the changeset viewer.