forked from e16/e16
1
0
Fork 0

Wrap imlib.

SVN revision: 21576
This commit is contained in:
Kim Woelders 2006-03-29 19:13:17 +00:00
parent 6854456944
commit 2f78638c0f
28 changed files with 892 additions and 728 deletions

View File

@ -61,8 +61,6 @@
#define USE_COMPOSITE 1 #define USE_COMPOSITE 1
#endif #endif
#include <Imlib2.h>
#define ENABLE_COLOR_MODIFIERS 0 /* Not functional */ #define ENABLE_COLOR_MODIFIERS 0 /* Not functional */
#define ENABLE_TRANSPARENCY 1 #define ENABLE_TRANSPARENCY 1
@ -669,7 +667,6 @@ void DialogAlertOK(const char *fmt, ...);
void DockIt(EWin * ewin); void DockIt(EWin * ewin);
/* draw.c */ /* draw.c */
Imlib_Image *ELoadImage(const char *file);
void DrawEwinShape(EWin * ewin, int md, int x, int y, int w, void DrawEwinShape(EWin * ewin, int md, int x, int y, int w,
int h, char firstlast); int h, char firstlast);

View File

@ -45,6 +45,8 @@ e16_SOURCES = \
econfig.c \ econfig.c \
econfig.h \ econfig.h \
edge.c \ edge.c \
eimage.c \
eimage.h \
emodule.c \ emodule.c \
emodule.h \ emodule.h \
eobj.c \ eobj.c \

View File

@ -27,6 +27,7 @@
#include "desktops.h" #include "desktops.h"
#include "dialog.h" #include "dialog.h"
#include "e16-ecore_list.h" #include "e16-ecore_list.h"
#include "eimage.h"
#include "emodule.h" #include "emodule.h"
#include "iclass.h" #include "iclass.h"
#include "tclass.h" #include "tclass.h"
@ -36,7 +37,7 @@ typedef struct
{ {
char *file; char *file;
char *real_file; char *real_file;
Imlib_Image *im; EImage *im;
char keep_aspect; char keep_aspect;
int xjust, yjust; int xjust, yjust;
int xperc, yperc; int xperc, yperc;
@ -168,7 +169,7 @@ BackgroundPixmapFree(Background * bg)
{ {
if (bg->pmap) if (bg->pmap)
{ {
imlib_free_pixmap_and_mask(bg->pmap); EImagePixmapFree(bg->pmap);
bg->pmap = None; bg->pmap = None;
} }
} }
@ -178,14 +179,12 @@ BackgroundImagesFree(Background * bg)
{ {
if (bg->bg.im) if (bg->bg.im)
{ {
imlib_context_set_image(bg->bg.im); EImageFree(bg->bg.im);
imlib_free_image();
bg->bg.im = NULL; bg->bg.im = NULL;
} }
if (bg->top.im) if (bg->top.im)
{ {
imlib_context_set_image(bg->top.im); EImageFree(bg->top.im);
imlib_free_image();
bg->top.im = NULL; bg->top.im = NULL;
} }
} }
@ -451,7 +450,9 @@ static void
BgFindImageSize(BgPart * bgp, unsigned int rw, unsigned int rh, BgFindImageSize(BgPart * bgp, unsigned int rw, unsigned int rh,
unsigned int *pw, unsigned int *ph) unsigned int *pw, unsigned int *ph)
{ {
int w, h; int w, h, iw, ih;
EImageGetSize(bgp->im, &iw, &ih);
if (bgp->keep_aspect) if (bgp->keep_aspect)
bgp->xperc = bgp->yperc; bgp->xperc = bgp->yperc;
@ -459,12 +460,12 @@ BgFindImageSize(BgPart * bgp, unsigned int rw, unsigned int rh,
if (bgp->xperc > 0) if (bgp->xperc > 0)
w = (rw * bgp->xperc) >> 10; w = (rw * bgp->xperc) >> 10;
else else
w = (imlib_image_get_width() * rw) / VRoot.w; w = (iw * rw) / VRoot.w;
if (bgp->yperc > 0) if (bgp->yperc > 0)
h = (rh * bgp->yperc) >> 10; h = (rh * bgp->yperc) >> 10;
else else
h = (imlib_image_get_height() * rh) / VRoot.h; h = (ih * rh) / VRoot.h;
if (w <= 0) if (w <= 0)
w = 1; w = 1;
@ -475,15 +476,13 @@ BgFindImageSize(BgPart * bgp, unsigned int rw, unsigned int rh,
{ {
if (bgp->yperc <= 0) if (bgp->yperc <= 0)
{ {
if (((w << 10) / h) != if (((w << 10) / h) != ((iw << 10) / ih))
((imlib_image_get_width() << 10) / imlib_image_get_height())) h = ((w * ih) / iw);
h = ((w * imlib_image_get_height()) / imlib_image_get_width());
} }
else else
{ {
if (((h << 10) / w) != if (((h << 10) / w) != ((ih << 10) / iw))
((imlib_image_get_height() << 10) / imlib_image_get_width())) w = ((h * iw) / ih);
w = ((h * imlib_image_get_width()) / imlib_image_get_height());
} }
} }
@ -491,83 +490,6 @@ BgFindImageSize(BgPart * bgp, unsigned int rw, unsigned int rh,
*ph = (unsigned int)h; *ph = (unsigned int)h;
} }
static void
e16_tile_image_onto_image(Imlib_Image * tile, int blend, int tw, int th,
int dx, int dy, int dw, int dh, int ox, int oy)
{
Imlib_Image *im, *tim;
int x, y, tx, ty, ww, hh;
int sw, sh;
im = imlib_context_get_image();
imlib_context_set_image(tile);
sw = imlib_image_get_width();
sh = imlib_image_get_height();
if (sw == tw && sh == th)
{
tim = tile;
}
else
{
tim = imlib_create_image(tw, th);
imlib_context_set_image(tim);
imlib_context_set_blend(0);
imlib_blend_image_onto_image(tile, 0, 0, 0, sw, sh, 0, 0, tw, th);
}
imlib_context_set_image(im);
if (ox)
{
ox = tw - ox;
ox %= tw;
if (ox < 0)
ox += tw;
}
if (oy)
{
oy = th - oy;
oy %= th;
if (oy < 0)
oy += th;
}
dw += dx;
dh += dy;
y = dy;
ty = oy;
hh = th - oy;
for (;;)
{
if (y + hh >= dh)
hh = dh - y;
if (hh <= 0)
break;
x = dx;
tx = ox;
ww = tw - ox;
for (;;)
{
if (x + ww >= dw)
ww = dw - x;
if (ww <= 0)
break;
imlib_blend_image_onto_image(tim, blend, tx, ty, ww, hh,
x, y, ww, hh);
tx = 0;
x += ww;
ww = tw;
}
ty = 0;
y += hh;
hh = th;
}
if (tim != tile)
{
imlib_context_set_image(tim);
imlib_free_image();
imlib_context_set_image(im);
}
}
static Pixmap static Pixmap
BackgroundCreatePixmap(Window win, unsigned int w, unsigned int h, BackgroundCreatePixmap(Window win, unsigned int w, unsigned int h,
unsigned int depth) unsigned int depth)
@ -596,11 +518,10 @@ BackgroundRealize(Background * bg, Drawable draw, unsigned int rw,
{ {
Pixmap pmap; Pixmap pmap;
GC gc; GC gc;
int rt; int x, y, ww, hh;
int x, y; unsigned int w, h;
unsigned int w, h, ww, hh;
char hasbg, hasfg; char hasbg, hasfg;
Imlib_Image *im; EImage *im;
#if ENABLE_COLOR_MODIFIERS #if ENABLE_COLOR_MODIFIERS
ColorModifierClass *cm; ColorModifierClass *cm;
@ -610,14 +531,14 @@ BackgroundRealize(Background * bg, Drawable draw, unsigned int rw,
{ {
if (!bg->bg.real_file) if (!bg->bg.real_file)
bg->bg.real_file = ThemeFileFind(bg->bg.file, 0); bg->bg.real_file = ThemeFileFind(bg->bg.file, 0);
bg->bg.im = ELoadImage(bg->bg.real_file); bg->bg.im = EImageLoad(bg->bg.real_file);
} }
if (bg->top.file && !bg->top.im) if (bg->top.file && !bg->top.im)
{ {
if (!bg->top.real_file) if (!bg->top.real_file)
bg->top.real_file = ThemeFileFind(bg->top.file, 0); bg->top.real_file = ThemeFileFind(bg->top.file, 0);
bg->top.im = ELoadImage(bg->top.real_file); bg->top.im = EImageLoad(bg->top.real_file);
} }
#if ENABLE_COLOR_MODIFIERS #if ENABLE_COLOR_MODIFIERS
@ -677,21 +598,10 @@ BackgroundRealize(Background * bg, Drawable draw, unsigned int rw,
/* Has either bg or fg image */ /* Has either bg or fg image */
rt = imlib_context_get_dither();
if (Conf.backgrounds.hiquality)
{
imlib_context_set_dither(1);
#if 0 /* ??? */
imlib_context_set_anti_alias(1);
#endif
}
w = h = x = y = 0; w = h = x = y = 0;
if (hasbg) if (hasbg)
{ {
imlib_context_set_image(bg->bg.im);
BgFindImageSize(&(bg->bg), rw, rh, &w, &h); BgFindImageSize(&(bg->bg), rw, rh, &w, &h);
x = ((int)(rw - w) * bg->bg.xjust) >> 10; x = ((int)(rw - w) * bg->bg.xjust) >> 10;
y = ((int)(rh - h) * bg->bg.yjust) >> 10; y = ((int)(rh - h) * bg->bg.yjust) >> 10;
@ -702,8 +612,7 @@ BackgroundRealize(Background * bg, Drawable draw, unsigned int rw,
{ {
/* Window, no fg, no offset, and scale to 100%, or tiled, no trans */ /* Window, no fg, no offset, and scale to 100%, or tiled, no trans */
pmap = BackgroundCreatePixmap(draw, w, h, VRoot.depth); pmap = BackgroundCreatePixmap(draw, w, h, VRoot.depth);
imlib_context_set_drawable(pmap); EImageRenderOnDrawable(bg->bg.im, pmap, 0, 0, w, h, 0);
imlib_render_image_on_drawable_at_size(0, 0, w, h);
#if 0 /* FIXME - Remove? */ #if 0 /* FIXME - Remove? */
if (x == 0 && y == 0) /* Hmmm. Always true. */ if (x == 0 && y == 0) /* Hmmm. Always true. */
@ -728,72 +637,55 @@ BackgroundRealize(Background * bg, Drawable draw, unsigned int rw,
pmap = BackgroundCreatePixmap(draw, rw, rh, VRoot.depth); pmap = BackgroundCreatePixmap(draw, rw, rh, VRoot.depth);
else else
pmap = draw; pmap = draw;
imlib_context_set_drawable(pmap);
if (hasbg && !hasfg && x == 0 && y == 0 && w == rw && h == rh) if (hasbg && !hasfg && x == 0 && y == 0 && w == rw && h == rh)
{ {
im = bg->bg.im; im = bg->bg.im;
imlib_context_set_image(im);
} }
else else
{ {
/* Create full size image */ /* Create full size image */
im = imlib_create_image(rw, rh); im = EImageCreate(rw, rh);
imlib_context_set_image(im); EImageSetHasAlpha(im, 0);
imlib_image_set_has_alpha(0);
if (!hasbg || !bg->bg_tile) if (!hasbg || !bg->bg_tile)
{ {
/* Fill solid */ /* Fill solid */
imlib_context_set_blend(0); EImageFill(im, 0, 0, rw, rh, bg->bg_solid.red, bg->bg_solid.green,
imlib_context_set_color(bg->bg_solid.red, bg->bg_solid.green, bg->bg_solid.blue, 255);
bg->bg_solid.blue, 0);
imlib_image_fill_rectangle(0, 0, rw, rh);
} }
if (hasbg) if (hasbg)
{ {
if (bg->bg_tile) if (bg->bg_tile)
{ {
e16_tile_image_onto_image(bg->bg.im, 0, w, h, EImageTile(im, bg->bg.im, 0, w, h, 0, 0, rw, rh, x, y);
0, 0, rw, rh, x, y);
} }
else else
{ {
imlib_context_set_image(bg->bg.im); EImageGetSize(bg->bg.im, &ww, &hh);
ww = imlib_image_get_width(); EImageBlend(im, bg->bg.im, 0, 0, 0, ww, hh, x, y, w, h, 1, 0);
hh = imlib_image_get_height();
imlib_context_set_image(im);
imlib_blend_image_onto_image(bg->bg.im, 1, 0, 0, ww, hh,
x, y, w, h);
} }
} }
} }
if (hasfg) if (hasfg)
{ {
imlib_context_set_image(bg->top.im); EImageGetSize(bg->top.im, &ww, &hh);
BgFindImageSize(&(bg->top), rw, rh, &w, &h); BgFindImageSize(&(bg->top), rw, rh, &w, &h);
x = ((rw - w) * bg->top.xjust) >> 10; x = ((rw - w) * bg->top.xjust) >> 10;
y = ((rh - h) * bg->top.yjust) >> 10; y = ((rh - h) * bg->top.yjust) >> 10;
ww = imlib_image_get_width(); EImageBlend(im, bg->top.im, 1, 0, 0, ww, hh, x, y, w, h, 0, 0);
hh = imlib_image_get_height();
imlib_context_set_image(im);
imlib_context_set_blend(1);
imlib_blend_image_onto_image(bg->top.im, 0, 0, 0, ww, hh, x, y, w, h);
imlib_context_set_blend(0);
} }
imlib_render_image_on_drawable_at_size(0, 0, rw, rh); EImageRenderOnDrawable(im, pmap, 0, 0, rw, rh, 0);
if (im != bg->bg.im) if (im != bg->bg.im)
imlib_free_image(); EImageFree(im);
done: done:
if (!bg->keepim) if (!bg->keepim)
BackgroundImagesFree(bg); BackgroundImagesFree(bg);
imlib_context_set_dither(rt);
if (ppmap) if (ppmap)
*ppmap = pmap; *ppmap = pmap;
if (ppixel) if (ppixel)
@ -821,7 +713,7 @@ BackgroundApplyWin(Background * bg, Window win)
if (pmap != None) if (pmap != None)
{ {
ESetWindowBackgroundPixmap(win, pmap); ESetWindowBackgroundPixmap(win, pmap);
imlib_free_pixmap_and_mask(pmap); EImagePixmapFree(pmap);
} }
else else
{ {
@ -858,7 +750,7 @@ BrackgroundCreateFromImage(const char *bgid, const char *file,
char *thumb, int thlen) char *thumb, int thlen)
{ {
Background *bg; Background *bg;
Imlib_Image *im, *im2; EImage *im, *im2;
XColor xclr; XColor xclr;
char tile = 1, keep_asp = 0; char tile = 1, keep_asp = 0;
int width, height; int width, height;
@ -883,13 +775,11 @@ BrackgroundCreateFromImage(const char *bgid, const char *file,
return bg; return bg;
} }
im = imlib_load_image(file); im = EImageLoad(file);
if (!im) if (!im)
return NULL; return NULL;
imlib_context_set_image(im); EImageGetSize(im, &width, &height);
width = imlib_image_get_width();
height = imlib_image_get_height();
if (thumb) if (thumb)
{ {
@ -900,14 +790,13 @@ BrackgroundCreateFromImage(const char *bgid, const char *file,
w2 = maxw; w2 = maxw;
h2 = (height * w2) / width; h2 = (height * w2) / width;
} }
im2 = imlib_create_cropped_scaled_image(0, 0, width, height, w2, h2); im2 = EImageCreateScaled(im, 0, 0, width, height, w2, h2);
imlib_free_image_and_decache(); EImageSave(im2, thumb);
imlib_context_set_image(im2); EImageDecache(im2);
imlib_image_set_format("png");
imlib_save_image(thumb);
imlib_free_image_and_decache();
} }
EImageDecache(im);
/* Quit if the background itself already exists */ /* Quit if the background itself already exists */
if (bg) if (bg)
return bg; return bg;
@ -1038,22 +927,21 @@ BackgroundIsNone(const Background * bg)
return (bg) ? bg->external : 1; return (bg) ? bg->external : 1;
} }
static Imlib_Image * static EImage *
BackgroundCacheMini(Background * bg, int keep, int nuke) BackgroundCacheMini(Background * bg, int keep, int nuke)
{ {
char s[4096]; char s[4096];
Imlib_Image *im; EImage *im;
Pixmap pmap; Pixmap pmap;
Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s.png", EDirUserCache(), Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s.png", EDirUserCache(),
BackgroundGetName(bg)); BackgroundGetName(bg));
im = ELoadImage(s); im = EImageLoad(s);
if (im) if (im)
{ {
imlib_context_set_image(im);
if (nuke) if (nuke)
imlib_free_image_and_decache(); EImageDecache(im);
else else
goto done; goto done;
} }
@ -1061,17 +949,14 @@ BackgroundCacheMini(Background * bg, int keep, int nuke)
/* Create new cached bg mini image */ /* Create new cached bg mini image */
pmap = ECreatePixmap(VRoot.win, 64, 48, VRoot.depth); pmap = ECreatePixmap(VRoot.win, 64, 48, VRoot.depth);
BackgroundApplyPmap(bg, pmap, 64, 48); BackgroundApplyPmap(bg, pmap, 64, 48);
imlib_context_set_drawable(pmap); im = EImageGrabDrawable(pmap, None, 0, 0, 64, 48, 0);
im = imlib_create_image_from_drawable(0, 0, 0, 64, 48, 0); EImageSave(im, s);
imlib_context_set_image(im);
imlib_image_set_format("png");
imlib_save_image(s);
EFreePixmap(pmap); EFreePixmap(pmap);
done: done:
if (keep) if (keep)
return im; return im;
imlib_free_image(); EImageFree(im);
return NULL; return NULL;
} }
@ -1841,7 +1726,7 @@ BG_RedrawView(void)
{ {
if (((x + 64 + 8) >= 0) && (x < w)) if (((x + 64 + 8) >= 0) && (x < w))
{ {
Imlib_Image *im; EImage *im;
if (ic_button) if (ic_button)
ImageclassApplySimple(ic_button, win, pmap, ImageclassApplySimple(ic_button, win, pmap,
@ -1870,10 +1755,8 @@ BG_RedrawView(void)
im = BackgroundCacheMini(bg, 1, 0); im = BackgroundCacheMini(bg, 1, 0);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageRenderOnDrawable(im, pmap, x + 4, 4, 64, 48, 0);
imlib_context_set_drawable(pmap); EImageFree(im);
imlib_render_image_on_drawable_at_size(x + 4, 4, 64, 48);
imlib_free_image();
} }
} }
} }

View File

@ -256,7 +256,7 @@ BorderWinpartCalc(EWin * ewin, int i, int ww, int hh)
int dummywidth, wmax, wmin; int dummywidth, wmax, wmin;
ImageClass *iclass; ImageClass *iclass;
TextClass *tclass; TextClass *tclass;
Imlib_Border *pad; EImageBorder *pad;
/* /*
* calculate width before height, because we need it in order to * calculate width before height, because we need it in order to
@ -321,7 +321,7 @@ BorderWinpartCalc(EWin * ewin, int i, int ww, int hh)
int dummyheight; int dummyheight;
ImageClass *iclass; ImageClass *iclass;
TextClass *tclass; TextClass *tclass;
Imlib_Border *pad; EImageBorder *pad;
iclass = ewin->border->part[i].iclass; iclass = ewin->border->part[i].iclass;
tclass = ewin->border->part[i].tclass; tclass = ewin->border->part[i].tclass;

View File

@ -24,6 +24,8 @@
#ifndef _BORDERS_H_ #ifndef _BORDERS_H_
#define _BORDERS_H_ #define _BORDERS_H_
#include "eimage.h"
typedef struct _winpoint typedef struct _winpoint
{ {
int originbox; int originbox;
@ -60,7 +62,7 @@ typedef struct _border
{ {
char *name; char *name;
char *group_border_name; char *group_border_name;
Imlib_Border border; EImageBorder border;
int num_winparts; int num_winparts;
WinPart *part; WinPart *part;
char changes_shape; char changes_shape;

View File

@ -26,6 +26,7 @@
#include "buttons.h" #include "buttons.h"
#include "desktops.h" #include "desktops.h"
#include "e16-ecore_list.h" #include "e16-ecore_list.h"
#include "eimage.h"
#include "emodule.h" #include "emodule.h"
#include "iclass.h" #include "iclass.h"
#include "tclass.h" #include "tclass.h"
@ -225,7 +226,7 @@ static void
ButtonCalc(Button * b) ButtonCalc(Button * b)
{ {
int w, h, x, y, xo, yo; int w, h, x, y, xo, yo;
Imlib_Image *im; EImage *im;
x = 0; x = 0;
y = 0; y = 0;
@ -236,10 +237,8 @@ ButtonCalc(Button * b)
im = ImageclassGetImage(b->iclass, 0, 0, 0); im = ImageclassGetImage(b->iclass, 0, 0, 0);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageGetSize(im, &w, &h);
w = imlib_image_get_width(); EImageFree(im);
h = imlib_image_get_height();
imlib_free_image();
} }
else else
{ {

View File

@ -42,7 +42,7 @@ CoordsShow(EWin * ewin)
unsigned int w, h; unsigned int w, h;
int cx, cy, cw, ch; int cx, cy, cw, ch;
EObj *eo = coord_eo; EObj *eo = coord_eo;
Imlib_Border *pad; EImageBorder *pad;
int bl, br, bt, bb; int bl, br, bt, bb;
if (!Conf.movres.mode_info) if (!Conf.movres.mode_info)

View File

@ -24,6 +24,7 @@
#include "E.h" #include "E.h"
#include "dialog.h" #include "dialog.h"
#include "e16-ecore_list.h" #include "e16-ecore_list.h"
#include "eimage.h"
#include "ewins.h" #include "ewins.h"
#include "hints.h" #include "hints.h"
#include "iclass.h" #include "iclass.h"
@ -124,7 +125,7 @@ struct _ditem
void *data; void *data;
ImageClass *iclass; ImageClass *iclass;
TextClass *tclass; TextClass *tclass;
Imlib_Border padding; EImageBorder padding;
char fill_h; char fill_h;
char fill_v; char fill_v;
int align_h; int align_h;
@ -319,7 +320,7 @@ void
DialogSetText(Dialog * d, const char *text) DialogSetText(Dialog * d, const char *text)
{ {
int w, h; int w, h;
Imlib_Border *pad; EImageBorder *pad;
if (d->text) if (d->text)
Efree(d->text); Efree(d->text);
@ -367,7 +368,7 @@ DialogAddButton(Dialog * d, const char *text, DialogCallbackFunc * func,
{ {
DButton *db; DButton *db;
int w, h; int w, h;
Imlib_Border *pad; EImageBorder *pad;
db = Emalloc(sizeof(DButton)); db = Emalloc(sizeof(DButton));
@ -414,7 +415,7 @@ static void
DialogDrawButton(Dialog * d __UNUSED__, DButton * db) DialogDrawButton(Dialog * d __UNUSED__, DButton * db)
{ {
int state; int state;
Imlib_Image *im; EImage *im;
state = STATE_NORMAL; state = STATE_NORMAL;
if ((db->hilited) && (db->clicked)) if ((db->hilited) && (db->clicked))
@ -439,16 +440,16 @@ DialogDrawButton(Dialog * d __UNUSED__, DButton * db)
switch (db->image) switch (db->image)
{ {
case DLG_BUTTON_OK: case DLG_BUTTON_OK:
im = ELoadImage("pix/ok.png"); im = EImageLoad("pix/ok.png");
break; break;
case DLG_BUTTON_CANCEL: case DLG_BUTTON_CANCEL:
im = ELoadImage("pix/cancel.png"); im = EImageLoad("pix/cancel.png");
break; break;
case DLG_BUTTON_APPLY: case DLG_BUTTON_APPLY:
im = ELoadImage("pix/apply.png"); im = EImageLoad("pix/apply.png");
break; break;
case DLG_BUTTON_CLOSE: case DLG_BUTTON_CLOSE:
im = ELoadImage("pix/close.png"); im = EImageLoad("pix/close.png");
break; break;
default: default:
break; break;
@ -458,7 +459,7 @@ DialogDrawButton(Dialog * d __UNUSED__, DButton * db)
if (im) if (im)
{ {
ImageClass *ic = db->iclass; ImageClass *ic = db->iclass;
Imlib_Border *pad; EImageBorder *pad;
int h; int h;
pad = ImageclassGetPadding(ic); pad = ImageclassGetPadding(ic);
@ -468,12 +469,8 @@ DialogDrawButton(Dialog * d __UNUSED__, DButton * db)
db->w - (h + 2 + pad->left + pad->right), db->w - (h + 2 + pad->left + pad->right),
h, h, TextclassGetJustification(db->tclass)); h, h, TextclassGetJustification(db->tclass));
imlib_context_set_image(im); EImageRenderOnDrawable(im, db->win, pad->left, pad->top, h, h, 1);
imlib_context_set_drawable(db->win); EImageFree(im);
imlib_context_set_blend(1);
imlib_render_image_on_drawable_at_size(pad->left, pad->top, h, h);
imlib_context_set_blend(0);
imlib_free_image();
} }
else else
{ {
@ -576,7 +573,7 @@ ShowDialog(Dialog * d)
{ {
int i, w, h, mw, mh; int i, w, h, mw, mh;
EWin *ewin; EWin *ewin;
Imlib_Border *pad; EImageBorder *pad;
if (d->title) if (d->title)
{ {
@ -946,8 +943,8 @@ DialogRealizeItem(Dialog * d, DItem * di)
const char *def = NULL; const char *def = NULL;
int iw = 0, ih = 0; int iw = 0, ih = 0;
int register_win_callback; int register_win_callback;
Imlib_Image *im; EImage *im;
Imlib_Border *pad; EImageBorder *pad;
if (di->type == DITEM_BUTTON) if (di->type == DITEM_BUTTON)
{ {
@ -1042,10 +1039,9 @@ DialogRealizeItem(Dialog * d, DItem * di)
im = ImageclassGetImage(di->item.slider.ic_base, 0, 0, 0); im = ImageclassGetImage(di->item.slider.ic_base, 0, 0, 0);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageGetSize(im, &di->item.slider.base_orig_w,
di->item.slider.base_orig_w = imlib_image_get_width(); &di->item.slider.base_orig_h);
di->item.slider.base_orig_h = imlib_image_get_height(); EImageFree(im);
imlib_free_image();
} }
if (di->item.slider.ic_base) if (di->item.slider.ic_base)
ImageclassIncRefcount(di->item.slider.ic_base); ImageclassIncRefcount(di->item.slider.ic_base);
@ -1069,10 +1065,9 @@ DialogRealizeItem(Dialog * d, DItem * di)
im = ImageclassGetImage(di->item.slider.ic_knob, 0, 0, 0); im = ImageclassGetImage(di->item.slider.ic_knob, 0, 0, 0);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageGetSize(im, &di->item.slider.knob_orig_w,
di->item.slider.knob_orig_w = imlib_image_get_width(); &di->item.slider.knob_orig_h);
di->item.slider.knob_orig_h = imlib_image_get_height(); EImageFree(im);
imlib_free_image();
} }
if (!di->item.slider.ic_border) if (!di->item.slider.ic_border)
{ {
@ -1093,10 +1088,9 @@ DialogRealizeItem(Dialog * d, DItem * di)
im = ImageclassGetImage(di->item.slider.ic_border, 0, 0, 0); im = ImageclassGetImage(di->item.slider.ic_border, 0, 0, 0);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageGetSize(im, &di->item.slider.border_orig_w,
di->item.slider.border_orig_w = imlib_image_get_width(); &di->item.slider.border_orig_h);
di->item.slider.border_orig_h = imlib_image_get_height(); EImageFree(im);
imlib_free_image();
di->item.slider.border_win = di->item.slider.border_win =
ECreateWindow(d->win, -20, -20, 2, 2, 0); ECreateWindow(d->win, -20, -20, 2, 2, 0);
EMapWindow(di->item.slider.border_win); EMapWindow(di->item.slider.border_win);
@ -1153,10 +1147,9 @@ DialogRealizeItem(Dialog * d, DItem * di)
im = ImageclassGetImage(di->iclass, 0, 0, 0); im = ImageclassGetImage(di->iclass, 0, 0, 0);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageGetSize(im, &di->item.check_button.check_orig_w,
di->item.check_button.check_orig_w = imlib_image_get_width(); &di->item.check_button.check_orig_h);
di->item.check_button.check_orig_h = imlib_image_get_height(); EImageFree(im);
imlib_free_image();
} }
TextSize(di->tclass, 0, 0, STATE_NORMAL, di->text, &iw, &ih, 17); TextSize(di->tclass, 0, 0, STATE_NORMAL, di->text, &iw, &ih, 17);
if (ih < di->item.check_button.check_orig_h) if (ih < di->item.check_button.check_orig_h)
@ -1179,22 +1172,19 @@ DialogRealizeItem(Dialog * d, DItem * di)
di->h = ih; di->h = ih;
break; break;
case DITEM_IMAGE: case DITEM_IMAGE:
im = ELoadImage(di->item.image.image); im = EImageLoad(di->item.image.image);
if (im) if (im)
{ {
Pixmap pmap = 0, mask = 0; Pixmap pmap = 0, mask = 0;
imlib_context_set_image(im); EImageGetSize(im, &iw, &ih);
iw = imlib_image_get_width();
ih = imlib_image_get_height();
di->win = ECreateWindow(d->win, 0, 0, iw, ih, 0); di->win = ECreateWindow(d->win, 0, 0, iw, ih, 0);
EMapWindow(di->win); EMapWindow(di->win);
imlib_context_set_drawable(di->win); EImageRenderPixmaps(im, di->win, &pmap, &mask, 0, 0);
imlib_render_pixmaps_for_whole_image(&pmap, &mask);
ESetWindowBackgroundPixmap(di->win, pmap); ESetWindowBackgroundPixmap(di->win, pmap);
EShapeCombineMask(di->win, ShapeBounding, 0, 0, mask, ShapeSet); EShapeCombineMask(di->win, ShapeBounding, 0, 0, mask, ShapeSet);
imlib_free_pixmap_and_mask(pmap); EImagePixmapFree(pmap);
imlib_free_image(); EImageFree(im);
} }
di->w = iw; di->w = iw;
di->h = ih; di->h = ih;
@ -1215,10 +1205,9 @@ DialogRealizeItem(Dialog * d, DItem * di)
im = ImageclassGetImage(di->iclass, 0, 0, 0); im = ImageclassGetImage(di->iclass, 0, 0, 0);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageGetSize(im, &di->item.radio_button.radio_orig_w,
di->item.radio_button.radio_orig_w = imlib_image_get_width(); &di->item.radio_button.radio_orig_h);
di->item.radio_button.radio_orig_h = imlib_image_get_height(); EImageFree(im);
imlib_free_image();
} }
TextSize(di->tclass, 0, 0, STATE_NORMAL, di->text, &iw, &ih, 17); TextSize(di->tclass, 0, 0, STATE_NORMAL, di->text, &iw, &ih, 17);
if (ih < di->item.radio_button.radio_orig_h) if (ih < di->item.radio_button.radio_orig_h)
@ -1565,7 +1554,7 @@ static void
DialogDrawItem(Dialog * d, DItem * di) DialogDrawItem(Dialog * d, DItem * di)
{ {
int state; int state;
Imlib_Border *pad; EImageBorder *pad;
if (!di->update && di->type != DITEM_TABLE) if (!di->update && di->type != DITEM_TABLE)
return; return;
@ -1773,7 +1762,7 @@ DialogsCheckUpdate(void)
static void static void
DialogItemsRealize(Dialog * d) DialogItemsRealize(Dialog * d)
{ {
Imlib_Border *pad; EImageBorder *pad;
if (!d->item) if (!d->item)
return; return;

View File

@ -981,29 +981,3 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast)
CoordsHide(); CoordsHide();
} }
} }
Imlib_Image *
ELoadImage(const char *file)
{
Imlib_Image *im;
char *f;
if (!file)
return NULL;
if (file[0] == '/')
{
im = imlib_load_image(file);
return im;
}
f = ThemeFileFind(file, 0);
if (f)
{
im = imlib_load_image(f);
Efree(f);
return im;
}
return NULL;
}

470
src/eimage.c Normal file
View File

@ -0,0 +1,470 @@
/*
* Copyright (C) 2004-2006 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies of the Software, its documentation and marketing & publicity
* materials, and acknowledgment shall be given in the documentation, materials
* and software packages that this Software was used.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "E.h"
#include "eimage.h"
#include "xwin.h"
#include <Imlib2.h>
void
EImageInit(Display * dpy)
{
imlib_set_cache_size(2048 * 1024);
imlib_set_font_cache_size(512 * 1024);
imlib_set_color_usage(128);
imlib_context_set_display(dpy);
imlib_context_set_visual(DefaultVisual(dpy, DefaultScreen(dpy)));
imlib_context_set_colormap(DefaultColormap(dpy, DefaultScreen(dpy)));
imlib_context_set_dither(1);
}
EImage *
EImageLoad(const char *file)
{
EImage *im;
char *f;
if (!file)
return NULL;
if (file[0] == '/')
{
im = imlib_load_image(file);
return im;
}
f = ThemeFileFind(file, 0);
if (f)
{
im = imlib_load_image(f);
Efree(f);
return im;
}
return NULL;
}
void
EImageSave(EImage * im, const char *file)
{
imlib_context_set_image(im);
imlib_image_set_format("png");
imlib_save_image(file);
}
EImage *
EImageCreate(int w, int h)
{
EImage *im;
im = imlib_create_image(w, h);
return im;
}
EImage *
EImageCreateFromData(int w, int h, unsigned int *data)
{
EImage *im;
im = imlib_create_image_using_copied_data(w, h, data);
return im;
}
EImage *
EImageCreateScaled(EImage * im, int sx, int sy, int sw, int sh, int dw, int dh)
{
imlib_context_set_image(im);
if (sw <= 0)
sw = imlib_image_get_width();
if (sh <= 0)
sh = imlib_image_get_height();
return imlib_create_cropped_scaled_image(sx, sy, sw, sh, dw, dh);
}
void
EImageFree(EImage * im)
{
imlib_context_set_image(im);
imlib_free_image();
}
void
EImageDecache(EImage * im)
{
imlib_context_set_image(im);
imlib_free_image_and_decache();
}
static int
_EImageCheckAlpha(void)
{
static const short oink = 3; /* For endianness checking */
unsigned char *pb, *pe;
if (!imlib_image_has_alpha())
return 0;
pb = (unsigned char *)imlib_image_get_data_for_reading_only();
pe = pb + 4 * imlib_image_get_width() * imlib_image_get_height();
pb += *((char *)(&oink));
for (; pb < pe; pb += 4)
if (*pb != 0xff)
return 1;
return 0;
}
void
EImageCheckAlpha(EImage * im)
{
imlib_context_set_image(im);
if (imlib_image_has_alpha() && !_EImageCheckAlpha())
{
#if 0
Eprintf("Alpha set but no shape %s\n", is->real_file);
#endif
imlib_image_set_has_alpha(0);
}
}
void
EImageSetHasAlpha(EImage * im, int has_alpha)
{
imlib_context_set_image(im);
imlib_image_set_has_alpha(has_alpha);
}
void
EImageSetBorder(EImage * im, EImageBorder * border)
{
Imlib_Border ib;
ib.left = border->left;
ib.right = border->right;
ib.top = border->top;
ib.bottom = border->bottom;
imlib_context_set_image(im);
imlib_image_set_border(&ib);
}
int
EImageHasAlpha(EImage * im)
{
imlib_context_set_image(im);
return imlib_image_has_alpha();
}
void
EImageGetSize(EImage * im, int *pw, int *ph)
{
imlib_context_set_image(im);
*pw = imlib_image_get_width();
*ph = imlib_image_get_height();
}
void
EImageFill(EImage * im, int x, int y, int w, int h, int r, int g, int b, int a)
{
imlib_context_set_image(im);
imlib_context_set_color(r, g, b, a);
imlib_context_set_blend(0);
imlib_image_fill_rectangle(x, y, w, h);
}
void
EImageOrientate(EImage * im, int orientation)
{
imlib_context_set_image(im);
imlib_image_orientate(orientation);
}
void
EImageBlend(EImage * im, EImage * src, int blend,
int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh, int merge_alpha, int anti_alias)
{
imlib_context_set_image(im);
if (anti_alias)
imlib_context_set_anti_alias(1);
if (blend)
imlib_context_set_blend(1);
imlib_blend_image_onto_image(src, merge_alpha, sx, sy, sw, sh,
dx, dy, dw, dh);
if (blend)
imlib_context_set_blend(0);
if (anti_alias)
imlib_context_set_anti_alias(0);
}
void
EImageBlendCM(EImage * im, EImage * src, EImageColorModifier * icm)
{
int w, h, iw, ih;
imlib_context_set_image(src);
iw = imlib_image_get_width();
ih = imlib_image_get_height();
imlib_context_set_image(im);
w = imlib_image_get_width();
h = imlib_image_get_height();
imlib_context_set_blend(1);
if (icm)
imlib_context_set_color_modifier(icm);
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_blend_image_onto_image(src, 0, 0, 0, iw, ih, 0, 0, w, h);
imlib_context_set_blend(0);
if (icm)
imlib_context_set_color_modifier(NULL);
}
void
EImageTile(EImage * im, EImage * tile, int blend, int tw, int th,
int dx, int dy, int dw, int dh, int ox, int oy)
{
Imlib_Image *tim;
int x, y, tx, ty, ww, hh;
int sw, sh;
imlib_context_set_image(tile);
sw = imlib_image_get_width();
sh = imlib_image_get_height();
if (sw == tw && sh == th)
{
tim = tile;
}
else
{
tim = imlib_create_image(tw, th);
imlib_context_set_image(tim);
imlib_context_set_blend(0);
imlib_blend_image_onto_image(tile, 0, 0, 0, sw, sh, 0, 0, tw, th);
}
imlib_context_set_image(im);
if (ox)
{
ox = tw - ox;
ox %= tw;
if (ox < 0)
ox += tw;
}
if (oy)
{
oy = th - oy;
oy %= th;
if (oy < 0)
oy += th;
}
dw += dx;
dh += dy;
y = dy;
ty = oy;
hh = th - oy;
for (;;)
{
if (y + hh >= dh)
hh = dh - y;
if (hh <= 0)
break;
x = dx;
tx = ox;
ww = tw - ox;
for (;;)
{
if (x + ww >= dw)
ww = dw - x;
if (ww <= 0)
break;
imlib_blend_image_onto_image(tim, blend, tx, ty, ww, hh,
x, y, ww, hh);
tx = 0;
x += ww;
ww = tw;
}
ty = 0;
y += hh;
hh = th;
}
if (tim != tile)
{
imlib_context_set_image(tim);
imlib_free_image();
imlib_context_set_image(im); /* FIXME - Remove */
}
}
EImage *
EImageGrabDrawable(Drawable draw, Pixmap mask, int x, int y, int w, int h,
int grab)
{
EImage *im;
imlib_context_set_drawable(draw);
im = imlib_create_image_from_drawable(mask, x, y, w, h, grab);
return im;
}
EImage *
EImageGrabDrawableScaled(Drawable draw, Pixmap mask, int x, int y, int w, int h,
int iw, int ih, int grab, int get_mask_from_shape)
{
EImage *im;
imlib_context_set_drawable(draw);
im =
imlib_create_scaled_image_from_drawable(mask, x, y, w, h, iw, ih, grab,
get_mask_from_shape);
return im;
}
void
EImageRenderOnDrawable(EImage * im, Drawable draw, int x, int y, int w, int h,
int blend)
{
imlib_context_set_image(im);
imlib_context_set_drawable(draw);
if (blend)
imlib_context_set_blend(1);
imlib_render_image_on_drawable_at_size(x, y, w, h);
if (blend)
imlib_context_set_blend(0);
}
void
EImageRenderPixmaps(EImage * im, Drawable draw, Pixmap * pmap, Pixmap * mask,
int w, int h)
{
imlib_context_set_image(im);
imlib_context_set_drawable(draw);
*pmap = *mask = None;
if (w <= 0 || h <= 0)
imlib_render_pixmaps_for_whole_image(pmap, mask);
else
imlib_render_pixmaps_for_whole_image_at_size(pmap, mask, w, h);
}
void
EImagePixmapFree(Pixmap pmap)
{
imlib_free_pixmap_and_mask(pmap);
}
void
ScaleRect(Window src, Pixmap dst, Pixmap * pdst, int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh, int scale)
{
Imlib_Image *im;
Pixmap pmap, mask;
scale = (scale) ? 2 : 1;
imlib_context_set_drawable(src);
im = imlib_create_scaled_image_from_drawable(None, sx, sy, sw, sh,
scale * dw, scale * dh, 0, 0);
imlib_context_set_image(im);
imlib_context_set_anti_alias(1);
if (pdst)
{
imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, dw, dh);
*pdst = pmap;
}
else
{
imlib_context_set_drawable(dst);
imlib_render_image_on_drawable_at_size(dx, dy, dw, dh);
}
imlib_free_image();
}
void
EDrawableDumpImage(Drawable draw, const char *txt)
{
static int seqn = 0;
char buf[1024];
Imlib_Image *im;
int w, h;
w = h = 0;
EGetGeometry(draw, NULL, NULL, NULL, &w, &h, NULL, NULL);
if (w <= 0 || h <= 0)
return;
imlib_context_set_drawable(draw);
im = imlib_create_image_from_drawable(None, 0, 0, w, h, !EServerIsGrabbed());
imlib_context_set_image(im);
imlib_image_set_format("png");
sprintf(buf, "%s-%#lx-%d.png", txt, draw, seqn++);
Eprintf("EDrawableDumpImage: %s\n", buf);
imlib_save_image(buf);
imlib_free_image_and_decache();
}
void
FreePmapMask(PmapMask * pmm)
{
/* type !=0: Created by imlib_render_pixmaps_for_whole_image... */
if (pmm->pmap)
{
if (pmm->type == 0)
EFreePixmap(pmm->pmap);
else
imlib_free_pixmap_and_mask(pmm->pmap);
pmm->pmap = 0;
}
if (pmm->mask)
{
if (pmm->type == 0)
EFreePixmap(pmm->mask);
pmm->mask = 0;
}
}
EImageColorModifier *
EImageColorModifierCreate(unsigned char *r, unsigned char *g, unsigned char *b,
unsigned char *a)
{
EImageColorModifier *icm;
icm = imlib_create_color_modifier();
if (!icm)
return NULL;
imlib_context_set_color_modifier(icm);
#if 0 /* Useful in this context? */
imlib_modify_color_modifier_gamma(0.5);
imlib_modify_color_modifier_brightness(0.5);
imlib_modify_color_modifier_contrast(0.5);
#endif
imlib_set_color_modifier_tables(r, g, b, a);
imlib_context_set_color_modifier(NULL);
return icm;
}

94
src/eimage.h Normal file
View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2004-2006 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies of the Software, its documentation and marketing & publicity
* materials, and acknowledgment shall be given in the documentation, materials
* and software packages that this Software was used.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _EIMAGE_H_
#define _EIMAGE_H_
typedef void EImage;
typedef void EImageColorModifier;
typedef struct
{
int left, right, top, bottom;
} EImageBorder;
void EImageInit(Display * dpy);
EImage *EImageCreate(int w, int h);
EImage *EImageCreateFromData(int w, int h, unsigned int *data);
EImage *EImageCreateScaled(EImage * im, int sx, int sy,
int sw, int sh, int dw, int dh);
void EImageFree(EImage * im);
void EImageDecache(EImage * im);
void EImageSave(EImage * im, const char *file);
EImage *EImageLoad(const char *file);
void EImageCheckAlpha(EImage * im);
void EImageSetHasAlpha(EImage * im, int has_alpha);
void EImageSetBorder(EImage * im, EImageBorder * border);
int EImageHasAlpha(EImage * im);
void EImageGetSize(EImage * im, int *pw, int *ph);
void EImageFill(EImage * im, int x, int y, int w, int h, int r,
int g, int b, int a);
void EImageOrientate(EImage * im, int orientation);
void EImageBlend(EImage * im, EImage * src, int blend,
int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh,
int merge_alpha, int anti_alias);
void EImageBlendCM(EImage * im, EImage * src,
EImageColorModifier * icm);
void EImageTile(EImage * im, EImage * tile, int blend, int tw,
int th, int dx, int dy, int dw, int dh, int ox,
int oy);
EImage *EImageGrabDrawable(Drawable draw, Pixmap mask,
int x, int y, int w, int h, int grab);
EImage *EImageGrabDrawableScaled(Drawable draw, Pixmap mask,
int x, int y, int w, int h,
int iw, int ih, int grab,
int get_mask_from_shape);
void EImageRenderOnDrawable(EImage * im, Drawable draw,
int x, int y, int w, int h,
int blend);
void EImageRenderPixmaps(EImage * im, Drawable draw,
Pixmap * pmap, Pixmap * mask,
int w, int h);
void EImagePixmapFree(Pixmap pmap);
EImageColorModifier *EImageColorModifierCreate(unsigned char *r,
unsigned char *g,
unsigned char *b,
unsigned char *a);
void ScaleRect(Window src, Pixmap dst, Pixmap * pdst,
int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh, int scale);
#endif /* _EIMAGE_H_ */

View File

@ -23,6 +23,7 @@
*/ */
#include "E.h" #include "E.h"
#include "e16-ecore_hints.h" #include "e16-ecore_hints.h"
#include "eimage.h"
#include "xwin.h" #include "xwin.h"
#include <sys/time.h> #include <sys/time.h>
@ -44,15 +45,7 @@ ExtInitWinMain(void)
EGrabServer(); EGrabServer();
#if 0 EImageInit(disp);
imlib_set_cache_size(2048 * 1024);
imlib_set_font_cache_size(512 * 1024);
imlib_set_color_usage(128);
#endif
imlib_context_set_display(disp);
imlib_context_set_visual(DefaultVisual(disp, DefaultScreen(disp)));
imlib_context_set_colormap(DefaultColormap(disp, DefaultScreen(disp)));
attr.backing_store = NotUseful; attr.backing_store = NotUseful;
attr.override_redirect = True; attr.override_redirect = True;
@ -85,9 +78,9 @@ ExtInitWinMain(void)
{ {
Window w2, ww; Window w2, ww;
char s[1024]; char s[1024];
Imlib_Image *im; EImage *im;
struct timeval tv; struct timeval tv;
int dd, x, y; int dd, x, y, w, h;
unsigned int mm; unsigned int mm;
Cursor cs = 0; Cursor cs = 0;
XColor cl; XColor cl;
@ -122,25 +115,20 @@ ExtInitWinMain(void)
if (EventDebug(EDBUG_TYPE_SESSION)) if (EventDebug(EDBUG_TYPE_SESSION))
Eprintf("ExtInitWinCreate - child %s\n", s); Eprintf("ExtInitWinCreate - child %s\n", s);
im = ELoadImage(s); im = EImageLoad(s);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageRenderPixmaps(im, w2, &pmap, &mask, 0, 0);
imlib_context_set_drawable(w2); EImageGetSize(im, &w, &h);
imlib_render_pixmaps_for_whole_image(&pmap, &mask);
XShapeCombineMask(disp, w2, ShapeBounding, 0, 0, mask, XShapeCombineMask(disp, w2, ShapeBounding, 0, 0, mask,
ShapeSet); ShapeSet);
XSetWindowBackgroundPixmap(disp, w2, pmap); XSetWindowBackgroundPixmap(disp, w2, pmap);
imlib_free_pixmap_and_mask(pmap); EImagePixmapFree(pmap);
XClearWindow(disp, w2); XClearWindow(disp, w2);
XQueryPointer(disp, win, &ww, &ww, &dd, &dd, &x, &y, &mm); XQueryPointer(disp, win, &ww, &ww, &dd, &dd, &x, &y, &mm);
XMoveResizeWindow(disp, w2, XMoveResizeWindow(disp, w2, x - w / 2, y - h / 2, w, h);
x - imlib_image_get_width() / 2,
y - imlib_image_get_height() / 2,
imlib_image_get_width(),
imlib_image_get_height());
XMapWindow(disp, w2); XMapWindow(disp, w2);
imlib_free_image(); EImageFree(im);
} }
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 50000; tv.tv_usec = 50000;

View File

@ -23,6 +23,7 @@
#include "E.h" #include "E.h"
#include "desktops.h" #include "desktops.h"
#include "dialog.h" #include "dialog.h"
#include "eimage.h"
#include "emodule.h" #include "emodule.h"
#include "xwin.h" #include "xwin.h"
#include <math.h> #include <math.h>
@ -717,22 +718,19 @@ FX_imagespinner_timeout(int val __UNUSED__, void *data __UNUSED__)
fx_imagespinner_count++; fx_imagespinner_count++;
if (string) if (string)
{ {
Imlib_Image *im; EImage *im;
im = ELoadImage(string); im = EImageLoad(string);
if (im) if (im)
{ {
int x, y, w, h; int x, y, w, h;
imlib_context_set_image(im); EImageGetSize(im, &w, &h);
w = imlib_image_get_width();
h = imlib_image_get_height();
sscanf(fx_imagespinner_params, "%*s %i %i ", &x, &y); sscanf(fx_imagespinner_params, "%*s %i %i ", &x, &y);
x = ((VRoot.w * x) >> 10) - ((w * x) >> 10); x = ((VRoot.w * x) >> 10) - ((w * x) >> 10);
y = ((VRoot.h * y) >> 10) - ((h * y) >> 10); y = ((VRoot.h * y) >> 10) - ((h * y) >> 10);
imlib_context_set_drawable(fx_imagespinner_win); EImageRenderOnDrawable(im, fx_imagespinner_win, x, y, w, h, 0);
imlib_render_image_on_drawable_at_size(x, y, w, h); EImageFree(im);
imlib_free_image();
} }
Efree(string); Efree(string);
} }

View File

@ -40,6 +40,7 @@ struct _hiwin
void *data; void *data;
char animate; char animate;
GC gc; GC gc;
EImage *im;
}; };
typedef struct typedef struct
@ -55,41 +56,34 @@ static void
HiwinRenderImageInit(Hiwin * phi) HiwinRenderImageInit(Hiwin * phi)
{ {
EWin *ewin = phi->ewin; EWin *ewin = phi->ewin;
Imlib_Image *im;
Pixmap pmap; Pixmap pmap;
pmap = EoGetPixmap(ewin); pmap = EoGetPixmap(ewin);
if (pmap) if (pmap)
{ {
imlib_context_set_drawable(pmap); phi->im = EImageGrabDrawable(pmap, None, 0, 0,
im = imlib_create_image_from_drawable(0, 0, 0, EoGetW(ewin), EoGetH(ewin), 0);
EoGetW(ewin), EoGetH(ewin), 0);
/* Skip zoom effect if composite is active */ /* Skip zoom effect if composite is active */
phi->animate = 0; phi->animate = 0;
} }
else if (phi->zoom > 2 && EwinIsOnScreen(ewin)) else if (phi->zoom > 2 && EwinIsOnScreen(ewin))
{ {
imlib_context_set_drawable(EoGetWin(ewin)); phi->im = EImageGrabDrawable(EoGetWin(ewin), None, 0, 0,
im = imlib_create_image_from_drawable(0, 0, 0, EoGetW(ewin), EoGetH(ewin), 0);
EoGetW(ewin), EoGetH(ewin), 0);
} }
else else
{ {
imlib_context_set_drawable(ewin->mini_pmm.pmap); phi->im = EImageGrabDrawable(ewin->mini_pmm.pmap, None, 0, 0,
im = imlib_create_image_from_drawable(0, 0, 0, ewin->mini_w, ewin->mini_h, 0);
ewin->mini_w, ewin->mini_h, 0);
} }
imlib_context_set_image(im);
imlib_context_set_drawable(EoGetWin(phi));
ESetWindowBackgroundPixmap(EoGetWin(phi), None); ESetWindowBackgroundPixmap(EoGetWin(phi), None);
} }
static void static void
HiwinRenderImageDrawX(Hiwin * phi, Drawable draw) HiwinRenderImageDrawX(Hiwin * phi, Drawable draw)
{ {
imlib_context_set_drawable(draw); EImageRenderOnDrawable(phi->im, draw, 0, 0, EoGetW(phi), EoGetH(phi), 0);
imlib_render_image_on_drawable_at_size(0, 0, EoGetW(phi), EoGetH(phi));
} }
static void static void
@ -112,14 +106,14 @@ HiwinRenderImageFini(Hiwin * phi, int shown)
EFreePixmap(pmap); EFreePixmap(pmap);
EClearWindow(EoGetWin(phi)); EClearWindow(EoGetWin(phi));
} }
imlib_free_image_and_decache(); EImageDecache(phi->im);
phi->im = NULL;
} }
#if USE_COMPOSITE #if USE_COMPOSITE
static void static void
HiwinRenderImageUpdate(Hiwin * phi) HiwinRenderImageUpdate(Hiwin * phi)
{ {
Imlib_Image *im;
Pixmap pmap; Pixmap pmap;
EWin *ewin = phi->ewin; EWin *ewin = phi->ewin;
@ -127,14 +121,12 @@ HiwinRenderImageUpdate(Hiwin * phi)
if (pmap == None) if (pmap == None)
return; return;
imlib_context_set_drawable(pmap); phi->im = EImageGrabDrawable(pmap, None, 0, 0,
im = imlib_create_image_from_drawable(0, 0, 0, EoGetW(ewin), EoGetH(ewin), 0);
EoGetW(ewin), EoGetH(ewin), 0);
imlib_context_set_image(im);
ESetWindowBackgroundPixmap(EoGetWin(phi), None); ESetWindowBackgroundPixmap(EoGetWin(phi), None);
HiwinRenderImageDrawX(phi, EoGetWin(phi)); HiwinRenderImageDrawX(phi, EoGetWin(phi));
imlib_free_image_and_decache(); EImageDecache(phi->im);
phi->im = NULL;
} }
#endif #endif

View File

@ -26,6 +26,7 @@
#include "conf.h" #include "conf.h"
#include "desktops.h" #include "desktops.h"
#include "e16-ecore_list.h" #include "e16-ecore_list.h"
#include "eimage.h"
#include "emodule.h" #include "emodule.h"
#include "iclass.h" #include "iclass.h"
#include "tclass.h" #include "tclass.h"
@ -56,8 +57,8 @@ struct _imagestate
char *real_file; char *real_file;
char unloadable; char unloadable;
char transparent; char transparent;
Imlib_Image *im; EImage *im;
Imlib_Border *border; EImageBorder *border;
int pixmapfillstyle; int pixmapfillstyle;
XColor bg, hi, lo, hihi, lolo; XColor bg, hi, lo, hihi, lolo;
int bevelstyle; int bevelstyle;
@ -79,7 +80,7 @@ struct _imageclass
{ {
char *name; char *name;
ImageStateArray norm, active, sticky, sticky_active; ImageStateArray norm, active, sticky, sticky_active;
Imlib_Border padding; EImageBorder padding;
#if ENABLE_COLOR_MODIFIERS #if ENABLE_COLOR_MODIFIERS
ColorModifierClass *colmod; ColorModifierClass *colmod;
#endif #endif
@ -90,9 +91,9 @@ static Ecore_List *iclass_list = NULL;
#ifdef ENABLE_THEME_TRANSPARENCY #ifdef ENABLE_THEME_TRANSPARENCY
static Imlib_Color_Modifier *icm = NULL; static EImageColorModifier *icm = NULL;
static DATA8 gray[256]; static unsigned char gray[256];
static DATA8 alpha[256]; static unsigned char alpha[256];
static int prev_alpha = -1; static int prev_alpha = -1;
@ -120,15 +121,7 @@ TransparencyMakeColorModifier(void)
} }
if (icm == NULL) if (icm == NULL)
icm = imlib_create_color_modifier(); icm = EImageColorModifierCreate(gray, gray, gray, alpha);
imlib_context_set_color_modifier(icm);
#if 0 /* Useful in this context? */
imlib_modify_color_modifier_gamma(0.5);
imlib_modify_color_modifier_brightness(0.5);
imlib_modify_color_modifier_contrast(0.5);
#endif
imlib_set_color_modifier_tables(gray, gray, gray, alpha);
imlib_context_set_color_modifier(NULL);
} }
void void
@ -211,8 +204,7 @@ FreeImageState(ImageState * i)
if (i->im) if (i->im)
{ {
imlib_context_set_image(i->im); EImageFree(i->im);
imlib_free_image();
i->im = NULL; i->im = NULL;
} }
@ -251,25 +243,6 @@ ImagestatePopulate(ImageState * is)
EAllocColor(&is->lolo); EAllocColor(&is->lolo);
} }
static int
e16_image_check_has_alpha(void)
{
static const short oink = 3; /* For endianness checking */
unsigned char *pb, *pe;
if (!imlib_image_has_alpha())
return 0;
pb = (unsigned char *)imlib_image_get_data_for_reading_only();
pe = pb + 4 * imlib_image_get_width() * imlib_image_get_height();
pb += *((char *)(&oink));
for (; pb < pe; pb += 4)
if (*pb != 0xff)
return 1;
return 0;
}
static void static void
ImagestateRealize(ImageState * is) ImagestateRealize(ImageState * is)
{ {
@ -284,7 +257,7 @@ ImagestateRealize(ImageState * is)
if (!is->real_file) if (!is->real_file)
is->real_file = ThemeFileFind(is->im_file, 0); is->real_file = ThemeFileFind(is->im_file, 0);
is->im = ELoadImage(is->real_file); is->im = EImageLoad(is->real_file);
if (!is->im) if (!is->im)
{ {
Eprintf Eprintf
@ -293,18 +266,10 @@ ImagestateRealize(ImageState * is)
return; return;
} }
imlib_context_set_image(is->im); EImageCheckAlpha(is->im);
if (imlib_image_has_alpha() && !e16_image_check_has_alpha())
{
#if 0
Eprintf("Alpha set but no shape %s\n", is->real_file);
#endif
imlib_image_set_has_alpha(0);
}
if (is->border) if (is->border)
imlib_image_set_border(is->border); EImageSetBorder(is->im, is->border);
#if 0 /* To be implemented? */ #if 0 /* To be implemented? */
if (is->colmod) if (is->colmod)
@ -399,7 +364,7 @@ ImageclassGetName(ImageClass * ic)
return (ic) ? ic->name : NULL; return (ic) ? ic->name : NULL;
} }
Imlib_Border * EImageBorder *
ImageclassGetPadding(ImageClass * ic) ImageclassGetPadding(ImageClass * ic)
{ {
return (ic) ? &(ic->padding) : NULL; return (ic) ? &(ic->padding) : NULL;
@ -563,7 +528,7 @@ ImageclassConfigLoad(FILE * fs)
goto done; goto done;
case ICLASS_LRTB: case ICLASS_LRTB:
{ {
ICToRead->border = Emalloc(sizeof(Imlib_Border)); ICToRead->border = Emalloc(sizeof(EImageBorder));
l = r = t = b = 0; l = r = t = b = 0;
sscanf(s, "%*s %i %i %i %i", &l, &r, &t, &b); sscanf(s, "%*s %i %i %i %i", &l, &r, &t, &b);
@ -804,10 +769,10 @@ ImageclassGetImageState(ImageClass * ic, int state, int active, int sticky)
return is; return is;
} }
Imlib_Image * EImage *
ImageclassGetImage(ImageClass * ic, int active, int sticky, int state) ImageclassGetImage(ImageClass * ic, int active, int sticky, int state)
{ {
Imlib_Image *im; EImage *im;
ImageState *is; ImageState *is;
if (!ic) if (!ic)
@ -833,7 +798,7 @@ ImageclassApplySimple(ImageClass * ic, Window win, Drawable draw, int state,
int x, int y, int w, int h) int x, int y, int w, int h)
{ {
Pixmap pmap; Pixmap pmap;
Imlib_Image *im; EImage *im;
im = ImageclassGetImage(ic, 0, 0, state); im = ImageclassGetImage(ic, 0, 0, state);
if (!im) if (!im)
@ -846,10 +811,9 @@ ImageclassApplySimple(ImageClass * ic, Window win, Drawable draw, int state,
draw = pmap; draw = pmap;
x = y = 0; x = y = 0;
} }
imlib_context_set_image(im);
imlib_context_set_drawable(draw); EImageRenderOnDrawable(im, draw, x, y, w, h, 0);
imlib_render_image_on_drawable_at_size(x, y, w, h); EImageFree(im);
imlib_free_image();
return pmap; return pmap;
} }
@ -907,10 +871,10 @@ pt_type_to_flags(int image_type)
return flags; return flags;
} }
static Imlib_Image * static EImage *
pt_get_bg_image(Window win, int w, int h, int use_root) pt_get_bg_image(Window win, int w, int h, int use_root)
{ {
Imlib_Image *ii = NULL; EImage *ii = NULL;
Window cr, dummy; Window cr, dummy;
Drawable bg; Drawable bg;
int xx, yy; int xx, yy;
@ -932,53 +896,25 @@ pt_get_bg_image(Window win, int w, int h, int use_root)
if (xx < VRoot.w && yy < VRoot.h && xx + w >= 0 && yy + h >= 0) if (xx < VRoot.w && yy < VRoot.h && xx + w >= 0 && yy + h >= 0)
{ {
/* Create the background base image */ /* Create the background base image */
imlib_context_set_drawable(bg); ii = EImageGrabDrawable(bg, None, xx, yy, w, h, !EServerIsGrabbed());
ii = imlib_create_image_from_drawable(0, xx, yy, w, h,
!EServerIsGrabbed());
} }
return ii; return ii;
} }
static void #endif
pt_blend(Imlib_Image * bg, Imlib_Image * im, int use_cm)
EImage *
ImageclassGetImageBlended(ImageClass * ic, Window win, int w, int h, int active,
int sticky, int state, int image_type)
{ {
int w, h, iw, ih; EImage *im, *bg;
imlib_context_set_image(im);
iw = imlib_image_get_width();
ih = imlib_image_get_height();
imlib_context_set_image(bg);
w = imlib_image_get_width();
h = imlib_image_get_height();
imlib_context_set_blend(1);
#ifdef ENABLE_THEME_TRANSPARENCY
if (use_cm)
{
imlib_context_set_color_modifier(icm);
}
#endif
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_blend_image_onto_image(im, 0, 0, 0, iw, ih, 0, 0, w, h);
imlib_context_set_blend(0);
#ifdef ENABLE_THEME_TRANSPARENCY
if (use_cm)
{
imlib_context_set_color_modifier(NULL);
}
#endif
}
#endif
Imlib_Image *
EImageBlendPT(Imlib_Image * im, Window win, int w, int h, int image_type)
{
Imlib_Image *bg;
int flags; int flags;
int ww, hh;
if (!ic)
return NULL;
im = ImageclassGetImage(ic, active, sticky, state);
if (!im) if (!im)
return NULL; return NULL;
@ -989,8 +925,8 @@ EImageBlendPT(Imlib_Image * im, Window win, int w, int h, int image_type)
bg = pt_get_bg_image(win, w, h, flags & ICLASS_ATTR_GLASS); bg = pt_get_bg_image(win, w, h, flags & ICLASS_ATTR_GLASS);
if (bg) if (bg)
{ {
pt_blend(bg, im, flags & ICLASS_ATTR_USE_CM); EImageBlendCM(bg, im, (flags & ICLASS_ATTR_USE_CM) ? icm : NULL);
return bg; goto done;
} }
} }
#else #else
@ -998,10 +934,10 @@ EImageBlendPT(Imlib_Image * im, Window win, int w, int h, int image_type)
win = None; win = None;
#endif #endif
imlib_context_set_image(im); bg = EImageCreateScaled(im, 0, 0, 0, 0, w, h);
ww = imlib_image_get_width();
hh = imlib_image_get_height(); done:
bg = imlib_create_cropped_scaled_image(0, 0, ww, hh, w, h); EImageFree(im);
return bg; return bg;
} }
@ -1011,7 +947,7 @@ ImagestateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm,
int make_mask, int w, int h, int image_type) int make_mask, int w, int h, int image_type)
{ {
#ifdef ENABLE_TRANSPARENCY #ifdef ENABLE_TRANSPARENCY
Imlib_Image *ii = NULL; EImage *ii = NULL;
int flags; int flags;
Pixmap pmap, mask; Pixmap pmap, mask;
@ -1023,7 +959,7 @@ ImagestateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm,
* 0x02: Use root window as base (use only for transients, if at all) * 0x02: Use root window as base (use only for transients, if at all)
* 0x04: Don't apply image mask to result * 0x04: Don't apply image mask to result
*/ */
if (is->transparent && imlib_image_has_alpha()) if (is->transparent && EImageHasAlpha(is->im))
flags = is->transparent; flags = is->transparent;
if (flags != ICLASS_ATTR_OPAQUE) if (flags != ICLASS_ATTR_OPAQUE)
@ -1039,36 +975,29 @@ ImagestateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm,
if (ii) if (ii)
{ {
imlib_context_set_drawable(win); EImageBlendCM(ii, is->im, (flags & ICLASS_ATTR_USE_CM) ? icm : NULL);
pt_blend(ii, is->im, flags & ICLASS_ATTR_USE_CM);
pmm->type = 0; pmm->type = 0;
pmm->pmap = pmap = ECreatePixmap(win, w, h, VRoot.depth); pmm->pmap = pmap = ECreatePixmap(win, w, h, VRoot.depth);
pmm->mask = None; pmm->mask = None;
pmm->w = w; pmm->w = w;
pmm->h = h; pmm->h = h;
imlib_context_set_image(ii); EImageRenderOnDrawable(ii, pmap, 0, 0, w, h, 0);
imlib_context_set_drawable(pmap);
imlib_render_image_on_drawable_at_size(0, 0, w, h);
imlib_context_set_drawable(win);
if (make_mask && !(flags & ICLASS_ATTR_NO_CLIP)) if (make_mask && !(flags & ICLASS_ATTR_NO_CLIP))
{ {
imlib_context_set_image(is->im); if (EImageHasAlpha(is->im))
if (imlib_image_has_alpha())
{ {
/* Make the scaled clip mask to be used */ /* Make the scaled clip mask to be used */
imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, w, EImageRenderPixmaps(is->im, win, &pmap, &mask, w, h);
h);
/* Replace the mask with the correct one */ /* Replace the mask with the correct one */
pmm->mask = ECreatePixmapCopy(mask, w, h, 1); pmm->mask = ECreatePixmapCopy(mask, w, h, 1);
imlib_free_pixmap_and_mask(pmap); EImagePixmapFree(pmap);
} }
} }
imlib_context_set_image(ii); EImageDecache(ii);
imlib_free_image_and_decache();
} }
else else
#else #else
@ -1081,19 +1010,13 @@ ImagestateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm,
pmm->pmap = pmm->mask = None; pmm->pmap = pmm->mask = None;
pmm->w = w; pmm->w = w;
pmm->h = h; pmm->h = h;
imlib_context_set_image(is->im); EImageRenderPixmaps(is->im, win, &pmm->pmap, &pmm->mask, w, h);
imlib_context_set_drawable(win);
imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, &pmm->mask,
w, h);
} }
else else
{ {
int ww, hh, cw, ch, pw, ph; int ww, hh, cw, ch, pw, ph;
imlib_context_set_image(is->im); EImageGetSize(is->im, &ww, &hh);
ww = imlib_image_get_width();
hh = imlib_image_get_height();
pw = w; pw = w;
ph = h; ph = h;
@ -1123,9 +1046,7 @@ ImagestateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm,
pmm->pmap = pmm->mask = None; pmm->pmap = pmm->mask = None;
pmm->w = pw; pmm->w = pw;
pmm->h = ph; pmm->h = ph;
imlib_context_set_drawable(win); EImageRenderPixmaps(is->im, win, &pmm->pmap, &pmm->mask, pw, ph);
imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, &pmm->mask,
pw, ph);
} }
} }
@ -1296,8 +1217,7 @@ ITApply(Window win, ImageClass * ic, ImageState * is, int w, int h, int state,
if ((is->unloadable) || (Conf.memory_paranoia)) if ((is->unloadable) || (Conf.memory_paranoia))
{ {
imlib_context_set_image(is->im); EImageFree(is->im);
imlib_free_image();
is->im = NULL; is->im = NULL;
} }
} }
@ -1396,8 +1316,7 @@ ImageclassApplyCopy(ImageClass * ic, Window win, int w, int h, int active,
if ((is->unloadable) || (Conf.memory_paranoia)) if ((is->unloadable) || (Conf.memory_paranoia))
{ {
imlib_context_set_image(is->im); EImageFree(is->im);
imlib_free_image();
is->im = NULL; is->im = NULL;
} }
} }
@ -1561,7 +1480,7 @@ ImageclassIpc(const char *params, Client * c __UNUSED__)
word(params, 3, param3); word(params, 3, param3);
p = (Pixmap) strtol(param3, (char **)NULL, 0); p = (Pixmap) strtol(param3, (char **)NULL, 0);
imlib_free_pixmap_and_mask(p); EImagePixmapFree(p);
} }
else if (!strcmp(param2, "get_padding")) else if (!strcmp(param2, "get_padding"))
{ {
@ -1581,10 +1500,11 @@ ImageclassIpc(const char *params, Client * c __UNUSED__)
ImagestateRealize(ic->norm.normal); ImagestateRealize(ic->norm.normal);
if (ic->norm.normal->im) if (ic->norm.normal->im)
{ {
imlib_context_set_image(ic->norm.normal->im); int w, h;
IpcPrintf("%i %i\n", imlib_image_get_width(),
imlib_image_get_height()); EImageGetSize(ic->norm.normal->im, &w, &h);
imlib_free_image(); EImageFree(ic->norm.normal->im);
IpcPrintf("%i %i\n", w, h);
} }
} }
else else

View File

@ -24,6 +24,7 @@
#ifndef _ICLASS_H #ifndef _ICLASS_H
#define _ICLASS_H #define _ICLASS_H
#include "eimage.h"
#include "xwin.h" #include "xwin.h"
struct _textclass; struct _textclass;
@ -99,18 +100,15 @@ int ImageclassIsTransparent(ImageClass * ic);
#define ImageclassIsTransparent(ic) 0 #define ImageclassIsTransparent(ic) 0
#endif #endif
Imlib_Image *EImageBlendPT(Imlib_Image * im, Window win, int w, int h,
int image_type);
ImageClass *ImageclassFind(const char *name, int fallback); ImageClass *ImageclassFind(const char *name, int fallback);
void ImageclassIncRefcount(ImageClass * ic); void ImageclassIncRefcount(ImageClass * ic);
void ImageclassDecRefcount(ImageClass * ic); void ImageclassDecRefcount(ImageClass * ic);
const char *ImageclassGetName(ImageClass * ic); const char *ImageclassGetName(ImageClass * ic);
Imlib_Border *ImageclassGetPadding(ImageClass * ic); EImageBorder *ImageclassGetPadding(ImageClass * ic);
ImageState *ImageclassGetImageState(ImageClass * ic, int state, ImageState *ImageclassGetImageState(ImageClass * ic, int state,
int active, int sticky); int active, int sticky);
ImageClass *ImageclassCreateSimple(const char *name, const char *image); ImageClass *ImageclassCreateSimple(const char *name, const char *image);
Imlib_Image *ImageclassGetImage(ImageClass * ic, int active, int sticky, EImage *ImageclassGetImage(ImageClass * ic, int active, int sticky,
int state); int state);
Pixmap ImageclassApplySimple(ImageClass * ic, Window win, Pixmap ImageclassApplySimple(ImageClass * ic, Window win,
Drawable draw, int state, int x, Drawable draw, int state, int x,
@ -122,6 +120,10 @@ void ImageclassApplyCopy(ImageClass * ic, Window win, int w,
int h, int active, int sticky, int h, int active, int sticky,
int state, PmapMask * pmm, int state, PmapMask * pmm,
int make_mask, int image_type); int make_mask, int image_type);
EImage *ImageclassGetImageBlended(ImageClass * ic, Window win,
int w, int h, int active,
int sticky, int state,
int image_type);
void ITApply(Window win, ImageClass * ic, ImageState * is, int w, void ITApply(Window win, ImageClass * ic, ImageState * is, int w,
int h, int state, int active, int sticky, int h, int state, int active, int sticky,
char expose, int image_type, struct _textclass *tc, char expose, int image_type, struct _textclass *tc,

View File

@ -64,7 +64,7 @@ typedef struct
} u; } u;
int xo, yo, wo, ho; /* Outer */ int xo, yo, wo, ho; /* Outer */
int xi, yi, wi, hi; /* Inner */ int xi, yi, wi, hi; /* Inner */
Imlib_Image *im; EImage *im;
} IboxOject; } IboxOject;
struct _iconbox struct _iconbox
@ -94,7 +94,7 @@ struct _iconbox
int max, max_min; int max, max_min;
ImageClass *ic_box; ImageClass *ic_box;
ImageClass *ic_item_base; ImageClass *ic_item_base;
Imlib_Image *im_item_base; EImage *im_item_base;
char arrow1_hilited; char arrow1_hilited;
char arrow1_clicked; char arrow1_clicked;
@ -479,7 +479,7 @@ static void
IconboxReconfigure(Iconbox * ib) IconboxReconfigure(Iconbox * ib)
{ {
ImageClass *ic, *ic2; ImageClass *ic, *ic2;
Imlib_Border *pad; EImageBorder *pad;
EWin *ewin; EWin *ewin;
int extra; int extra;
unsigned int wmin, hmin, wmax, hmax; unsigned int wmin, hmin, wmax, hmax;
@ -704,10 +704,8 @@ IconboxObjEwinDel(Iconbox * ib, EWin * ewin)
return; return;
if (ib->objs[i].im) if (ib->objs[i].im)
{ EImageFree(ib->objs[i].im);
imlib_context_set_image(ib->objs[i].im);
imlib_free_image();
}
IconboxObjectDel(ib, ewin); IconboxObjectDel(ib, ewin);
} }
@ -829,10 +827,7 @@ IconboxUpdateEwinIcon(Iconbox * ib, EWin * ewin, int icon_mode)
return; return;
if (ib->objs[i].im) if (ib->objs[i].im)
{ EImageFree(ib->objs[i].im);
imlib_context_set_image(ib->objs[i].im);
imlib_free_image();
}
ib->objs[i].im = EwinIconImageGet(ewin, ib->iconsize, icon_mode); ib->objs[i].im = EwinIconImageGet(ewin, ib->iconsize, icon_mode);
IconboxRedraw(ib); IconboxRedraw(ib);
@ -848,13 +843,11 @@ IconboxesUpdateEwinIcon(EWin * ewin, int icon_mode)
} }
static void static void
IconboxFindIconSize(Imlib_Image * im, int *pw, int *ph, int size) IconboxFindIconSize(EImage * im, int *pw, int *ph, int size)
{ {
int w, h, minsz, maxwh; int w, h, minsz, maxwh;
imlib_context_set_image(im); EImageGetSize(im, &w, &h);
w = imlib_image_get_width();
h = imlib_image_get_height();
maxwh = (w > h) ? w : h; maxwh = (w > h) ? w : h;
if (maxwh <= 1) if (maxwh <= 1)
@ -879,7 +872,7 @@ IconboxLayoutImageWin(Iconbox * ib)
int i, xo, yo, wo, ho, wi, hi; int i, xo, yo, wo, ho, wi, hi;
int item_pad, padl, padr, padt, padb; int item_pad, padl, padr, padt, padb;
IboxOject *ibo; IboxOject *ibo;
Imlib_Border *pad; EImageBorder *pad;
if (ib->orientation) if (ib->orientation)
ib->ic_box = ImageclassFind("ICONBOX_VERTICAL", 0); ib->ic_box = ImageclassFind("ICONBOX_VERTICAL", 0);
@ -1034,7 +1027,7 @@ static void
IB_DrawScroll(Iconbox * ib) IB_DrawScroll(Iconbox * ib)
{ {
ImageClass *ic; ImageClass *ic;
Imlib_Border *pad; EImageBorder *pad;
int arrow_mode = ib->arrow_side; int arrow_mode = ib->arrow_side;
int bs, bw, bx; int bs, bw, bx;
int state; int state;
@ -1568,7 +1561,7 @@ IconboxDraw(Iconbox * ib)
ImageClass *ib_ic_cover; ImageClass *ib_ic_cover;
int ib_xlt, ib_ylt, ib_ww, ib_hh; int ib_xlt, ib_ylt, ib_ww, ib_hh;
int ib_x0, ib_y0, ib_w0, ib_h0; int ib_x0, ib_y0, ib_w0, ib_h0;
Imlib_Image *im, *im2; EImage *im;
int ww, hh; int ww, hh;
Pixmap pmap, mask; Pixmap pmap, mask;
@ -1636,21 +1629,15 @@ IconboxDraw(Iconbox * ib)
(!ib->nobg || (ib->type == IB_TYPE_SYSTRAY && !ib->draw_icon_base))) (!ib->nobg || (ib->type == IB_TYPE_SYSTRAY && !ib->draw_icon_base)))
{ {
/* Start out with iconbox image class image */ /* Start out with iconbox image class image */
im2 = ImageclassGetImage(ib->ic_box, 0, 0, STATE_NORMAL); im = ImageclassGetImageBlended(ib->ic_box, ib->icon_win, ib_w0, ib_h0,
im = EImageBlendPT(im2, ib->icon_win, ib_w0, ib_h0, ST_ICONBOX); 0, 0, STATE_NORMAL, ST_ICONBOX);
imlib_context_set_image(im2);
imlib_free_image();
imlib_context_set_image(im);
} }
else else
{ {
/* Start out with blank image */ /* Start out with blank image */
im = imlib_create_image(ib_w0, ib_h0); im = EImageCreate(ib_w0, ib_h0);
imlib_context_set_image(im); EImageFill(im, 0, 0, ib_w0, ib_h0, 0, 0, 0, 255);
imlib_image_set_has_alpha(1); EImageSetHasAlpha(im, 1);
imlib_context_set_blend(0);
imlib_context_set_color(0, 0, 0, 0);
imlib_image_fill_rectangle(0, 0, ib_w0, ib_h0);
} }
for (i = 0; i < ib->num_objs; i++) for (i = 0; i < ib->num_objs; i++)
@ -1661,32 +1648,18 @@ IconboxDraw(Iconbox * ib)
if (ib->draw_icon_base && ib->im_item_base) if (ib->draw_icon_base && ib->im_item_base)
{ {
imlib_context_set_image(ib->im_item_base); EImageGetSize(ib->im_item_base, &ww, &hh);
ww = imlib_image_get_width(); EImageBlend(im, ib->im_item_base, 1, 0, 0, ww, hh,
hh = imlib_image_get_height(); ibo->xo, ibo->yo, ibo->wo, ibo->ho, 1, 0);
imlib_context_set_image(im);
imlib_context_set_blend(1);
imlib_blend_image_onto_image(ib->im_item_base, 1, 0, 0,
ww, hh, ibo->xo, ibo->yo,
ibo->wo, ibo->ho);
imlib_context_set_blend(0);
} }
if (ib->type == IB_TYPE_ICONBOX) if (ib->type == IB_TYPE_ICONBOX)
{ {
if (ibo->im) if (ibo->im)
{ {
imlib_context_set_image(ibo->im); EImageGetSize(ibo->im, &ww, &hh);
ww = imlib_image_get_width(); EImageBlend(im, ibo->im, 1, 0, 0, ww, hh,
hh = imlib_image_get_height(); ibo->xi, ibo->yi, ibo->wi, ibo->hi, 1, 1);
imlib_context_set_image(im);
imlib_context_set_anti_alias(1);
imlib_context_set_blend(1);
imlib_blend_image_onto_image(ibo->im, 1, 0, 0, ww, hh,
ibo->xi, ibo->yi, ibo->wi,
ibo->hi);
imlib_context_set_blend(0);
imlib_context_set_anti_alias(0);
} }
} }
else else
@ -1702,15 +1675,11 @@ IconboxDraw(Iconbox * ib)
if (im) if (im)
{ {
EMapWindow(ib->icon_win); EMapWindow(ib->icon_win);
imlib_context_set_drawable(ib->icon_win); EImageRenderPixmaps(im, ib->icon_win, &pmap, &mask, 0, 0);
imlib_context_set_image(im);
imlib_image_set_has_alpha(1);
pmap = mask = None;
imlib_render_pixmaps_for_whole_image(&pmap, &mask);
ESetWindowBackgroundPixmap(ib->icon_win, pmap); ESetWindowBackgroundPixmap(ib->icon_win, pmap);
EShapeCombineMask(ib->icon_win, ShapeBounding, 0, 0, mask, ShapeSet); EShapeCombineMask(ib->icon_win, ShapeBounding, 0, 0, mask, ShapeSet);
imlib_free_pixmap_and_mask(pmap); EImagePixmapFree(pmap);
imlib_free_image(); EImageFree(im);
EClearWindow(ib->icon_win); EClearWindow(ib->icon_win);
if (ib->type == IB_TYPE_SYSTRAY && ib->nobg && !ib->draw_icon_base) if (ib->type == IB_TYPE_SYSTRAY && ib->nobg && !ib->draw_icon_base)
@ -1864,7 +1833,7 @@ IboxEventScrollbarWin(XEvent * ev, void *prm)
static int px, py, pos0; static int px, py, pos0;
int bs, dp; int bs, dp;
ImageClass *ic; ImageClass *ic;
Imlib_Border *pad; EImageBorder *pad;
switch (ev->type) switch (ev->type)
{ {

View File

@ -22,6 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "E.h" #include "E.h"
#include "eimage.h"
#include "ewins.h" #include "ewins.h"
#include "icons.h" #include "icons.h"
#include "xwin.h" #include "xwin.h"
@ -64,12 +65,12 @@ NetwmIconFindBestSize(unsigned int *val, unsigned int len, int size)
return k; return k;
} }
static Imlib_Image * static EImage *
IB_SnapEWin(EWin * ewin, int size) IB_SnapEWin(EWin * ewin, int size)
{ {
/* Make snapshot of window */ /* Make snapshot of window */
int w, h, ww, hh, scale; int w, h, ww, hh, scale;
Imlib_Image *im; EImage *im;
Drawable draw; Drawable draw;
if (!EwinIsMapped(ewin)) if (!EwinIsMapped(ewin))
@ -111,33 +112,28 @@ IB_SnapEWin(EWin * ewin, int size)
Pixmap mask; Pixmap mask;
mask = EWindowGetShapePixmap(EoGetWin(ewin)); mask = EWindowGetShapePixmap(EoGetWin(ewin));
imlib_context_set_drawable(draw); im = EImageGrabDrawableScaled(draw, mask, 0, 0, ww, hh, w, h,
im = imlib_create_scaled_image_from_drawable(mask, 0, 0, ww, hh, !EServerIsGrabbed(), 0);
w, h, !EServerIsGrabbed(),
0);
} }
else else
{ {
draw = EoGetWin(ewin); draw = EoGetWin(ewin);
imlib_context_set_drawable(draw); im = EImageGrabDrawableScaled(draw, None, 0, 0, ww, hh, w, h,
im = imlib_create_scaled_image_from_drawable(None, 0, 0, ww, hh, !EServerIsGrabbed(), 1);
w, h, !EServerIsGrabbed(),
1);
} }
imlib_context_set_image(im); EImageSetHasAlpha(im, 1);
imlib_image_set_has_alpha(1);
return im; return im;
} }
static Imlib_Image * static EImage *
IB_GetAppIcon(EWin * ewin, int size) IB_GetAppIcon(EWin * ewin, int size)
{ {
/* Get the applications icon pixmap/mask */ /* Get the applications icon pixmap/mask */
int x, y; int x, y;
unsigned int w, h, depth, bw; unsigned int w, h, depth, bw;
Window rt; Window rt;
Imlib_Image im; EImage *im;
if (ewin->ewmh.wm_icon) if (ewin->ewmh.wm_icon)
{ {
@ -145,13 +141,10 @@ IB_GetAppIcon(EWin * ewin, int size)
size); size);
if (x >= 0) if (x >= 0)
{ {
im = imlib_create_image_using_copied_data(ewin->ewmh.wm_icon[x], im = EImageCreateFromData(ewin->ewmh.wm_icon[x],
ewin->ewmh.wm_icon[x + ewin->ewmh.wm_icon[x + 1],
1], ewin->ewmh.wm_icon + x + 2);
ewin->ewmh.wm_icon + x + EImageSetHasAlpha(im, 1);
2);
imlib_context_set_image(im);
imlib_image_set_has_alpha(1);
return im; return im;
} }
} }
@ -166,30 +159,25 @@ IB_GetAppIcon(EWin * ewin, int size)
if (w < 1 || h < 1) if (w < 1 || h < 1)
return NULL; return NULL;
imlib_context_set_colormap(None); im = EImageGrabDrawable(ewin->icccm.icon_pmap, ewin->icccm.icon_mask,
imlib_context_set_drawable(ewin->icccm.icon_pmap); 0, 0, w, h, !EServerIsGrabbed());
im = imlib_create_image_from_drawable(ewin->icccm.icon_mask, 0, 0, w, h, EImageSetHasAlpha(im, 1);
!EServerIsGrabbed());
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
imlib_context_set_colormap(VRoot.cmap);
imlib_context_set_drawable(VRoot.win);
return im; return im;
} }
static Imlib_Image * static EImage *
IB_GetEIcon(EWin * ewin) IB_GetEIcon(EWin * ewin)
{ {
/* get the icon defined for this window in E's iconf match file */ /* get the icon defined for this window in E's iconf match file */
const char *file; const char *file;
Imlib_Image *im; EImage *im;
file = WindowMatchEwinIcon(ewin); file = WindowMatchEwinIcon(ewin);
if (!file) if (!file)
return NULL; return NULL;
im = ELoadImage(file); im = EImageLoad(file);
return im; return im;
} }
@ -204,10 +192,10 @@ static const char ewin_icon_modes[N_MODES][N_TYPES] = {
{EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_NONE}, {EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_NONE},
}; };
Imlib_Image * EImage *
EwinIconImageGet(EWin * ewin, int size, int mode) EwinIconImageGet(EWin * ewin, int size, int mode)
{ {
Imlib_Image *im = NULL; EImage *im = NULL;
int i, type; int i, type;
if (mode < 0 || mode >= N_MODES) if (mode < 0 || mode >= N_MODES)

View File

@ -21,6 +21,10 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef _ICONS_H_
#define _ICONS_H_
#include "eimage.h"
typedef enum typedef enum
{ {
@ -30,4 +34,6 @@ typedef enum
EWIN_ICON_TYPE_NONE, EWIN_ICON_TYPE_NONE,
} ewin_icon_e; } ewin_icon_e;
Imlib_Image *EwinIconImageGet(EWin * ewin, int size, int mode); EImage *EwinIconImageGet(EWin * ewin, int size, int mode);
#endif /* _ICONS_H_ */

View File

@ -25,6 +25,7 @@
#include "borders.h" #include "borders.h"
#include "dialog.h" #include "dialog.h"
#include "e16-ecore_list.h" #include "e16-ecore_list.h"
#include "eimage.h"
#include "emodule.h" #include "emodule.h"
#include "eobj.h" #include "eobj.h"
#include "ewins.h" #include "ewins.h"
@ -650,8 +651,8 @@ MenuRealize(Menu * m)
int i, maxh, maxw, nmaxy; int i, maxh, maxw, nmaxy;
int maxx1, maxx2, w, h, x, y, r, mmw, mmh; int maxx1, maxx2, w, h, x, y, r, mmw, mmh;
int iw, ih; int iw, ih;
Imlib_Image *im; EImage *im;
Imlib_Border *pad, *pad_item, *pad_sub; EImageBorder *pad, *pad_item, *pad_sub;
char has_i, has_s; char has_i, has_s;
if (!m->style) if (!m->style)
@ -709,10 +710,8 @@ MenuRealize(Menu * m)
w = h = Conf.menus.icon_size; w = h = Conf.menus.icon_size;
if (w <= 0 || h <= 0) if (w <= 0 || h <= 0)
{ {
imlib_context_set_image(im); EImageGetSize(im, &w, &h);
w = imlib_image_get_width(); EImageFree(im);
h = imlib_image_get_height();
imlib_free_image();
} }
m->items[i]->icon_w = w; m->items[i]->icon_w = w;
m->items[i]->icon_h = h; m->items[i]->icon_h = h;

View File

@ -144,33 +144,6 @@ PagerDestroy(Pager * p)
Efree(p); Efree(p);
} }
static void
ScaleRect(Window src, Pixmap dst, Pixmap * pdst, int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh, int scale)
{
Imlib_Image *im;
Pixmap pmap, mask;
scale = (scale) ? 2 : 1;
imlib_context_set_drawable(src);
im = imlib_create_scaled_image_from_drawable(None, sx, sy, sw, sh,
scale * dw, scale * dh, 0, 0);
imlib_context_set_image(im);
imlib_context_set_anti_alias(1);
if (pdst)
{
imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, dw, dh);
*pdst = pmap;
}
else
{
imlib_context_set_drawable(dst);
imlib_render_image_on_drawable_at_size(dx, dy, dw, dh);
}
imlib_free_image();
}
static void static void
PagerScanTrig(Pager * p) PagerScanTrig(Pager * p)
{ {
@ -270,18 +243,15 @@ PagerScanTimeout(int val __UNUSED__, void *data)
static void static void
PagerHiwinUpdate(Hiwin * phi, Pager * p __UNUSED__, EWin * ewin) PagerHiwinUpdate(Hiwin * phi, Pager * p __UNUSED__, EWin * ewin)
{ {
Imlib_Image *im; EImage *im;
if (!EoIsShown(phi) || !ewin->mini_pmm.pmap) if (!EoIsShown(phi) || !ewin->mini_pmm.pmap)
return; return;
imlib_context_set_drawable(ewin->mini_pmm.pmap); im = EImageGrabDrawable(ewin->mini_pmm.pmap, None, 0, 0,
im = imlib_create_image_from_drawable(0, 0, 0, ewin->mini_w, ewin->mini_h, 0);
ewin->mini_w, ewin->mini_h, 0); EImageRenderOnDrawable(im, EoGetWin(phi), 0, 0, EoGetW(phi), EoGetH(phi), 0);
imlib_context_set_image(im); EImageDecache(im);
imlib_context_set_drawable(EoGetWin(phi));
imlib_render_image_on_drawable_at_size(0, 0, EoGetW(phi), EoGetH(phi));
imlib_free_image_and_decache();
} }
#endif #endif
@ -542,32 +512,27 @@ PagerUpdateBg(Pager * p)
#if USE_PAGER_BACKGROUND_CACHE #if USE_PAGER_BACKGROUND_CACHE
char s[4096]; char s[4096];
char *uniq; char *uniq;
Imlib_Image *im; EImage *im;
uniq = BackgroundGetUniqueString(bg); uniq = BackgroundGetUniqueString(bg);
Esnprintf(s, sizeof(s), "%s/cached/pager/%s.%i.%i.%s.png", Esnprintf(s, sizeof(s), "%s/cached/pager/%s.%i.%i.%s.png",
EDirUserCache(), BackgroundGetName(bg), p->dw, p->dh, uniq); EDirUserCache(), BackgroundGetName(bg), p->dw, p->dh, uniq);
Efree(uniq); Efree(uniq);
im = imlib_load_image(s); im = EImageLoad(s);
if (im) if (im)
{ {
imlib_context_set_image(im); EImageRenderOnDrawable(im, pmap, 0, 0, p->dw, p->dh, 0);
imlib_context_set_drawable(pmap); EImageDecache(im);
imlib_render_image_on_drawable_at_size(0, 0, p->dw, p->dh);
imlib_free_image_and_decache();
} }
else else
{ {
#endif #endif
BackgroundApplyPmap(bg, pmap, p->dw, p->dh); BackgroundApplyPmap(bg, pmap, p->dw, p->dh);
#if USE_PAGER_BACKGROUND_CACHE #if USE_PAGER_BACKGROUND_CACHE
imlib_context_set_drawable(pmap); im = EImageGrabDrawable(pmap, None, 0, 0, p->dw, p->dh, 0);
im = imlib_create_image_from_drawable(0, 0, 0, p->dw, p->dh, 1); EImageSave(im, s);
imlib_context_set_image(im); EImageDecache(im);
imlib_image_set_format("png");
imlib_save_image(s);
imlib_free_image_and_decache();
} }
#endif #endif
return; return;

View File

@ -22,6 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "E.h" #include "E.h"
#include "eimage.h"
#include "ewins.h" #include "ewins.h"
#include "xwin.h" #include "xwin.h"
#include <signal.h> #include <signal.h>
@ -242,17 +243,8 @@ SetupX(const char *dstr)
VRoot.h = RRoot.h; VRoot.h = RRoot.h;
} }
/* initialise imlib */ /* Initialise image handling */
imlib_set_cache_size(2048 * 1024); EImageInit(disp);
imlib_set_font_cache_size(512 * 1024);
imlib_set_color_usage(128);
imlib_context_set_dither(1);
imlib_context_set_display(disp);
imlib_context_set_visual(VRoot.vis);
imlib_context_set_colormap(VRoot.cmap);
imlib_context_set_dither_mask(0);
/* Initialise event handling */ /* Initialise event handling */
EventsInit(); EventsInit();

View File

@ -475,7 +475,7 @@ TextclassApply(ImageClass * iclass, Window win, int w, int h, int active,
int sticky, int state, char expose __UNUSED__, int sticky, int state, char expose __UNUSED__,
TextClass * tclass, const char *text) TextClass * tclass, const char *text)
{ {
Imlib_Border *pad; EImageBorder *pad;
if ((!iclass) || (!tclass) || (!text) || (!win) || (w < 1) || (h < 1)) if ((!iclass) || (!tclass) || (!text) || (!win) || (w < 1) || (h < 1))
return; return;

View File

@ -22,6 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "E.h" #include "E.h"
#include "eimage.h"
#include "tclass.h" #include "tclass.h"
#include "xwin.h" #include "xwin.h"
@ -790,10 +791,10 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state,
} }
void void
TextDrawRotTo(Window win, Drawable * drawable, int x, int y, int w, int h, TextDrawRotTo(Window win, Drawable * draw, int x, int y, int w, int h,
TextState * ts) TextState * ts)
{ {
Imlib_Image *ii = NULL; EImage *im;
int win_x, win_y; int win_x, win_y;
unsigned int win_w, win_h, win_b, win_d; unsigned int win_w, win_h, win_b, win_d;
Window rr; Window rr;
@ -801,43 +802,35 @@ TextDrawRotTo(Window win, Drawable * drawable, int x, int y, int w, int h,
switch (ts->style.orientation) switch (ts->style.orientation)
{ {
case FONT_TO_UP: case FONT_TO_UP:
imlib_context_set_drawable(win); im = EImageGrabDrawable(win, 0, y, x, h, w, 0);
ii = imlib_create_image_from_drawable(0, y, x, h, w, 0); EImageOrientate(im, 1);
imlib_context_set_image(ii); EImageRenderOnDrawable(im, *draw, 0, 0, w, h, 0);
imlib_image_orientate(1); EImageFree(im);
imlib_context_set_drawable(*drawable);
imlib_render_image_on_drawable_at_size(0, 0, w, h);
break; break;
case FONT_TO_DOWN: case FONT_TO_DOWN:
XGetGeometry(disp, win, &rr, &win_x, &win_y, &win_w, &win_h, XGetGeometry(disp, win, &rr, &win_x, &win_y, &win_w, &win_h,
&win_b, &win_d); &win_b, &win_d);
imlib_context_set_drawable(win); im = EImageGrabDrawable(win, None, win_w - y - h, x, h, w, 0);
ii = imlib_create_image_from_drawable(0, win_w - y - h, x, h, w, 0); EImageOrientate(im, 3);
imlib_context_set_image(ii); EImageRenderOnDrawable(im, *draw, 0, 0, w, h, 0);
imlib_image_orientate(3); EImageFree(im);
imlib_context_set_drawable(*drawable);
imlib_render_image_on_drawable_at_size(0, 0, w, h);
break; break;
case FONT_TO_LEFT: /* Holy carumba! That's for yoga addicts, maybe .... */ case FONT_TO_LEFT: /* Holy carumba! That's for yoga addicts, maybe .... */
imlib_context_set_drawable(win); im = EImageGrabDrawable(win, None, x, y, w, h, 0);
ii = imlib_create_image_from_drawable(0, x, y, w, h, 0); EImageOrientate(im, 2);
imlib_context_set_image(ii); EImageRenderOnDrawable(im, *draw, 0, 0, w, h, 0);
imlib_image_orientate(2); EImageFree(im);
imlib_context_set_drawable(*drawable);
imlib_render_image_on_drawable_at_size(0, 0, w, h);
break; break;
default: default:
break; break;
} }
if (ii)
imlib_free_image();
} }
void void
TextDrawRotBack(Window win, Pixmap drawable, int x, int y, int w, int h, TextDrawRotBack(Window win, Pixmap draw, int x, int y, int w, int h,
TextState * ts) TextState * ts)
{ {
Imlib_Image *ii = NULL; EImage *im;
int win_x, win_y; int win_x, win_y;
unsigned int win_w, win_h, win_b, win_d; unsigned int win_w, win_h, win_b, win_d;
Window rr; Window rr;
@ -845,34 +838,26 @@ TextDrawRotBack(Window win, Pixmap drawable, int x, int y, int w, int h,
switch (ts->style.orientation) switch (ts->style.orientation)
{ {
case FONT_TO_UP: case FONT_TO_UP:
imlib_context_set_drawable(drawable); im = EImageGrabDrawable(draw, None, 0, 0, w, h, 0);
ii = imlib_create_image_from_drawable(0, 0, 0, w, h, 0); EImageOrientate(im, 3);
imlib_context_set_image(ii); EImageRenderOnDrawable(im, win, y, x, h, w, 0);
imlib_image_orientate(3); EImageFree(im);
imlib_context_set_drawable(win);
imlib_render_image_on_drawable_at_size(y, x, h, w);
break; break;
case FONT_TO_DOWN: case FONT_TO_DOWN:
imlib_context_set_drawable(drawable);
XGetGeometry(disp, win, &rr, &win_x, &win_y, &win_w, &win_h, XGetGeometry(disp, win, &rr, &win_x, &win_y, &win_w, &win_h,
&win_b, &win_d); &win_b, &win_d);
ii = imlib_create_image_from_drawable(0, 0, 0, w, h, 0); im = EImageGrabDrawable(draw, None, 0, 0, w, h, 0);
imlib_context_set_image(ii); EImageOrientate(im, 1);
imlib_image_orientate(1); EImageRenderOnDrawable(im, win, win_w - y - h, x, h, w, 0);
imlib_context_set_drawable(win); EImageFree(im);
imlib_render_image_on_drawable_at_size(win_w - y - h, x, h, w);
break; break;
case FONT_TO_LEFT: /* Holy carumba! That's for yoga addicts, maybe .... */ case FONT_TO_LEFT: /* Holy carumba! That's for yoga addicts, maybe .... */
imlib_context_set_drawable(drawable); im = EImageGrabDrawable(draw, None, 0, 0, w, h, 0);
ii = imlib_create_image_from_drawable(0, 0, 0, w, h, 0); EImageOrientate(im, 2);
imlib_context_set_image(ii); EImageRenderOnDrawable(im, win, x, y, w, h, 0);
imlib_image_orientate(2); EImageFree(im);
imlib_context_set_drawable(win);
imlib_render_image_on_drawable_at_size(x, y, w, h);
break; break;
default: default:
break; break;
} }
if (ii)
imlib_free_image();
} }

View File

@ -232,7 +232,8 @@ static ImageClass *
TooltipCreateIclass(const char *name, const char *file, int *pw, int *ph) TooltipCreateIclass(const char *name, const char *file, int *pw, int *ph)
{ {
ImageClass *ic; ImageClass *ic;
Imlib_Image *im; EImage *im;
int w, h;
ic = ImageclassFind(name, 0); ic = ImageclassFind(name, 0);
if (!ic) if (!ic)
@ -241,11 +242,11 @@ TooltipCreateIclass(const char *name, const char *file, int *pw, int *ph)
if (im) if (im)
{ {
imlib_context_set_image(im); EImageGetSize(im, &w, &h);
if (*pw < imlib_image_get_width()) if (*pw < w)
*pw = imlib_image_get_width(); *pw = w;
if (*ph < imlib_image_get_height()) if (*ph < h)
*ph = imlib_image_get_height(); *ph = h;
} }
return ic; return ic;
@ -255,20 +256,18 @@ static void
TooltipIclassPaste(ToolTip * tt, const char *ic_name, int x, int y, int *px) TooltipIclassPaste(ToolTip * tt, const char *ic_name, int x, int y, int *px)
{ {
ImageClass *ic; ImageClass *ic;
Imlib_Image *im; EImage *im;
int w, h;
ic = ImageclassFind(ic_name, 0); ic = ImageclassFind(ic_name, 0);
im = ImageclassGetImage(ic, 0, 0, 0); im = ImageclassGetImage(ic, 0, 0, 0);
if (!ic || !im) if (!ic || !im)
return; return;
imlib_context_set_image(im); EImageGetSize(im, &w, &h);
imlib_context_set_drawable(tt->TTWIN->win); EImageRenderOnDrawable(im, tt->TTWIN->win, x, y, w, h, 1);
imlib_context_set_blend(1);
imlib_render_image_on_drawable(x, y);
imlib_context_set_blend(0);
*px = x + imlib_image_get_width(); *px = x + w;
} }
void void
@ -278,10 +277,10 @@ TooltipShow(ToolTip * tt, const char *text, ActionClass * ac, int x, int y)
int ww, hh, adx, ady, dist; int ww, hh, adx, ady, dist;
int headline_h = 0, headline_w = 0, icons_width = int headline_h = 0, headline_w = 0, icons_width =
0, labels_width = 0, double_w = 0; 0, labels_width = 0, double_w = 0;
Imlib_Image *im; EImage *im;
int *heights = NULL; int *heights = NULL;
ImageClass *ic; ImageClass *ic;
Imlib_Border *pad; EImageBorder *pad;
int cols[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int cols[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int num, modifiers; int num, modifiers;
Action *aa; Action *aa;
@ -431,10 +430,8 @@ TooltipShow(ToolTip * tt, const char *text, ActionClass * ac, int x, int y)
iy = 0; iy = 0;
if (im) if (im)
{ {
imlib_context_set_image(im); EImageGetSize(im, &iw, &ih);
iw = imlib_image_get_width(); EImageFree(im);
ih = imlib_image_get_height();
imlib_free_image();
} }
w += iw; w += iw;
if (h < ih) if (h < ih)

View File

@ -22,8 +22,10 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "E.h" #include "E.h"
#include "eimage.h"
#include "tclass.h" #include "tclass.h"
#include "xwin.h" #include "xwin.h"
#include <Imlib2.h>
struct _efont struct _efont
{ {
@ -65,21 +67,19 @@ void
EFont_draw_string(Drawable win, GC gc, int x, int y, const char *text, EFont_draw_string(Drawable win, GC gc, int x, int y, const char *text,
Efont * f, Visual * vis __UNUSED__, Colormap cm) Efont * f, Visual * vis __UNUSED__, Colormap cm)
{ {
Imlib_Image im; EImage *im;
int w, h, ascent, descent; int w, h, ascent, descent;
Efont_extents(f, text, &ascent, &descent, &w, NULL, NULL, NULL, NULL); Efont_extents(f, text, &ascent, &descent, &w, NULL, NULL, NULL, NULL);
h = ascent + descent; h = ascent + descent;
imlib_context_set_drawable(win); im = EImageGrabDrawable(win, None, x, y - ascent, w, h, 0);
im = imlib_create_image_from_drawable(0, x, y - ascent, w, h, 0);
imlib_context_set_image(im); imlib_context_set_image(im);
imlib_context_set_font(f->face); imlib_context_set_font(f->face);
ImlibSetFgColorFromGC(gc, cm); ImlibSetFgColorFromGC(gc, cm);
imlib_text_draw(0, 0, text); imlib_text_draw(0, 0, text);
imlib_render_image_on_drawable(x, y - ascent); EImageRenderOnDrawable(im, win, x, y - ascent, w, h, 0);
imlib_free_image(); EImageFree(im);
} }
void void

View File

@ -108,7 +108,7 @@ static void
WarpFocusWinShow(WarpFocusWin * fw) WarpFocusWinShow(WarpFocusWin * fw)
{ {
WarplistItem *wi; WarplistItem *wi;
Imlib_Border *pad; EImageBorder *pad;
int i, x, y, w, h, ww, hh; int i, x, y, w, h, ww, hh;
char s[1024]; char s[1024];
const char *fmt; const char *fmt;
@ -212,8 +212,8 @@ WarpFocusWinPaint(WarpFocusWin * fw)
if (Conf.warplist.icon_mode != 0) if (Conf.warplist.icon_mode != 0)
{ {
int icon_size = fw->mh - 2 * ICON_PAD; int icon_size = fw->mh - 2 * ICON_PAD;
Imlib_Image *im; EImage *im;
Imlib_Border *pad; EImageBorder *pad;
pad = ImageclassGetPadding(fw->ic); pad = ImageclassGetPadding(fw->ic);
@ -225,14 +225,10 @@ WarpFocusWinPaint(WarpFocusWin * fw)
if (!im) if (!im)
continue; continue;
imlib_context_set_image(im); EImageRenderOnDrawable(im, wi->win, pad->left +
imlib_context_set_drawable(wi->win); ICON_PAD, ICON_PAD,
imlib_context_set_blend(1); icon_size, icon_size, 1);
imlib_render_image_on_drawable_at_size(pad->left + EImageFree(im);
ICON_PAD, ICON_PAD,
icon_size, icon_size);
imlib_free_image();
imlib_context_set_blend(0);
} }
else else
{ {

43
src/x.c
View File

@ -1548,46 +1548,3 @@ EGetTimestamp(void)
return ev.xproperty.time; return ev.xproperty.time;
} }
void
EDrawableDumpImage(Drawable draw, const char *txt)
{
static int seqn = 0;
char buf[1024];
Imlib_Image *im;
int w, h;
w = h = 0;
EGetGeometry(draw, NULL, NULL, NULL, &w, &h, NULL, NULL);
if (w <= 0 || h <= 0)
return;
imlib_context_set_drawable(draw);
im = imlib_create_image_from_drawable(None, 0, 0, w, h, !EServerIsGrabbed());
imlib_context_set_image(im);
imlib_image_set_format("png");
sprintf(buf, "%s-%#lx-%d.png", txt, draw, seqn++);
Eprintf("EDrawableDumpImage: %s\n", buf);
imlib_save_image(buf);
imlib_free_image_and_decache();
}
void
FreePmapMask(PmapMask * pmm)
{
/* type !=0: Created by imlib_render_pixmaps_for_whole_image... */
if (pmm->pmap)
{
if (pmm->type == 0)
EFreePixmap(pmm->pmap);
else
imlib_free_pixmap_and_mask(pmm->pmap);
pmm->pmap = 0;
}
if (pmm->mask)
{
if (pmm->type == 0)
EFreePixmap(pmm->mask);
pmm->mask = 0;
}
}