Mercurial > hg > forks > libbpg
comparison bpgview.c @ 5:524eae707ba4
Cosmetics: Remove trailing whitespace.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 07 Dec 2016 10:38:38 +0200 |
parents | 772086c29cc7 |
children |
comparison
equal
deleted
inserted
replaced
4:bbd61622856a | 5:524eae707ba4 |
---|---|
94 buf = malloc(len); | 94 buf = malloc(len); |
95 if (!buf) | 95 if (!buf) |
96 return NULL; | 96 return NULL; |
97 if (fread(buf, 1, len, f) != len) | 97 if (fread(buf, 1, len, f) != len) |
98 return NULL; | 98 return NULL; |
99 | 99 |
100 frames = NULL; | 100 frames = NULL; |
101 frame_count = 0; | 101 frame_count = 0; |
102 | 102 |
103 s = bpg_decoder_open(); | 103 s = bpg_decoder_open(); |
104 if (bpg_decoder_decode(s, buf, len) < 0) | 104 if (bpg_decoder_decode(s, buf, len) < 0) |
105 goto fail; | 105 goto fail; |
106 bpg_decoder_get_info(s, bi); | 106 bpg_decoder_get_info(s, bi); |
107 #if SDL_BYTEORDER == SDL_BIG_ENDIAN | 107 #if SDL_BYTEORDER == SDL_BIG_ENDIAN |
108 rmask = 0xff000000; | 108 rmask = 0xff000000; |
109 gmask = 0x00ff0000; | 109 gmask = 0x00ff0000; |
120 break; | 120 break; |
121 bpg_decoder_get_frame_duration(s, &delay_num, &delay_den); | 121 bpg_decoder_get_frame_duration(s, &delay_num, &delay_den); |
122 frames = realloc(frames, sizeof(frames[0]) * (frame_count + 1)); | 122 frames = realloc(frames, sizeof(frames[0]) * (frame_count + 1)); |
123 img = SDL_CreateRGBSurface(SDL_HWSURFACE, bi->width, bi->height, 32, | 123 img = SDL_CreateRGBSurface(SDL_HWSURFACE, bi->width, bi->height, 32, |
124 rmask, gmask, bmask, amask); | 124 rmask, gmask, bmask, amask); |
125 if (!img) | 125 if (!img) |
126 goto fail; | 126 goto fail; |
127 | 127 |
128 SDL_LockSurface(img); | 128 SDL_LockSurface(img); |
129 for(y = 0; y < bi->height; y++) { | 129 for(y = 0; y < bi->height; y++) { |
130 bpg_decoder_get_line(s, (uint8_t *)img->pixels + y * img->pitch); | 130 bpg_decoder_get_line(s, (uint8_t *)img->pixels + y * img->pitch); |
131 } | 131 } |
132 SDL_UnlockSurface(img); | 132 SDL_UnlockSurface(img); |
153 if (dc->frame_timer_id) { | 153 if (dc->frame_timer_id) { |
154 /* XXX: the SDL timer API is not safe, so we remove the timer even if it already expired */ | 154 /* XXX: the SDL timer API is not safe, so we remove the timer even if it already expired */ |
155 SDL_RemoveTimer(dc->frame_timer_id); | 155 SDL_RemoveTimer(dc->frame_timer_id); |
156 dc->frame_timer_id = 0; | 156 dc->frame_timer_id = 0; |
157 } | 157 } |
158 dc->frame_timer_id = | 158 dc->frame_timer_id = |
159 SDL_AddTimer(dc->frames[dc->frame_index].delay, timer_cb, NULL); | 159 SDL_AddTimer(dc->frames[dc->frame_index].delay, timer_cb, NULL); |
160 } | 160 } |
161 | 161 |
162 int load_image(DispContext *dc, const char *filename) | 162 int load_image(DispContext *dc, const char *filename) |
163 { | 163 { |
199 free(dc->frames); | 199 free(dc->frames); |
200 if (dc->frame_timer_id) { | 200 if (dc->frame_timer_id) { |
201 SDL_RemoveTimer(dc->frame_timer_id); | 201 SDL_RemoveTimer(dc->frame_timer_id); |
202 dc->frame_timer_id = 0; | 202 dc->frame_timer_id = 0; |
203 } | 203 } |
204 | 204 |
205 dc->frame_count = frame_count; | 205 dc->frame_count = frame_count; |
206 dc->frames = frames; | 206 dc->frames = frames; |
207 dc->frame_index = 0; | 207 dc->frame_index = 0; |
208 dc->loop_counter = 0; | 208 dc->loop_counter = 0; |
209 dc->loop_count = loop_count; | 209 dc->loop_count = loop_count; |
529 break; | 529 break; |
530 default: | 530 default: |
531 break; | 531 break; |
532 } | 532 } |
533 } | 533 } |
534 done: | 534 done: |
535 | 535 |
536 SDL_FreeSurface(dc->screen); | 536 SDL_FreeSurface(dc->screen); |
537 return 0; | 537 return 0; |
538 } | 538 } |