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

« back to all changes in this revision

Viewing changes to tests/sdl_stb_image.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
SDL_Surface* screen;
 
8
 
 
9
int testImage(const char* fileName) {
 
10
  SDL_Surface *image = IMG_Load(fileName);
 
11
  if (!image)
 
12
  {
 
13
     printf("IMG_Load: %s\n", IMG_GetError());
 
14
     return 0;
 
15
  }
 
16
  assert(image->format->BitsPerPixel == 32);
 
17
  assert(image->format->BytesPerPixel == 4);
 
18
  assert(image->pitch == 4*image->w);
 
19
  int result = image->w;
 
20
 
 
21
  SDL_BlitSurface (image, NULL, screen, NULL);
 
22
  SDL_FreeSurface (image);
 
23
 
 
24
  return result;
 
25
}
 
26
 
 
27
void ready() {
 
28
  printf("ready!\n");
 
29
 
 
30
  testImage("screenshot.jpg"); // relative path
 
31
 
 
32
  SDL_Flip(screen);
 
33
}
 
34
 
 
35
int main() {
 
36
  SDL_Init(SDL_INIT_VIDEO);
 
37
  screen = SDL_SetVideoMode(600, 450, 32, SDL_SWSURFACE);
 
38
 
 
39
  printf("rename..\n");
 
40
 
 
41
  rename("screenshot.not", "screenshot.jpg");
 
42
 
 
43
  printf("decode..\n");
 
44
 
 
45
  ready();
 
46
 
 
47
  return 0;
 
48
}
 
49