From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from wopr.sciops.net ([216.126.196.60]) by ewsd; Fri Jan 18 12:40:21 EST 2019 Received: (qmail 72893 invoked from network); 18 Jan 2019 09:40:13 -0800 Received: from 105.15.136.77.rev.sfr.net (HELO u25.nope) (qwx@77.136.15.105) by wopr.sciops.net with SMTP; 18 Jan 2019 09:40:13 -0800 Message-ID: <29BD3DBBC18C327BB8A22649EADF6E77@wopr.sciops.net> From: qwx Date: Fri, 18 Jan 2019 18:40:02 +0100 To: 9front@9front.org Subject: libmemdraw bug? MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: transactional webscale table dependency WEB2.0 table-scale wrapper Hello, I'm looking at rsc's implementation of pico, which reads in images with readmemimage(). It only handles 248x248 images, but if extended to arbitrary dimensions, the images aren't displayed correctly unless their dimensions don't have the lowest 3 bits set. In other words, if dx & 7 and/or dy & 7, the image seems to be read/loaded incorrectly. Pico uses libmemdraw to load and manipulate images, then displays them with libdraw. I'm inlining below a simple program that demonstrates the issue. What is going on? Thanks, qwx /* ; hget http://9front.org/img/ninefront.bit > /tmp/ninefront.bit ; 6c -FTVw test.c && 6l test.6 && 6.out /tmp/ninefront.bit */ #include #include #include #include void main(int argc, char **argv) { int fd; Memimage *m; Image *i; if(argc != 2) sysfatal("usage"); if(memimageinit() < 0) sysfatal("memimageinit: %r"); if((fd = open(argv[1], OREAD)) < 0) sysfatal("open: %r"); m = readmemimage(fd); close(fd); if(m == nil) sysfatal("readmemimage: %r"); if(initdraw(nil, nil, nil) < 0) sysfatal("initdraw: %r"); if((i = allocimage(display, m->r, m->chan, 0, DNofill)) == nil) sysfatal("allocimage: %r"); if(loadimage(i, i->r, byteaddr(m, m->r.min), Dx(m->r)*Dy(m->r)*m->depth/8) < 0) sysfatal("loadimage: %r"); draw(screen, screen->r, i, nil, i->r.min); flushimage(display, 1); for(;;) sleep(1); }