home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
223.lha
/
IffToPostScript
/
ifftops.doc
< prev
next >
Wrap
Text File
|
1989-04-07
|
12KB
|
265 lines
_i_f_f_t_o_p_s - _t_r_a_n_s_l_a_t_e _a_n _A_m_i_g_a _I_F_F _f_o_r_m_a_t _f_i_l_e _i_n_t_o _P_o_s_t_S_c_r_i_p_t
_i_f_f_t_o_p_s[-c]
[-_p<x-start>,<y-start>,<x-scale>,<y-scale>]
<_i_n_p_u_t-_f_i_l_e>[<output-file>]
_I_f_f_t_o_p_s translates Amiga IFF format files - specifically
InterLeaved BitMap (ILBM) graphics IFF files - into
PostScript format. It handles both black & white images and
color images (see NOTE #1 in NOTES section below), including
HAM mode images. There are options for positioning an image
on the output page, scaling the image (larger or smaller),
rotating the image, and placing multiple images on the same
output page.
The program works by generating a small PostScript-language
"header" followed by a hexadecimal representation (in
ASCII), of the bits of the image to render, in a raw format
that PostScript understands. When the "header" is executed
by the PostScript interpreter (which is commonly embedded in
the printer being used) it handles the positioning, scaling,
etc. functions and then reads all of the following data to
produce the resultant image.
All of the command line arguments are optional. The one
piece of information that _i_f_f_t_o_p_s needs is the name of the
input file to process. If this is not supplied on the com-
mand line then the user is prompted for it. (see NOTE #2)
The arguments to _i_f_f_t_o_p_s are:
-c color. Take a color ILBM IFF file and produce a
color PostScript output file. (If this flag is
used with a black & white ILBM IFF file then the
image is rendered in black & white with an
interesting sepia effect.)
-h hold page image. In PostScript terminology
each printed page is called a page image. By
default, _i_f_f_t_o_p_s appends a PostScript command at
the end of each processed IFF image to cause the
current page image to print out. If it is desired
to place more than one IFF image onto the same
printed page (i.e. page image) then this flag will
cause the PostScript command (specifically
"showpage") not to be appended. (see "EXAMPLES"
below)
-s smooth. This flag is my own attempt (very
unsophisticated and brute force) at smoothing out
the IFF image by doubling the number of pixels,
both horizontally and vertically, and averaging
the values. (see NOTE #3 below)
-r rotate. Rotate the image by the given number
March 21, 1989
- 2 -
of degrees. The value for the degrees must be
between 360 and -360. Positive values result in
counterclockwise rotation.
-p position. Place and size the IFF image within
the PostScript page image (i.e. on the resultant
printed page.) <x-start> and <y-start> are the
PostScript coordinates of the lower left-hand
corner of the image to be printed. The defaults
for these are 10 and 10 respectively. <x-scale>
and <y-scale> are the PostScript dimensions, of
the image to be printed, in the x and y direc-
tions. The defaults for these are 550 and 480
respectively. (see "EXAMPLES" below)
If an <output-file> is not specified on the command line
then the file "out.ps" is used. If the specified (or
default) <output-file> already exists then the output is
appended to the end of this file (this is so that the "-h"
flag (described above) will work.) Be careful that this is
what you want - it caused me trouble on several occasions by
appending to files when I didn't intend to.
_P_r_o_c_e_s_s _t_h_e _I_L_B_M _I_F_F _f_o_r_m_a_t _f_i_l_e _n_a_m_e_d "_d_o_g" _a_n_d _p_u_t _t_h_e
_r_e_s_u_l_t_i_n_g _P_o_s_t_S_c_r_i_p_t _o_u_t_p_u_t _i_n _t_h_e _f_i_l_e "_d_o_g._p_s":
_i_f_f_t_o_p_s _d_o_g _d_o_g._p_s
_P_o_s_i_t_i_o_n _a_n_d _s_c_a_l_e _t_h_e _i_m_a_g_e _t_o _b_e _i_n _t_h_e _c_e_n_t_e_r _o_f _t_h_e _p_a_g_e
_a_n_d _t_o _b_e _f_o_u_r _i_n_c_h_e_s _b_y _t_h_r_e_e _i_n_c_h_e_s:
_i_f_f_t_o_p_s -_p _1_6_2,_2_8_8,_2_8_8,_2_1_6 _d_o_g _d_o_g_2._p_s
_P_o_s_i_t_i_o_n, _s_c_a_l_e, _a_n_d _r_o_t_a_t_e _t_h_e _i_m_a_g_e _s_o _t_h_a_t _t_h_e_r_e _a_r_e _f_o_u_r
_c_o_p_y_s _o_f _t_h_e _i_m_a_g_e _o_n _t_h_e _p_a_g_e, _s_i_d_e-_b_y-_s_i_d_e, _a_l_l _f_o_u_r
_i_n_c_h_e_s _b_y _t_h_r_e_e _i_n_c_h_e_s:
_i_f_f_t_o_p_s -_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c_l_u_d_e"
_f_i_l_e_s _a_n_d _s_o_m_e "#_d_e_f_i_n_e"_s). _T_o _c_o_m_p_i_l_e _t_h_i_s _p_r_o_g_r_a_m
_f_o_r _o_n_e _o_f _t_h_e _t_w_o _e_n_v_i_r_o_n_m_e_n_t_s _e_i_t_h_e_r _a "#_d_e_f_i_n_e
_A_M_I_G_A" _o_r _a "#_d_e_f_i_n_e _U_N_I_X" _m_u_s_t _e_x_i_s_t _a_t _t_h_e _b_e_g_i_n_n_i_n_g
_o_f _t_h_e _f_i_l_e. _B_e _s_u_r_e _t_h_a_t _O_N_L_Y _O_N_E _o_f _t_h_e_s_e _t_w_o
"#_d_e_f_i_n_e"_s _i_s _i_n _e_f_f_e_c_t.
_3.) _T_h_e "-_s" _f_l_a_g _h_a_s _v_e_r_y _l_i_t_t_l_e _n_o_t_i_c_e_a_b_l_e _e_f_f_e_c_t _o_n _a
_3_0_0 _D_P_I _l_a_s_e_r _p_r_i_n_t_e_r. _I _b_e_l_i_e_v_e _t_h_a_t _t_h_i_s _i_s _b_e_c_a_u_s_e
_t_h_e _d_e_f_a_u_l_t "_p_r_i_n_t _c_e_l_l" _s_i_z_e _i_s _a_p_p_r_o_x_i_m_a_t_e_l_y _5_0 _c_e_l_l_s
_p_e_r _i_n_c_h. _O_n _t_h_e _Q_M_S _C_o_l_o_r_s_c_r_i_p_t-_1_0_0 _p_r_i_n_t_e_r _I
_p_r_e_p_e_n_d_e_d _t_h_e _f_o_l_l_o_w_i_n_g _P_o_s_t_S_c_r_i_p_t _c_o_d_e, _b_y _h_a_n_d, _t_o
_t_h_e _o_u_t_p_u_t _f_i_l_e _p_r_o_d_u_c_e_d _b_y _i_f_f_t_o_p_s:
%!
/sfreq 72 def
/sproc {dup mul exch dup mul add 1 exch sub} def
sfreq 60 /sproc load
sfreq 30 /sproc load
sfreq 0 /sproc load
sfreq 0 /sproc load
setcolorscreen
(NOTE: this printer is a four-color printer (YMCB))
(NOTE: the standard PostScript language has a counter-
part "setscreen" command for black & white printers.)
The result of adding these lines was a noticeable
reduction in the grainyness of the output file.
An unfortunate side effect of this smoothing function
is an aprox. 40% increase in the size of the source
code file. (I haven't check the relative sizes of the
binary files.) Because of this and because of its mar-
ginal usefulness, the source code includes preprocessor
defines, keyed on the identifier SMOOTH_INCLUDE, which
allow the smoothing code to be compiled out of the pro-
gram. Specifically, if the line "#define
SMOOTH_INCLUDE" exists in the source file then the
smoothing code will be included.
Happily, the smoothing function only adds a small
amount to the total execution time of the program.
However, the user should take note that using the "-s"
flag causes the output file to be four times larger
that it would be without using this flag.
_o_u_t._p_s _d_e_f_a_u_l_t _o_u_t_p_u_t _f_i_l_e _i_f _n_o_n_e _i_s _s_p_e_c_i_f_i_e_d
_T_h_e_r_e _s_h_o_u_l_d _b_e _a _w_a_y _f_o_r _t_h_e <_i_n_p_u_t-_f_i_l_e> _a_n_d <_o_u_t_p_u_t-_f_i_l_e>
_t_o _b_e _r_e-_d_i_r_e_c_t_e_d _f_r_o_m/_t_o _s_t_a_n_d_a_r_d-_i_n_p_u_t _a_n_d _s_t_a_n_d_a_r_d-
_o_u_t_p_u_t.
March 21, 1989
- 4 -
_L_e_R_o_y _F_u_n_d_i_n_g_s_l_a_n_d, _N_o_v_e_m_b_e_r _1_9_8_8
(_d_e_r_i_v_e_d _f_r_o_m _a _p_r_o_g_r_a_m _c_a_l_l_e_d _C_L_A_Z _w_h_i_c_h _w_a_s _c_r_e_a_t_e_d _b_y
_S_t_e_v_e _L_u_d_t_k_e, _M_a_y _1_9_8_7)
March 21, 1989