From b3e120ecb6b363d2e3c58277097e53513e7d011b Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 26 Jun 2013 02:27:35 +0200 Subject: paint: restore color channel on undo after conversion thru pipe converting image thru pipe would not properly restore the original color channel on undo. like |iconv -c k8 would still be grayscale after undo. --- sys/src/cmd/paint.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/src/cmd/paint.c b/sys/src/cmd/paint.c index dafb29fa4..31996c3f1 100644 --- a/sys/src/cmd/paint.c +++ b/sys/src/cmd/paint.c @@ -259,10 +259,16 @@ restore(int n) if((tmp = undo[x]) == nil) return; undo[x] = nil; - expand(tmp->r); - draw(canvas, tmp->r, tmp, nil, tmp->r.min); - update(&tmp->r); - freeimage(tmp); + if(canvas != nil && canvas->chan != tmp->chan){ + freeimage(canvas); + canvas = tmp; + update(nil); + } else { + expand(tmp->r); + draw(canvas, tmp->r, tmp, nil, tmp->r.min); + update(&tmp->r); + freeimage(tmp); + } } } -- cgit v1.2.3