Browse Source

graphics: load_sprite should return a status code

K. Lange 1 year ago
parent
commit
54ec34837b
2 changed files with 6 additions and 2 deletions
  1. 1 1
      base/usr/include/toaru/graphics.h
  2. 5 1
      lib/graphics.c

+ 1 - 1
base/usr/include/toaru/graphics.h

@@ -74,7 +74,7 @@ extern void blur_context_no_vignette(gfx_context_t * _dst, gfx_context_t * _src,
 extern void blur_context_box(gfx_context_t * _src, int radius);
 extern void sprite_free(sprite_t * sprite);
 
-extern void load_sprite(sprite_t * sprite, char * filename);
+extern int load_sprite(sprite_t * sprite, char * filename);
 //extern int load_sprite_png(sprite_t * sprite, char * file);
 extern void draw_sprite(gfx_context_t * ctx, sprite_t * sprite, int32_t x, int32_t y);
 extern void draw_line(gfx_context_t * ctx, int32_t x0, int32_t x1, int32_t y0, int32_t y1, uint32_t color);

+ 5 - 1
lib/graphics.c

@@ -395,9 +395,12 @@ void blur_context_box(gfx_context_t * _src, int radius) {
 	_box_blur_vertical(_src,radius);
 }
 
-void load_sprite(sprite_t * sprite, char * filename) {
+int load_sprite(sprite_t * sprite, char * filename) {
 	/* Open the requested binary */
 	FILE * image = fopen(filename, "r");
+
+	if (!image) return 1;
+
 	size_t image_size= 0;
 
 	fseek(image, 0, SEEK_END);
@@ -517,6 +520,7 @@ void load_sprite(sprite_t * sprite, char * filename) {
 _cleanup_sprite:
 	fclose(image);
 	free(bufferb);
+	return 0;
 }
 
 #ifndef NO_SSE