3
#include <SDL/SDL_image.h>
5
#include <emscripten.h>
7
int testImage(SDL_Surface* screen, const char* fileName) {
8
SDL_Surface *image = IMG_Load(fileName);
11
printf("IMG_Load: %s\n", IMG_GetError());
14
assert(image->format->BitsPerPixel == 32);
15
assert(image->format->BytesPerPixel == 4);
16
assert(image->pitch == 4*image->w);
17
int result = image->w;
19
SDL_BlitSurface (image, NULL, screen, NULL);
20
SDL_FreeSurface (image);
26
SDL_Init(SDL_INIT_VIDEO);
27
SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_SWSURFACE);
30
result = testImage(screen, "screenshot.jpeg"); // relative path
32
result |= testImage(screen, "/screenshot.jpeg"); // absolute path
37
printf("you should see an image.\n");