DIRECTORY SampleArrayIcons, Icons USING [iconH, IconRef, IconRep, iconW, NewIcon], SampleArrays USING [FromAIS, GetSample, SampleArray], Real USING [FixC]; SampleArrayIconsImpl: CEDAR PROGRAM IMPORTS Icons, SampleArrays, Real EXPORTS SampleArrayIcons = BEGIN OPEN SampleArrayIcons; iconH: INTEGER ~ Icons.iconH; iconW: INTEGER ~ Icons.iconW; NewIconFromFilename: PUBLIC PROC [file: ROPE] RETURNS [newFlavor: IconFlavor] ~ { sa: SampleArrays.SampleArray ~ SampleArrays.FromAIS[name: file]; newFlavor _ NewIcon[sa]; }; NewIcon: PUBLIC PROC [sa: SampleArrays.SampleArray, layer: NAT _ 0] RETURNS [newFlavor: IconFlavor] ~ { iconRef: Icons.IconRef _ NEW[Icons.IconRep]; bits: ARRAY [0 .. iconH) OF PACKED ARRAY [0 .. iconW) OF [0..1]; buffer: ARRAY [-1 .. iconW] OF INTEGER _ ALL[0]; this, next, d, dr: INTEGER _ 0; scale: REAL; PAScan: PROC [iconScan: CARDINAL] RETURNS [aisScan: CARDINAL] ~ INLINE { RETURN[Real.FixC[iconScan*scale]]; }; PAPixel: PROC [iconPixel: CARDINAL] RETURNS [aisPixel: CARDINAL] ~ INLINE { RETURN[Real.FixC[iconPixel*scale]]; }; scale _ MIN[(sa.fSize)/(iconW - 1.0), (sa.sSize)/(iconH - 1.0)]; FOR scan: CARDINAL IN [0 .. iconH) DO s: CARDINAL _ MIN[sa.sSize-1, Real.FixC[scan*scale]]; FOR pixel: CARDINAL IN [0 .. iconW) DO f: CARDINAL _ MIN[sa.fSize-1, Real.FixC[pixel*scale]]; this _ SampleArrays.GetSample[sa: sa, i: layer, index: [s: s, f: f]] + buffer[pixel] + next; IF this < 128 THEN bits[scan][pixel] _ 1 ELSE {bits[scan][pixel] _ 0; this _ this-255}; [buffer[pixel-1], d, dr, next] _ Propagate[this, d, dr]; ENDLOOP; ENDLOOP; FOR scan: CARDINAL IN [0 .. iconH) DO bits[scan][0] _ bits[scan][1] _ bits[scan][iconW-2] _ bits[scan][iconW-1] _ 1; ENDLOOP; FOR pixel: CARDINAL IN [0 .. iconH) DO bits[0][pixel] _ bits[1][pixel] _ bits[iconH-2][pixel] _ bits[iconH-1][pixel] _ 1; ENDLOOP; iconRef.bits _ LOOPHOLE[bits]; RETURN[Icons.NewIcon[iconRef]]; }; Propagate: PROC [this, oldd, olddr: INTEGER] RETURNS [dl, d, dr, next: INTEGER] ~ INLINE { RETURN [ dl: ThreeParts[this]+oldd, d: olddr + FiveParts[this], dr: OnePart[this], next: SevenParts[this] ] }; SixteenthOf: PROC [i: INTEGER] RETURNS [INTEGER] ~ TRUSTED INLINE {RETURN[i/16]}; OnePart: PROC [i: INTEGER] RETURNS [INTEGER] ~ INLINE {RETURN[SixteenthOf[i]]}; ThreeParts: PROC [i: INTEGER] RETURNS [INTEGER] ~ INLINE {RETURN[SixteenthOf[(i*3)]]}; FiveParts: PROC [i: INTEGER] RETURNS [INTEGER] ~ INLINE {RETURN[SixteenthOf[(i*5)]]}; SevenParts: PROC [i: INTEGER] RETURNS [INTEGER] ~ INLINE {RETURN[SixteenthOf[(i*7)]]}; END. €SampleArrayIconsImpl.mesa Copyright c 1984 by Xerox Corporation. All rights reserved. Created Thursday, August 2, 1984 9:41 pm PDT Last edited by Eric Nickell, December 14, 1985 11:01:08 pm PST UnsignedDivideBy16: PROC [INTEGER] RETURNS [INTEGER] ~ TRUSTED MACHINE CODE { PO.zLIB, 16; PO.zDIV }; SixteenthOf: PROC [i: INTEGER] RETURNS [INTEGER] ~ TRUSTED INLINE { RETURN[UnsignedDivideBy16[i+1024]-1024/16]; }; ΚJ˜šœ™Jšœ Οmœ1™J™—šΟk ˜ Jšœ˜Jšœžœ+˜6Icodešœ žœ#˜5Jšœžœ˜J˜—šœž ˜#Jšžœ˜!Jšžœ˜Jšœž˜Jšžœ˜J˜Jšœžœ˜Jšœžœ˜J˜š Οnœžœžœžœžœ˜QJ•StartOfExpansion[name: ROPE]˜@J˜J˜J˜—š Ÿœžœžœ'žœžœ˜gKšœžœ˜,Kš œžœžœžœžœžœ˜@Kš œžœžœžœžœ˜0Kšœžœ˜Kšœžœ˜ š Ÿœžœ žœžœ žœžœ˜HKšžœ˜"K˜—š Ÿœžœ žœžœ žœžœ˜KKšžœ˜#K˜—Kšœžœ5˜@J˜šžœžœžœž˜%Jšœžœžœ$˜5šžœžœžœž˜&Jšœžœžœ%˜6J–E[pa: ImagerPixelArrayDefs.PixelArray, i: NAT, s: INT, f: INT]šœ\˜\šžœ ˜ Jšžœ˜Jšžœ*˜.—J˜8Jšž˜—Jšž˜—šžœžœžœž˜%J˜NJšž˜—šžœžœžœž˜&J˜RJšž˜—Jšœžœ˜Jšžœ˜J˜J˜—š Ÿ œžœžœžœžœžœ˜Zšžœ˜J˜J˜J˜J˜Jšœ˜—J˜—šŸœžœžœžœžœžœžœžœ™NJšžœ žœ™J™—šŸ œžœžœžœžœžœžœ™CJšžœ%™+Jšœ™—JšŸ œžœžœžœžœžœžœžœ˜QJ˜JšŸœžœžœžœžœžœžœ˜OJšŸ œžœžœžœžœžœžœ˜VJšŸ œžœžœžœžœžœžœ˜UJšŸ œžœžœžœžœžœžœ˜VJ˜Jšžœ˜——…— ΨΖ