1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 04:48:06 +01:00

WindowMaker: New get_texture_image function

The new function get_texture_image includes the common code of
wTextureMakePixmap() and wTextureMakeTGradient()
This commit is contained in:
Rodolfo García Peñas (kix)
2012-04-14 11:29:14 +02:00
committed by Carlos R. Mafra
parent 1b0ed30b9b
commit 244b63e6b5

View File

@@ -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;