Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature-vt/sys/lib/ghostscript/viewgif.ps – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
%    Copyright (C) 1989, 1992, 1993, 1998 Aladdin Enterprises.  All rights reserved.
2
% 
3
% This software is provided AS-IS with no warranty, either express or
4
% implied.
5
% 
6
% This software is distributed under license and may not be copied,
7
% modified or distributed except as expressly authorized under the terms
8
% of the license contained in the file LICENSE in this distribution.
9
% 
10
% For more information about licensing, please refer to
11
% http://www.ghostscript.com/licensing/. For information on
12
% commercial licensing, go to http://www.artifex.com/licensing/ or
13
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
% San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
 
16
% $Id: viewgif.ps,v 1.5 2003/04/12 18:08:18 ray Exp $
17
% viewgif.ps
18
% Display a GIF file.
19
 
20
/read1			% <file> read1 <int>
21
 { read pop
22
 } bind def
23
/read2			% <file> read2 <int>
24
 { dup read1 exch read1 8 bitshift add
25
 } bind def
26
 
27
/readGIFheader		% <file> readGIFheader <dict>
28
 { 20 dict begin
29
   dup 6 string readstring pop
30
   dup (GIF87a) eq exch (GIF89a) eq or not
31
    { (Not a GIF file.\n) print cleartomark stop
32
    } if
33
   dup read2 /Width exch def
34
   dup read2 /Height exch def
35
   dup read1
36
   dup 128 ge /GlobalColor exch def
37
   dup -4 bitshift 7 and 1 add /BitsPerPixel exch def	%***BOGUS?***
38
   dup 8 and 0 ne /PaletteSorted exch def
39
   7 and 1 add dup /BitsPerPixel exch def
40
     1 exch bitshift /PaletteSize exch def
41
   dup read1 /BackgroundIndex exch def
42
   dup read1 15 add 64 div /AspectRatio exch def
43
   GlobalColor
44
    { PaletteSize 3 mul string readstring pop
45
      /GlobalPalette exch def
46
    } if
47
   currentdict end
48
 } bind def
49
 
50
/readGIFimageHeader	% <file> readGIFimageHeader <dict>
51
			% Note: GIF header must be on dict stack
52
 { 10 dict begin
53
    { dup read1
54
      dup (!) 0 get ne { exit } if pop		% extension
55
      dup read1 pop
56
       { dup read1 dup 0 eq { pop exit } if { dup read1 pop } repeat
57
       } loop
58
    } loop
59
   (,) 0 get ne
60
    { (Not a GIF image.\n) print stop
61
    } if
62
   dup read2 /Left exch def
63
   dup read2 /Top exch def
64
   dup read2 /Width exch def
65
   dup read2 /Height exch def
66
   dup read1
67
   dup 128 ge /LocalColor exch def
68
   dup 64 and 0 ne /Interlaced exch def
69
   LocalColor
70
    { 7 and 1 add /BitsPerPixel exch def
71
      1 BitsPerPixel bitshift 3 mul string readstring pop
72
      /Palette exch def
73
    }
74
    { pop pop /Palette GlobalPalette def
75
    }
76
   ifelse
77
   currentdict end
78
 } bind def
79
 
80
/imageGIF		% <imagedict> imageGIF
81
 { /ImageOut where
82
    { pop
83
		% We know BitsPerComponent = 8, Decode = [0 255].
84
		% and there is only a single data source which is
85
		% either a filter or a string whose size is exactly
86
		% the width of the row.
87
      dup /DataSource get dup type /stringtype eq
88
       { ImageOut exch writestring
89
       }
90
       { pop dup /Width get string
91
	 1 index /Height get
92
	  { 1 index /DataSource get 1 index readstring pop
93
	    ImageOut exch writestring
94
	  }
95
	 repeat pop pop
96
       }
97
      ifelse 
98
    }
99
    { image
100
    }
101
   ifelse
102
 } bind def
103
 
104
/viewGIF		% <file|string> viewGIF -
105
 { save 20 dict begin
106
   /saved exch def
107
   dup type /stringtype eq { (r) file } if
108
   /F exch def
109
   /ImageOutFile where { /ImageOut ImageOutFile (w) file def } if
110
   F readGIFheader /Header exch def
111
     currentdict Header end begin begin
112
   VGIFDEBUG { Header { exch == == } forall (----------------\n) print flush } if
113
   F readGIFimageHeader /ImageHeader exch def
114
     currentdict ImageHeader end begin begin
115
   VGIFDEBUG { ImageHeader { exch == == } forall (----------------\n) print flush } if
116
   /D F
117
   <<	/InitialCodeLength F read1
118
	/FirstBitLowOrder true
119
	/BlockData true
120
	/EarlyChange 0
121
   >> /LZWDecode filter def
122
 
123
   [/Indexed /DeviceRGB 1 BitsPerPixel bitshift 1 sub Palette] setcolorspace
124
   matrix currentmatrix
125
 
126
   setmatrix
127
   <<	/ImageType 1
128
	/ImageMatrix [1 0 0 -1 0 Height]
129
	/BitsPerComponent 8
130
	/Decode [0 255]
131
   Interlaced
132
    {	/Width Width   /Height 1
133
	/row Width string def
134
	/DataSource row
135
      >> /I exch def
136
      /inter		% <num> <denom> inter -
137
       { /denom exch def   /num exch def
138
         gsave
139
	 /lines Height denom 1 sub add num sub denom idiv def
140
 
141
	   Height exch denom mul num add sub
142
	   I /ImageMatrix get 5 3 -1 roll put
143
	   D row readstring pop pop
144
	   I imageGIF
145
	 } for
146
	 grestore
147
       }
148
      bind def
149
 
150
      4 8 inter
151
      2 4 inter
152
      1 2 inter
153
    }
154
    {	/Width Width   /Height Height
155
	/DataSource D
156
      >> imageGIF
157
    }
158
   ifelse
159
   saved end end end restore
160
 } bind def