MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / testImage

Function testImage

test/browser/test_sdl_image.c:16–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include <stdlib.h>
15
16int 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
45int main() {
46 SDL_Init(SDL_INIT_VIDEO);

Callers 1

mainFunction · 0.70

Calls 3

printfFunction · 0.85
assertFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected