|
|
1.1 root 1: /* Copyright (c) 1989, 1990 AT&T --- All Rights Reserved. */
2: /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T. */
3: /* The copyright notice does not imply actual or intended publication. */
4: /* AUTHORS: */
5: /* H. S. Baird - ATT-BL MH - first versions */
6: /* A rle file consists of any number of:
7: `scan_line's, each of which has the form:
8: (short) bytes_mny, followed by bytes_mny bytes in the form:
9: (packed short) runs_mny
10: if >0, then followed by runs_mny runs
11: else if ==0, then followed by:
12: (packed short) blank_lines_mny skipped, -1
13: (packed short) runs_mny (>0), then...
14: ...runs_mny runs
15: A `run' is two (packed short) oxs,oxe which are
16: both offset counts >=0 from the prior `?x?' (starts at 0 at left margin).
17: Suppose that xs, xe are the corresponding accumulated pixel indices,
18: then xs is the pixel index of the first black pixel of the run,
19: and xe the pixel index of the first white pixel following the run.
20: A `packed short' is a byte if its value is <128, else two bytes `HIGH' & `LOW'
21: with the 0200 bit of its HIGH byte set.
22: */
23:
24: #define HIGH(A) ((A>>8)&0177)
25: #define LOW(A) (A&0377)
26:
27: /* run-length-encoding constants, typedefs */
28:
29: /* The following assumes a worst case page width of 17 inches (Legal page, >ISO A2)
30: and worst case digitizing resolution of 400 pixels/inch (e.g. CCITT Group 4),
31: for a maximum of 6800 pixels/line */
32: #define RLE_RUNS 3401 /* maximum no. runs in a line */
33: #define RLE_BYTES 6800 /* maximum no. data bytes in a rle line (enough?) */
34:
35: typedef struct RLE_Run {
36: short xs; /* x-coord of first pixel in run */
37: short xe; /* x-coord of last pixel in run (NOT first following) */
38: } RLE_Run;
39: #define Init_RLE_Run {0,0}
40:
41: typedef struct DRLE_Run {
42: short xs; /* x-coord of first pixel in run */
43: short xe; /* x-coord of last pixel in run (NOT first following) */
44: struct DRLE_Run *next;
45: } DRLE_Run;
46:
47: typedef struct RLE_Yrun {
48: short y,xs,xe;
49: } RLE_Yrun;
50: #define Init_RLE_Yrun {0,0,0}
51:
52: typedef struct RLE_Line {
53: short y; /* y-coord of line */
54: short len; /* length of line in pixels (white+black) */
55: short runs; /* no. of runs */
56: RLE_Run r[RLE_RUNS];
57: } RLE_Line;
58: #define Init_RLE_Line {0,0,0,Init_RLE_Run}
59:
60:
61: typedef struct DRLE_Line { /* dynamically allocated version */
62: DRLE_Run *r; /* first run */
63: DRLE_Run *lastr; /* last run */
64: } DRLE_Line;
65: #define Init_DRLE_Line {0,0}
66:
67: typedef struct RLE_Lines {
68: int mny;
69: RLE_Line *rla; /* array of RLE_Lines */
70: } RLE_Lines;
71: #define Init_RLE_Lines {0,NULL}
72: #if MAIN
73: RLE_Lines empty_RLE_Lines = Init_RLE_Lines;
74: #else
75: extern RLE_Lines empty_RLE_Lines;
76: #endif
77:
78: typedef struct Transform_rlel_arg {
79: boolean ident; /* if T, then no change (speed-optimization) */
80: Bbx tr; /* trim: select just this window of input */
81: Sp off; /* offset: translate by off.x,off.y */
82: Pp scl; /* scale: X & Y expansion factors (about 0,0) */
83: Sp wh; /* truncate: exact maximum output width,height */
84: Radians rot; /* rotate: angle (multiple of PI/4) */
85: boolean rev; /* reverse: swap black and white */
86: int sy; /* next integer line no. to write */
87: double dy; /* next real line no. to write */
88: } Transform_rlel_arg;
89: #define Init_Transform_rlel_arg {T,Init_Bbx,Init_Zero_Sp,{1.0,1.0},Init_Zero_Sp,0.0,F,0,0.0}
90: #if MAIN
91: Transform_rlel_arg empty_Transform_rlel_arg = Init_Transform_rlel_arg;
92: #else
93: extern Transform_rlel_arg empty_Transform_rlel_arg;
94: #endif
95:
96: #ifdef MAIN
97: /* these routines are found in rlelib.c */
98:
99: boolean RLE_open(); /* arg: (FILE *) */
100: RLE_Line *RLE_line(); /* args: l,r - left,right interval */
101: RLE_Line *RLE_get_Line(); /* args: l,r - left,right interval */
102: int RLE_run(); /* arg: (RLE_Run *) */
103: fwrb_rlines(); /* args: (FILE *), (RLE_Lines *) */
104: insert_rlel();
105: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.