summaryrefslogtreecommitdiff
path: root/sys/src/cmd/resize.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/resize.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/resize.c')
-rw-r--r--sys/src/cmd/resize.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/src/cmd/resize.c b/sys/src/cmd/resize.c
index bc863b6a2..3773c8236 100644
--- a/sys/src/cmd/resize.c
+++ b/sys/src/cmd/resize.c
@@ -97,7 +97,6 @@ main(int argc, char **argv)
int fd, xsize, ysize;
Memimage *im, *nim;
ulong ochan, tchan;
- char buf[12];
xsize = ysize = 0;
ARGBEGIN{
@@ -134,7 +133,14 @@ main(int argc, char **argv)
ochan = im->chan;
switch(ochan){
default:
- sysfatal("can't handle channel type %s", chantostr(buf, ochan));
+ for(tchan = ochan; tchan; tchan >>= 8)
+ if(TYPE(tchan) == CAlpha){
+ tchan = RGBA32;
+ break;
+ }
+ if(tchan == 0)
+ tchan = RGB24;
+ break;
case GREY8:
case RGB24:
case RGBA32:
@@ -142,11 +148,6 @@ main(int argc, char **argv)
case XRGB32:
tchan = ochan;
break;
- case CMAP8:
- case RGB16:
- case RGB15:
- tchan = RGB24;
- break;
case GREY1:
case GREY2:
case GREY4: