summaryrefslogtreecommitdiff
path: root/sys/src/cmd/resample.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-10-18 20:17:12 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-10-18 20:17:12 +0200
commit558b9558d4d90c0dabaa57c9a3fe79f9f5f626d5 (patch)
tree3b654e941df4b0068c537fe47d6e0ff1302876c9 /sys/src/cmd/resample.c
parent0a3eb7d6b1ef7e9ef569dcc8e73c98a8446b52fc (diff)
more generic way to deal with image chan conversion for resize/resample/rotate
this is to catch crazy color channels like k8a8 and the 15/16 bit ones and CMAP. basically, just convert to RGBA32 or RGB24 depending on if it has an alpha channel.
Diffstat (limited to 'sys/src/cmd/resample.c')
-rw-r--r--sys/src/cmd/resample.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/sys/src/cmd/resample.c b/sys/src/cmd/resample.c
index 942589293..a1487a398 100644
--- a/sys/src/cmd/resample.c
+++ b/sys/src/cmd/resample.c
@@ -203,7 +203,6 @@ main(int argc, char *argv[])
Memimage *m, *new, *t1, *t2;
char *file;
ulong tchan;
- char tmp[100];
double v;
for(i=-K2; i<=K2; i++){
@@ -278,8 +277,15 @@ main(int argc, char *argv[])
if(xsize == 0)
xsize = (ysize * Dx(m->r)) / Dy(m->r);
- new = nil;
switch(m->chan){
+ default:
+ for(tchan = m->chan; tchan; tchan >>= 8)
+ if(TYPE(tchan) == CAlpha){
+ tchan = RGBA32;
+ goto Convert;
+ }
+ tchan = RGB24;
+ goto Convert;
case GREY8:
case RGB24:
@@ -289,12 +295,6 @@ main(int argc, char *argv[])
new = resample(xsize, ysize, m);
break;
- case CMAP8:
- case RGB15:
- case RGB16:
- tchan = RGB24;
- goto Convert;
-
case GREY1:
case GREY2:
case GREY4:
@@ -314,9 +314,6 @@ main(int argc, char *argv[])
memimagedraw(new, new->r, t2, t2->r.min, nil, ZP, S);
freememimage(t2);
break;
-
- default:
- sysfatal("can't handle channel type %s", chantostr(tmp, m->chan));
}
assert(new);