~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/sdl_image_jpeg.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <SDL/SDL.h>
 
3
#include <SDL/SDL_image.h>
 
4
#include <assert.h>
 
5
#include <emscripten.h>
 
6
 
 
7
int testImage(SDL_Surface* screen, const char* fileName) {
 
8
  SDL_Surface *image = IMG_Load(fileName);
 
9
  if (!image)
 
10
  {
 
11
     printf("IMG_Load: %s\n", IMG_GetError());
 
12
     return 0;
 
13
  }
 
14
  assert(image->format->BitsPerPixel == 32);
 
15
  assert(image->format->BytesPerPixel == 4);
 
16
  assert(image->pitch == 4*image->w);
 
17
  int result = image->w;
 
18
 
 
19
  SDL_BlitSurface (image, NULL, screen, NULL);
 
20
  SDL_FreeSurface (image);
 
21
 
 
22
  return result;
 
23
}
 
24
 
 
25
int main() {
 
26
  SDL_Init(SDL_INIT_VIDEO);
 
27
  SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_SWSURFACE);
 
28
 
 
29
  int result = 0;
 
30
  result = testImage(screen, "screenshot.jpeg"); // relative path
 
31
  assert(result != 0);
 
32
  result |= testImage(screen, "/screenshot.jpeg"); // absolute path
 
33
  assert(result != 0);
 
34
 
 
35
  SDL_Flip(screen);
 
36
 
 
37
  printf("you should see an image.\n");
 
38
 
 
39
  SDL_Quit();
 
40
 
 
41
  REPORT_RESULT();
 
42
 
 
43
  return 0;
 
44
}
 
45