diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libdraw/allocimagemix.c | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libdraw/allocimagemix.c')
| -rw-r--r-- | libdraw/allocimagemix.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libdraw/allocimagemix.c b/libdraw/allocimagemix.c new file mode 100644 index 00000000..73501fea --- /dev/null +++ b/libdraw/allocimagemix.c @@ -0,0 +1,42 @@ +#include "lib9.h" +#include "draw.h" + +Image* +allocimagemix(Display *d, ulong color1, ulong color3) +{ + Image *t, *b; + static Image *qmask; + + if(qmask == nil) + qmask = allocimage(d, Rect(0,0,1,1), GREY8, 1, 0x3F3F3FFF); + + if(d->depth <= 8){ /* create a 2×2 texture */ + t = allocimage(d, Rect(0,0,1,1), d->chan, 0, color1); + if(t == nil) + return nil; + + b = allocimage(d, Rect(0,0,2,2), d->chan, 1, color3); + if(b == nil){ + freeimage(t); + return nil; + } + + draw(b, Rect(0,0,1,1), t, nil, ZP); + freeimage(t); + return b; + }else{ /* use a solid color, blended using alpha */ + t = allocimage(d, Rect(0,0,1,1), d->chan, 1, color1); + if(t == nil) + return nil; + + b = allocimage(d, Rect(0,0,1,1), d->chan, 1, color3); + if(b == nil){ + freeimage(t); + return nil; + } + + draw(b, b->r, t, qmask, ZP); + freeimage(t); + return b; + } +} |
