| 14 | #include <stdlib.h> |
| 15 | |
| 16 | int testImage(SDL_Surface* screen, const char* fileName) { |
| 17 | printf("testImage: %s\n", fileName); |
| 18 | |
| 19 | SDL_Surface *image = IMG_Load(fileName); |
| 20 | if (!image) |
| 21 | { |
| 22 | printf("IMG_Load: %s\n", IMG_GetError()); |
| 23 | return 0; |
| 24 | } |
| 25 | assert(image->format->BitsPerPixel == 32); |
| 26 | assert(image->format->BytesPerPixel == 4); |
| 27 | assert(image->pitch == 4*image->w); |
| 28 | int result = image->w; |
| 29 | |
| 30 | SDL_BlitSurface (image, NULL, screen, NULL); |
| 31 | |
| 32 | int w, h; |
| 33 | char *data = emscripten_get_preloaded_image_data(fileName, &w, &h); |
| 34 | |
| 35 | assert(data); |
| 36 | assert(w == image->w); |
| 37 | assert(h == image->h); |
| 38 | |
| 39 | SDL_FreeSurface (image); |
| 40 | free(data); |
| 41 | |
| 42 | return result; |
| 43 | } |
| 44 | |
| 45 | int main() { |
| 46 | SDL_Init(SDL_INIT_VIDEO); |