浏览代码

Refactored img_open and img_check

master
Bert 14 年前
父节点
当前提交
1576eb4e17
共有 1 个文件被更改,包括 12 次插入10 次删除
  1. +12
    -10
      image.c

+ 12
- 10
image.c 查看文件

@@ -52,7 +52,7 @@ void img_free(img_t* img) {
imlib_free_image(); imlib_free_image();
} }


int img_check(const char *filename) {
int _imlib_load_image(const char *filename) {
Imlib_Image *im; Imlib_Image *im;


if (!filename) if (!filename)
@@ -65,28 +65,30 @@ int img_check(const char *filename) {


imlib_context_set_image(im); imlib_context_set_image(im);
imlib_image_set_changes_on_disk(); imlib_image_set_changes_on_disk();
imlib_free_image();

return 1; return 1;
} }


int img_load(img_t *img, const char *filename) {
Imlib_Image *im;
int img_check(const char *filename) {
int ret;

if ((ret = _imlib_load_image(filename)))
imlib_free_image();


return ret;
}

int img_load(img_t *img, const char *filename) {
if (!img || !filename) if (!img || !filename)
return 0; return 0;


if (imlib_context_get_image()) if (imlib_context_get_image())
imlib_free_image(); imlib_free_image();


if (!(im = imlib_load_image(filename))) {
WARN("could not open image: %s", filename);
if (!_imlib_load_image(filename))
return 0; return 0;
}


imlib_context_set_image(im);
imlib_context_set_anti_alias(img->aa); imlib_context_set_anti_alias(img->aa);
imlib_image_set_changes_on_disk();


img->re = 0; img->re = 0;
img->checkpan = 0; img->checkpan = 0;


正在加载...
取消
保存