Remember rotations across pages.
[rsc] --rw-rw-r-- M 208511 glenda sys 2152 Jan 4 07:22 sys/src/cmd/page/page.h
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/page.h:42,47 -
/n/sources/plan9/sys/src/cmd/page/page.h:42,48
void rot180(Image*);
Image *rot90(Image*);
+ Image *rot270(Image*);
Image *resample(Image*, Image*);
/* ghostscript interface shared by ps, pdf */
[rsc] --rw-rw-r-- M 208511 glenda sys 10435 Jan 4 07:22 sys/src/cmd/page/rotate.c
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/rotate.c:245,250 -
/n/sources/plan9/sys/src/cmd/page/rotate.c:245,275
return(tmp);
}
+ /* rotates an image 270 degrees clockwise */
+ Image *
+ rot270(Image *im)
+ {
+ Image *tmp;
+ int i, j, dx, dy;
+
+ dx = Dx(im->r);
+ dy = Dy(im->r);
+ tmp = xallocimage(display, Rect(0, 0, dy, dx), im->chan, 0, DCyan);
+ if(tmp == nil) {
+ fprint(2, "out of memory during rot270: %r\n");
+ wexits("memory");
+ }
+
+ for(i = 0; i < dy; i++) {
+ for(j = 0; j < dx; j++) {
+ drawop(tmp, Rect(i, j, i+1, j+1), im, nil, Pt(dx-(j+1), i), S);
+ }
+ }
+ freeimage(im);
+
+ return(tmp);
+ }
+
/* from resample.c -- resize from → to using interpolation */
[rsc] --rw-rw-r-- M 208511 glenda sys 22893 Jan 4 07:22 sys/src/cmd/page/view.c
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:16,22 -
/n/sources/plan9/sys/src/cmd/page/view.c:16,22
Document *doc;
Image *im;
int page;
- int upside = 0;
+ int angle = 0;
int showbottom = 0; /* on the next showpage, move the image so the bottom is visible. */
Rectangle ulrange; /* the upper left corner of the image must be in this rectangle */
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:156,163 -
/n/sources/plan9/sys/src/cmd/page/view.c:156,172
im = tmp;
}
- if(upside)
+ switch(angle){
+ case 90:
+ im = rot90(im);
+ break;
+ case 180:
rot180(im);
+ break;
+ case 270:
+ im = rot270(im);
+ break;
+ }
esetcursor(nil);
if(showbottom){
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:390,396 -
/n/sources/plan9/sys/src/cmd/page/view.c:399,405
esetcursor(&reading);
rot180(im);
esetcursor(nil);
- upside = !upside;
+ angle = (angle+180) % 360;
redraw(screen);
flushimage(display, 1);
break;
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:589,594 -
/n/sources/plan9/sys/src/cmd/page/view.c:598,604
esetcursor(&reading);
im = rot90(im);
esetcursor(nil);
+ angle = (angle+90) % 360;
redraw(screen);
flushimage(display, 1);
break;
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:598,604 -
/n/sources/plan9/sys/src/cmd/page/view.c:608,614
esetcursor(&reading);
rot180(im);
esetcursor(nil);
- upside = !upside;
+ angle = (angle+180) % 360;
redraw(screen);
flushimage(display, 1);
break;
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:16,22 -
/n/sources/plan9/sys/src/cmd/page/view.c:16,22
Document *doc;
Image *im;
int page;
- int upside = 0;
+ int angle = 0;
int showbottom = 0; /* on the next showpage, move the image so the bottom is visible. */
Rectangle ulrange; /* the upper left corner of the image must be in this rectangle */
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:156,163 -
/n/sources/plan9/sys/src/cmd/page/view.c:156,172
im = tmp;
}
- if(upside)
+ switch(angle){
+ case 90:
+ im = rot90(im);
+ break;
+ case 180:
rot180(im);
+ break;
+ case 270:
+ im = rot270(im);
+ break;
+ }
esetcursor(nil);
if(showbottom){
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:390,396 -
/n/sources/plan9/sys/src/cmd/page/view.c:399,405
esetcursor(&reading);
rot180(im);
esetcursor(nil);
- upside = !upside;
+ angle = (angle+180) % 360;
redraw(screen);
flushimage(display, 1);
break;
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:589,594 -
/n/sources/plan9/sys/src/cmd/page/view.c:598,604
esetcursor(&reading);
im = rot90(im);
esetcursor(nil);
+ angle = (angle+90) % 360;
redraw(screen);
flushimage(display, 1);
break;
/n/sourcesdump/2006/0104/plan9/sys/src/cmd/page/view.c:598,604 -
/n/sources/plan9/sys/src/cmd/page/view.c:608,614
esetcursor(&reading);
rot180(im);
esetcursor(nil);
- upside = !upside;
+ angle = (angle+180) % 360;
redraw(screen);
flushimage(display, 1);
break;
|