Return-Path: Date: Wed, 5 Jun 1996 16:50:42 GMT From: "Sverre H. Huseby" To: xvtech@trilon.com Subject: patch for resizing keeping aspect ratio I did a quick change of the code to allow that resizing I talked about in my previous mail. I don't know if it is bug-free, just tested it a little bit. At the end of this text you'll find a context diff from the file xvevent.c from xv version 3.10a. Sverre. *** xvevent.c.old Wed Jun 5 17:55:42 1996 --- xvevent.c Wed Jun 5 18:33:24 1996 *************** *** 1672,1678 **** char txt[512], buf[64], *sp, ch; static char *labels[] = { "\nOk", "\033Cancel" }; ! sprintf(txt, "Enter new image display size (ex. '400 x 300'),\n"); strcat (txt, "expansion ratio (ex. '75%'),\n"); strcat (txt, "or expansion ratios (ex. '200% x 125%'):"); --- 1672,1679 ---- char txt[512], buf[64], *sp, ch; static char *labels[] = { "\nOk", "\033Cancel" }; ! sprintf(txt, "Enter new image display size (ex. '400 x 300')\n"); ! strcat (txt, "(omit one argument to keep aspect ratio),\n"); strcat (txt, "expansion ratio (ex. '75%'),\n"); strcat (txt, "or expansion ratios (ex. '200% x 125%'):"); *************** *** 1699,1705 **** switch (state) { case 0: /* haven't seen arg1 yet */ if (ch == ' ') {} ! else if (ch == '%' || ch == 'x' || ch == '\0') state = 99; /* no arg1 */ else { arg1 = (ch - '0'); state = 1; } break; --- 1700,1707 ---- switch (state) { case 0: /* haven't seen arg1 yet */ if (ch == ' ') {} ! else if (ch == 'x') { arg1 = -1; state = 4; } ! else if (ch == '%' || ch == '\0') state = 99; /* no arg1 */ else { arg1 = (ch - '0'); state = 1; } break; *************** *** 1730,1736 **** case 4: /* got arg1 [%] x */ if (ch == ' ') {} ! else if (ch == '%' || ch == 'x' || ch == '\0') state = 99; else { arg2 = (ch - '0'); state = 5; } break; --- 1732,1739 ---- case 4: /* got arg1 [%] x */ if (ch == ' ') {} ! else if (ch == '\0') { arg2 = -1; state = 100; } ! else if (ch == '%' || ch == 'x') state = 99; else { arg2 = (ch - '0'); state = 5; } break; *************** *** 1765,1771 **** } while (state!=99 && state!=100); /* done parsing... */ ! if (state == 99) { ErrPopUp("Error: The entered SetSize string is not valid.", "\nRight."); return; } --- 1768,1774 ---- } while (state!=99 && state!=100); /* done parsing... */ ! if (state == 99 || numargs == 0) { ErrPopUp("Error: The entered SetSize string is not valid.", "\nRight."); return; } *************** *** 1775,1781 **** arg1, arg2, numargs, pct1, pct2); /* otherwise... */ ! if (numargs == 1) { if (pct1) { neww = (cWIDE * arg1) / 100; newh = (cHIGH * arg1) / 100; --- 1778,1790 ---- arg1, arg2, numargs, pct1, pct2); /* otherwise... */ ! if (arg1 < 0) { ! newh = (pct2) ? (cHIGH * arg2) / 100 : arg2; ! neww = (int) (((long) newh * cWIDE) / cHIGH); ! } else if (arg2 < 0) { ! neww = (pct1) ? (cWIDE * arg1) / 100 : arg1; ! newh = (int) (((long) neww * cHIGH) / cWIDE); ! } else if (numargs == 1) { if (pct1) { neww = (cWIDE * arg1) / 100; newh = (cHIGH * arg1) / 100;