nsxiv1576eb4
Refactored img_open and img_check
+12 −10
1 file changed
- M image.c +12 −10
| @@ -52,7 +52,7 @@ void img_free(img_t* img) { | |||
| 52 | 52 | imlib_free_image(); | |
| 53 | 53 | } | |
| 54 | 54 | ||
| 55 | − | int img_check(const char *filename) { | |
| 55 | + | int _imlib_load_image(const char *filename) { | |
| 56 | 56 | Imlib_Image *im; | |
| 57 | 57 | ||
| 58 | 58 | if (!filename) | |
| @@ -65,28 +65,30 @@ int img_check(const char *filename) { | |||
| 65 | 65 | ||
| 66 | 66 | imlib_context_set_image(im); | |
| 67 | 67 | imlib_image_set_changes_on_disk(); | |
| 68 | − | imlib_free_image(); | |
| 69 | − | ||
| 68 | + | ||
| 70 | 69 | return 1; | |
| 71 | 70 | } | |
| 72 | 71 | ||
| 73 | − | int img_load(img_t *img, const char *filename) { | |
| 74 | − | Imlib_Image *im; | |
| 72 | + | int img_check(const char *filename) { | |
| 73 | + | int ret; | |
| 74 | + | ||
| 75 | + | if ((ret = _imlib_load_image(filename))) | |
| 76 | + | imlib_free_image(); | |
| 75 | 77 | ||
| 78 | + | return ret; | |
| 79 | + | } | |
| 80 | + | ||
| 81 | + | int img_load(img_t *img, const char *filename) { | |
| 76 | 82 | if (!img || !filename) | |
| 77 | 83 | return 0; | |
| 78 | 84 | ||
| 79 | 85 | if (imlib_context_get_image()) | |
| 80 | 86 | imlib_free_image(); | |
| 81 | 87 | ||
| 82 | − | if (!(im = imlib_load_image(filename))) { | |
| 83 | − | WARN("could not open image: %s", filename); | |
| 88 | + | if (!_imlib_load_image(filename)) | |
| 84 | 89 | return 0; | |
| 85 | − | } | |
| 86 | 90 | ||
| 87 | − | imlib_context_set_image(im); | |
| 88 | 91 | imlib_context_set_anti_alias(img->aa); | |
| 89 | − | imlib_image_set_changes_on_disk(); | |
| 90 | 92 | ||
| 91 | 93 | img->re = 0; | |
| 92 | 94 | img->checkpan = 0; | |