[comp.sys.mac.hypercard] TNPict

jk4i+@andrew.cmu.edu (John McCall Kingsley, III) (12/12/90)

Hi,

Does anyone know the paramters that are needed by the TNPict XCMD from the
Apple Technical Notes Stack. I have been trying to use this XCMD, and it
seems to work fine, but it takes several parameters, and I have been able
to figure out some of them, but not all of them -- I am especially interested
in finding out how to reduce the size of the image. I have typed in some
random combinations and the file is reduced by 36%, but I cannot figure out
how one might go about reducing it by some factor that I determine.

Thanks.
Jack Kingsley

fry@zariski.harvard.edu (David Fry) (12/12/90)

In article <QbNK1Me00WB4QTU0Nw@andrew.cmu.edu> jk4i+@andrew.cmu.edu (John McCall Kingsley, III) writes:
>Hi,
>
>Does anyone know the paramters that are needed by the TNPict XCMD from the
>Apple Technical Notes Stack. I have been trying to use this XCMD, and it
>seems to work fine, but it takes several parameters, and I have been able
>to figure out some of them, but not all of them -- I am especially interested
>in finding out how to reduce the size of the image. I have typed in some
>random combinations and the file is reduced by 36%, but I cannot figure out
>how one might go about reducing it by some factor that I determine.
>
>Thanks.
>Jack Kingsley


I wrote TNPict several years ago, so I should comment.  Below
is a sloppy listing of the parameters that was written at that
time as a note to myself.  Unfortunately, you cannot determine
the image reduction percentage; you can merely tell it to
shrink the image to the size of the window.

I should also note that TNPict has problems with HyperCard 2.0
and I don't have any firm plans now to fix it.  Sorry.  You
can use the Picture XCMD for a replacement.


David Fry                               fry@math.harvard.EDU
Department of Mathematics               fry@huma1.bitnet
Harvard University                      ...!harvard!huma1!fry
Cambridge, MA  02138            
-----------------------------cut here--------------------------

About TNPict...

TNPict is a HyperCard XCMD for displaying and printing picture files 
from within a script.  It can natively open PICT and MacPaint files, 
as well as files with a 'PICT' resource of ID = 0 (StartUpScreens on 
a Macintosh II).  In addition, there is a mechanism for opening 
virtually any file type; using this technique, TNPict can now open 
EPSF files.

The syntax for TNPict is as follows:

TNPict fileName,windows,bestColors,left,top,right,bottom,
                        delay,leftpixel,toppixel

Only the fileName parameter is required; the others are optional.

% fileName should be a partial or complete pathname to the file to be 
displayed.  If the pathname is partial, the XCMD will use the 
Documents card in the Home stack to attempt to find a file for 
opening.  

fileName can also be the name of a 'PICT' resource in the stack, in 
the Home stack, or in the HyperCard application itself.

% windows specifies what type of window the picture should be 
presented in.  If windows = 0, the window will be borderless, with no 
scroll bars, and can't be resized or moved.  If windows = 1, a normal 
moveable document window will be used, with scroll bars, and zoom, 
grow and close boxes.

If windows = 1, the user will also be presented with a Print button 
in the lower left corner of the window.  If the option key is held 
down, the Print button turns into a Page Setup button.

The default is windows = 0.

(Special feature: if windows = 2, the file will be displayed, 
printed, and closed immediately, without user intervention.)

% bestColors is used for displaying color files on a Mac II (it has 
no effect on computers without Color QuickDraw).  If bestColors is 
non-zero, the color table used to make the image originally will be 
used to display it now, resulting in best possible quality at the 
possible expense of any pictures in the background.  If bestColors = 
0, the current color environment will be used for the picture.

The default is bestColors = 0.

% left,top,right, and bottom specify, in global screen coordinates, 
where the window should be positioned.  If left=top=right=bottom=0 
(the default), the window will use the entire main screen (the screen 
with the menubar).

% delay is the length of time, in seconds, that the picture window 
should stay open before closing by itself.  If delay = 0, the 
default, the window won't close until the user closes it.

% leftpixel and toppixel are coordinates indicating where the image 
should be scrolled to.   They are the top left pixel of the image in 
the window when it opens.  If they are negative, the picture will be 
shifted down and to the right by that amount.  If 
leftpixel=toppixel=0 (the default), TNPict will center the picture in 
the window.

Once the window is open, the user can print and scroll around (if 
windows = 1).  S/he can close the file by typing command-W or 
command-period, as well as clicking on the goaway box.  The image can 
be printed by clicking the Print button; if an EPSF file was opened, 
it will be printed with PostScript.  If a color file is being used on 
a Macintosh II with enough memory (how much memory depends on the 
actual file), the XCMD will print a halftone image on PostScript-
equipped devices.

Typing command-F will toggle between the "Reduce to Fit" window.  In 
this mode, the picture is resized to fit entirely on the screen.  
Typing command-F again will return to the normal window.  While in 
the reduced window, if you hold down the shift key, you'll see a 
rectangle indicating what portion of the file is visible in the 
normal window.  By clicking while still holding the shift key, you 
can drag this rectangle around.  When you type command-F and return 
to the normal view, the picture will be scrolled to this new 
position.

(Special feature:  if you add 10 to the windows parameter, you can 
force the XCMD to open the picture in the Reduce to Fit mode 
initially, rather than requiring the user to first type command-F.  
For example, "TNPict Bill,11" )

If there was trouble opening the file, TNPict returns one of four 
error messages (accessible with "the result" function):
Error: File not found
Error: Not enough memory
Error: File could not be opened
Error: User canceled operation

(The last message is triggered when the user cancels the opening of a 
file, such as an EPSF file, with a command-period keystroke.  So far, 
it is only used for EPSF files, but that could change.)

If there was no error, the XCMD returns (again, via Rthe resultS 
function) the global screen rectangle of the window when closed by 
the user, in (left,top,right,bottom) format.  This is useful if you 
wish to remember the position of a window the last time a user looked 
at a particular graphic, so you can reopen the window in the same 
place next time.

Note: the 'STR#' resource named "TNPict" must be include in the stack 
with the XCMD.