From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 8705 invoked from network); 13 Jan 2022 02:41:04 -0000 Received: from 4ess.inri.net (216.126.196.42) by inbox.vuxu.org with ESMTPUTF8; 13 Jan 2022 02:41:04 -0000 Received: from wopr.sciops.net ([216.126.196.60]) by 4ess; Wed Jan 12 21:36:15 -0500 2022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sciops.net; s=20210706; t=1642041363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=g2yVn2IgYYXf4xS6BKnLZFTnhXqbjnJkTSObDTg9ARE=; b=IZB+SM0WfEzjTQ9DCBoh+GBGYxuBnsQTsgRTaZK12IaYGF1NPUnK7qjpl/mqIEuFvLD2Fk JBUYQr2t8PpxuTN69eH+SAll7e1RcjQ8yuQDWxo/lFT1m15RecZA2nju6wg7c0qfNVJBw4 zIOyVFwsIy0BlT/KrG/hi28VNWJIDh8= Received: by wopr.sciops.net (OpenSMTPD) with ESMTPSA id 4f355293 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO) for <9front@9front.org>; Wed, 12 Jan 2022 18:36:03 -0800 (PST) Message-ID: <676DBB4BC5C037D3DD28D4476572730F@wopr.sciops.net> Date: Thu, 13 Jan 2022 03:36:01 +0100 From: qwx@sciops.net To: 9front@9front.org 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: compliant map/reduce framework Subject: [9front] page(1) invert colors Reply-To: 9front@9front.org Precedence: bulk Hello, Another optional patch for page(1), in case anyone finds it useful, for inverting image colors, which I find nice for reading pdf's given my eye strain problems, etc. etc. It's a bit silly, and I'm not aware of any external tool in 9front which can invert images, but phil9[1] and maybe others have written some. Cheers, qwx [1] gits://shithub.us/phil9/ifilter diff 6e64d30454f71ecda88dba1bd792e97509115d73 uncommitted --- a//sys/src/cmd/page.c +++ b//sys/src/cmd/page.c @@ -33,6 +33,7 @@ int imode; int newwin; int rotate; +int invert; int viewgen; int forward; /* read ahead direction: >= 0 forwards, < 0 backwards */ Point resize, pos; @@ -67,6 +68,7 @@ Cfitheight, Crotate90, Cupsidedown, + Cinvert, Cdummy1, Cnext, Cprev, @@ -91,6 +93,7 @@ [Cfitheight] "fit height", 'h', 0, 0, [Crotate90] "rotate 90", 'r', 0, 0, [Cupsidedown] "upside down", 'u', 0, 0, + [Cinvert] "invert", 'i', 0, 0, [Cdummy1] "", 0, 0, 0, [Cnext] "next", Kright, ' ', '\n', [Cprev] "prev", Kleft, Kbs, 0, @@ -894,6 +897,26 @@ } void +invertimage(Image *i) +{ + int n, m; + uchar *b; + uintptr *buf, *p; + + n = imagesize(i); + if((buf = malloc(n)) == nil) + return; + unloadimage(i, i->r, (uchar*)buf, n); + m = n; + for(p=buf; m>=sizeof *p; m-=sizeof *p, p++) + *p = ~*p; + for(b=(uchar*)p; m>0; m--, b++) + *b = ~*b; + loadimage(i, i->r, (uchar*)buf, n); + free(buf); +} + +void loadpage(Page *p) { int fd; @@ -913,6 +936,8 @@ p->open = nil; else { lockdisplay(display); + if(invert) + invertimage(p->image); imemsize += imagesize(p->image); unlockdisplay(display); } @@ -1492,6 +1517,9 @@ zoom = 1; resize = subpt(screen->r.max, screen->r.min); resize.x = 0; + goto Unload; + case Cinvert: + invert = !invert; goto Unload; case Czoomin: case Czoomout: