#include <draw.h>
#include <memdraw.h>
+int nflag;
+
static void
resample(Memimage *dst, Rectangle r, Memimage *src, Rectangle sr)
{
for(dp.y=0; dp.y<=dsize.y; dp.y++){
sp.y = _sp.y>>12;
ty = _sp.y&0xFFF;
+ if(nflag)
+ ty = ty << 1 & 0x1000;
pdst = pdst0;
sp.x = sr.min.x;
psrc0 = byteaddr(src, sp);
for(dp.x=0; dp.x<=dsize.x; dp.x++){
sp.x = _sp.x>>12;
tx = _sp.x&0xFFF;
+ if(nflag)
+ tx = tx << 1 & 0x1000;
psrc = psrc0 + sp.x*bpp;
s00 = (0x1000-tx)*(0x1000-ty);
s01 = tx*(0x1000-ty);
int fd, xsize, ysize;
Memimage *im, *nim;
ulong ochan, tchan;
- char buf[12];
xsize = ysize = 0;
ARGBEGIN{
case 'y':
ysize = getsize(EARGF(usage()));
break;
+ case 'n':
+ nflag++;
+ break;
default:
usage();
}ARGEND
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:
case XRGB32:
tchan = ochan;
break;
- case CMAP8:
- case RGB16:
- case RGB15:
- tchan = RGB24;
- break;
case GREY1:
case GREY2:
case GREY4:
if((nim = allocmemimage(
Rect(im->r.min.x, im->r.min.y, im->r.min.x+xsize, im->r.min.y+ysize),
tchan)) == nil)
- sysfatal("addocmemimage: %r");
+ sysfatal("allocmemimage: %r");
resample(nim, nim->r, im, im->r);
freememimage(im);
im = nim;