From 244b63e6b5bd039980aa0ea2ac8cbd6ca27b9fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sat, 14 Apr 2012 11:29:14 +0200 Subject: [PATCH] WindowMaker: New get_texture_image function The new function get_texture_image includes the common code of wTextureMakePixmap() and wTextureMakeTGradient() --- src/texture.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/texture.c b/src/texture.c index a18ed228..dca7b98d 100644 --- a/src/texture.c +++ b/src/texture.c @@ -36,6 +36,7 @@ extern WPreferences wPreferences; static void bevelImage(RImage * image, int relief); +static RImage * get_texture_image(WScreen *scr, char *pixmap_file); WTexSolid *wTextureMakeSolid(WScreen * scr, XColor * color) { @@ -265,20 +266,10 @@ WTexPixmap *wTextureMakePixmap(WScreen * scr, int style, char *pixmap_file, XCol WTexPixmap *texture; XGCValues gcv; RImage *image; - char *file; - file = FindImage(wPreferences.pixmap_path, pixmap_file); - if (!file) { - wwarning(_("image file \"%s\" used as texture could not be found."), pixmap_file); + image = get_texture_image(scr, pixmap_file); + if (!image) return NULL; - } - image = RLoadImage(scr->rcontext, file, 0); - if (!image) { - wwarning(_("could not load texture pixmap \"%s\":%s"), file, RMessageForError(RErrorCode)); - wfree(file); - return NULL; - } - wfree(file); texture = wmalloc(sizeof(WTexture)); memset(texture, 0, sizeof(WTexture)); @@ -303,20 +294,10 @@ WTexTGradient *wTextureMakeTGradient(WScreen * scr, int style, RColor * from, RC WTexTGradient *texture; XGCValues gcv; RImage *image; - char *file; - file = FindImage(wPreferences.pixmap_path, pixmap_file); - if (!file) { - wwarning(_("image file \"%s\" used as texture could not be found."), pixmap_file); + image = get_texture_image(scr, pixmap_file); + if (!image) return NULL; - } - image = RLoadImage(scr->rcontext, file, 0); - if (!image) { - wwarning(_("could not load texture pixmap \"%s\":%s"), file, RMessageForError(RErrorCode)); - wfree(file); - return NULL; - } - wfree(file); texture = wmalloc(sizeof(WTexture)); memset(texture, 0, sizeof(WTexture)); @@ -341,6 +322,27 @@ WTexTGradient *wTextureMakeTGradient(WScreen * scr, int style, RColor * from, RC return texture; } +static RImage * get_texture_image(WScreen *scr, char *pixmap_file) +{ + char *file; + RImage *image; + + file = FindImage(wPreferences.pixmap_path, pixmap_file); + if (!file) { + wwarning(_("image file \"%s\" used as texture could not be found."), pixmap_file); + return NULL; + } + image = RLoadImage(scr->rcontext, file, 0); + if (!image) { + wwarning(_("could not load texture pixmap \"%s\":%s"), file, RMessageForError(RErrorCode)); + wfree(file); + return NULL; + } + wfree(file); + + return image; +} + RImage *wTextureRenderImage(WTexture * texture, int width, int height, int relief) { RImage *image = NULL;