~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-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

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