summaryrefslogtreecommitdiff
path: root/libtk/image.c
diff options
context:
space:
mode:
authorforsyth <forsyth@vitanuova.com>2010-03-22 14:30:56 +0000
committerforsyth <forsyth@vitanuova.com>2010-03-22 14:30:56 +0000
commit0db9190e73bd2b1391b1108a354b8cf089ab5374 (patch)
tree755b2e6d0779e37a8530ab7097a0403fb5813524 /libtk/image.c
parentd764bd874c57ace45a2722fbc0c347ade01bc2f2 (diff)
20100322-1430
Diffstat (limited to 'libtk/image.c')
-rw-r--r--libtk/image.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libtk/image.c b/libtk/image.c
index 3b256eb3..cfd5f150 100644
--- a/libtk/image.c
+++ b/libtk/image.c
@@ -227,7 +227,6 @@ tkimage(TkTop *t, char *arg, char **ret)
TkImg *tkim;
char *fmt, *e, *buf, *cmd;
- /* Note - could actually allocate buf and cmd in one buffer - DBK */
buf = mallocz(Tkmaxitem, 0);
if(buf == nil)
return TkNomem;
@@ -318,14 +317,14 @@ tkimgput(TkImg *tki)
}
TkImg*
-tkauximage(TkTop *t, char* s, uchar* bytes, int nbytes, int chans, Rectangle r, int repl)
+tkauximage(TkTop *t, char* s, TkMemimage *m, int repl)
{
TkName *name;
TkCtxt *c;
TkImg *tki;
Display *d;
Image *i;
- int locked;
+ int locked, nbytes;
tki = tkname2img(t, s);
if (tki != nil) {
@@ -336,7 +335,7 @@ tkauximage(TkTop *t, char* s, uchar* bytes, int nbytes, int chans, Rectangle r,
name = tkmkname(s);
if (name == nil)
return nil;
- tki = mallocz(sizeof(*tki), 0);
+ tki = mallocz(sizeof(*tki), 1);
if (tki == nil)
goto err;
tki->env = tkdefaultenv(t);
@@ -346,15 +345,16 @@ tkauximage(TkTop *t, char* s, uchar* bytes, int nbytes, int chans, Rectangle r,
c = t->ctxt;
d = c->display;
+ nbytes = bytesperline(m->r, chantodepth(m->chans))*Dy(m->r);
locked = lockdisplay(d);
- i = allocimage(d, r, chans, repl, DTransparent);
+ i = allocimage(d, m->r, m->chans, repl, DTransparent);
if (i != nil) {
- if (loadimage(i, r, bytes, nbytes) != nbytes) {
+ if (loadimage(i, m->r, m->data, nbytes) != nbytes) {
freeimage(i);
i = nil;
}
if (repl)
- replclipr(i, 1, huger);
+ replclipr(i, 1, huger); /* TO DO: doesn't allocimage do this? */
}
if (locked)
unlockdisplay(d);
@@ -363,8 +363,8 @@ tkauximage(TkTop *t, char* s, uchar* bytes, int nbytes, int chans, Rectangle r,
tki->top = t;
tki->ref = 2; /* t->imgs ref and the ref we are returning */
tki->type = 0; /* bitmap */
- tki->w = Dx(r);
- tki->h = Dy(r);
+ tki->w = Dx(m->r);
+ tki->h = Dy(m->r);
tki->img = i;
tki->name = name;
tki->link = t->imgs;