author | Jan Vrany <jan.vrany@labware.com> |
Tue, 04 Apr 2023 14:22:18 +0200 | |
branch | jv |
changeset 4473 | 3675eb1de41b |
parent 3855 | 1db7742d33ad |
permissions | -rw-r--r-- |
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
1 |
" |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
2 |
COPYRIGHT (c) Claus Gittinger / 2006 by eXept Software AG |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
3 |
All Rights Reserved |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
4 |
|
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
5 |
This software is furnished under a license and may be used |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
10 |
hereby transferred. |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
11 |
" |
1804 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
15 |
|
1804 | 16 |
ImageReader subclass:#PICTReader |
1806 | 17 |
instanceVariableNames:'currentOpcode rowBytes bounds srcRect dstRect mode ctSeed ctFlags |
18 |
ctSize ctTable packType baseAddr pmVersion packSize hRes vRes |
|
19 |
pixelType pixelSize cmpCount cmpSize planeBytes pmTable |
|
20 |
pmReserved picSize picFrame picVersion' |
|
21 |
classVariableNames:'Opcodes' |
|
1804 | 22 |
poolDictionaries:'' |
23 |
category:'Graphics-Images-Readers' |
|
24 |
! |
|
25 |
||
1849 | 26 |
Object subclass:#PICTFrame |
27 |
instanceVariableNames:'image sourceRectangle destinationRectangle mode maskRegion' |
|
28 |
classVariableNames:'' |
|
29 |
poolDictionaries:'' |
|
30 |
privateIn:PICTReader |
|
31 |
! |
|
32 |
||
1804 | 33 |
!PICTReader class methodsFor:'documentation'! |
34 |
||
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
35 |
copyright |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
36 |
" |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
37 |
COPYRIGHT (c) Claus Gittinger / 2006 by eXept Software AG |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
38 |
All Rights Reserved |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
39 |
|
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
40 |
This software is furnished under a license and may be used |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
41 |
only in accordance with the terms of that license and with the |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
42 |
inclusion of the above copyright notice. This software may not |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
43 |
be provided or otherwise made available to, or used by, any |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
44 |
other person. No title to or ownership of the software is |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
45 |
hereby transferred. |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
46 |
" |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
47 |
! |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
48 |
|
1804 | 49 |
documentation |
50 |
" |
|
1807 | 51 |
this class will eventually provide fnctionality for loading and storing |
52 |
Apple PICT files. (QuickTime). |
|
1804 | 53 |
|
1807 | 54 |
WARNING: this is a first sceletton, ported from the AidaWeb PICTReader. |
1808 | 55 |
The implementation is VERY incomplete - it is provided here to provide a starting |
56 |
point for porters. |
|
1804 | 57 |
|
1850 | 58 |
For now, it does read a few sample images from the GFF books example CD. |
59 |
||
1804 | 60 |
[See also:] |
61 |
Image Form Icon |
|
62 |
BlitImageReader FaceReader JPEGReader GIFReader PBMReader PCXReader |
|
63 |
ST80FormReader TargaReader TIFFReader WindowsIconReader |
|
64 |
XBMReader XPMReader XWDReader |
|
65 |
" |
|
66 |
! |
|
67 |
||
68 |
examples |
|
69 |
" |
|
1849 | 70 |
PICTReader fromFile:'/unsaved2/stefan/nil/home/stefan/dos/winword/shared/ms.pct' |
71 |
PICTReader fromFile:'/phys/exept/tmp/pict/BLK.PCT' |
|
72 |
PICTReader fromFile:'/phys/exept/tmp/pict/BLU.PCT' |
|
73 |
PICTReader fromFile:'/phys/exept/tmp/pict/GRN.PCT' |
|
74 |
PICTReader fromFile:'/phys/exept/tmp/pict/RED.PCT' |
|
75 |
PICTReader fromFile:'/phys/exept/tmp/pict/WHT.PCT' |
|
76 |
PICTReader fromFile:'/phys/exept/tmp/pict/YEL.PCT' |
|
77 |
PICTReader fromFile:'/phys/exept/tmp/pict/FLAG_B24.PCT' |
|
78 |
PICTReader fromFile:'/phys/exept/tmp/pict/MARBLES.PCT' |
|
79 |
PICTReader fromFile:'/phys/exept/tmp/pict/TRU256.PCT' |
|
80 |
PICTReader fromFile:'/phys/exept/tmp/pict/VENUS.PCT' |
|
1807 | 81 |
|
82 |
||
83 |
example7 --- Version 2 PICTure --- |
|
84 |
||
85 |
| array stream image | |
|
86 |
array := #( |
|
87 |
16r0078 |
|
88 |
16r0000 16r0000 16r006C 16r00A8 |
|
89 |
16r0011 |
|
90 |
16r02FF |
|
91 |
16r0C00 |
|
92 |
16rFFFE |
|
93 |
16r0000 |
|
94 |
16r0048 16r0000 |
|
95 |
16r0048 16r0000 |
|
96 |
16r0002 16r0002 16r006E 16r00AA |
|
97 |
16r0000 |
|
98 |
16r001E |
|
99 |
16r0001 |
|
100 |
16r000A |
|
101 |
16r0002 16r0002 16r006E 16r00AA |
|
102 |
16r000A |
|
103 |
16r77DD 16r77DD 16r77DD 16r77DD |
|
104 |
16r0034 |
|
105 |
16r0002 16r0002 16r006E 16r00AA |
|
106 |
16r000A |
|
107 |
16r8822 16r8822 16r8822 16r8822 |
|
108 |
16r005C |
|
109 |
16r0008 |
|
110 |
16r0008 |
|
111 |
16r0071 |
|
112 |
16r001A |
|
113 |
16r0002 16r0002 16r006E 16r00AA |
|
114 |
16r006E 16r0002 16r0002 16r0054 16r006E 16r00AA 16r006E 16r0002 |
|
115 |
16r00FF |
|
116 |
). |
|
117 |
||
118 |
stream := WriteStream on: (ByteArray new: array size * 2 + 512). |
|
1843 | 119 |
stream next:512 put:0. |
1807 | 120 |
array do: |
121 |
[:n | |
|
122 |
stream nextPut: ((n bitAnd:16rFF00) bitShift: -8). |
|
123 |
stream nextPut: (n bitAnd: 16r00FF) |
|
124 |
]. |
|
125 |
image := PICTReader fromStream: (ReadStream on: stream contents). |
|
126 |
image |
|
127 |
||
128 |
||
1804 | 129 |
example8 |
130 |
--- Version 1 PICTure --- |
|
131 |
||
132 |
| array image | |
|
133 |
array := #[ |
|
134 |
16r00 16r4F |
|
135 |
16r00 16r02 16r00 16r02 16r00 16r6E 16r00 16rAA |
|
136 |
16r11 |
|
137 |
16r01 |
|
138 |
16r01 |
|
139 |
16r00 16r0A |
|
140 |
16r00 16r02 16r00 16r02 16r00 16r6E 16r00 16rAA |
|
141 |
16r0A |
|
142 |
16r77 16rDD 16r77 16rDD 16r77 16rDD 16r77 16rDD |
|
143 |
16r34 |
|
144 |
16r00 16r02 16r00 16r02 16r00 16r6E 16r00 16rAA |
|
145 |
16r0A |
|
146 |
16r88 16r22 16r88 16r22 16r88 16r22 16r88 16r22 |
|
147 |
16r5C |
|
148 |
16r71 |
|
149 |
16r00 16r1A |
|
150 |
16r00 16r02 16r00 16r02 16r00 16r6E 16r00 16rAA |
|
151 |
16r00 16r6E 16r00 16r02 16r00 16r02 16r00 16r54 16r00 16r6E 16r00 16rAA 16r00 16r6E 16r00 16r02 |
|
152 |
16rFF |
|
153 |
]. |
|
1807 | 154 |
array := (ByteArray new:512) , array. |
1804 | 155 |
image := PICTReader fromStream: (ReadStream on: array). |
1816 | 156 |
image |
1804 | 157 |
" |
158 |
! ! |
|
159 |
||
160 |
!PICTReader class methodsFor:'initialization'! |
|
161 |
||
1806 | 162 |
defineOpcodes00 |
163 |
Opcodes at: 16r0000 put: ('NOP' -> 0). |
|
164 |
Opcodes at: 16r0001 put: ('Clip' -> 'Region size'). |
|
165 |
Opcodes at: 16r0002 put: ('BkPat' -> 8). |
|
166 |
Opcodes at: 16r0003 put: ('TxFont' -> 2). |
|
167 |
Opcodes at: 16r0004 put: ('TxFace' -> 1). |
|
168 |
Opcodes at: 16r0005 put: ('TxMode' -> 2). |
|
169 |
Opcodes at: 16r0006 put: ('SpExtra' -> 4). |
|
170 |
Opcodes at: 16r0007 put: ('PnSize' -> 4). |
|
171 |
Opcodes at: 16r0008 put: ('PnMode' -> 2). |
|
172 |
Opcodes at: 16r0009 put: ('PnPat' -> 8). |
|
173 |
Opcodes at: 16r000A put: ('FillPat' -> 8). |
|
174 |
Opcodes at: 16r000B put: ('OvSize' -> 4). |
|
175 |
Opcodes at: 16r000C put: ('Origin' -> 4). |
|
176 |
Opcodes at: 16r000D put: ('TxSize' -> 2). |
|
177 |
Opcodes at: 16r000E put: ('FgColor' -> 4). |
|
178 |
Opcodes at: 16r000F put: ('BkColor' -> 4). |
|
179 |
! |
|
180 |
||
181 |
defineOpcodes01 |
|
182 |
Opcodes at: 16r0010 put: ('TxRatio' -> 8). |
|
183 |
Opcodes at: 16r0011 put: ('VersionOp' -> 1). |
|
184 |
Opcodes at: 16r0012 put: ('BkPixPat' -> 'Variable'). |
|
185 |
Opcodes at: 16r0013 put: ('PnPixPat' -> 'Variable'). |
|
186 |
Opcodes at: 16r0014 put: ('FillPixPat' -> 'Variable'). |
|
187 |
Opcodes at: 16r0015 put: ('PnLocHFrac' -> 2). |
|
188 |
Opcodes at: 16r0016 put: ('ChExtra' -> 2). |
|
189 |
Opcodes at: 16r0017 put: ('Apple0017' -> 'Not determined'). |
|
190 |
Opcodes at: 16r0018 put: ('Apple0018' -> 'Not determined'). |
|
191 |
Opcodes at: 16r0019 put: ('Apple0019' -> 'Not determined'). |
|
192 |
Opcodes at: 16r001A put: ('RGBFgCol' -> 6). |
|
193 |
Opcodes at: 16r001B put: ('RGBBkCol' -> 6). |
|
194 |
Opcodes at: 16r001C put: ('HiliteMode' -> 0). |
|
195 |
Opcodes at: 16r001D put: ('HiliteColor' -> 6). |
|
196 |
Opcodes at: 16r001E put: ('DefHilite' -> 0). |
|
197 |
Opcodes at: 16r001F put: ('OpColor' -> 6). |
|
198 |
! |
|
199 |
||
200 |
defineOpcodes02 |
|
201 |
Opcodes at: 16r0020 put: ('Line' -> 8). |
|
202 |
Opcodes at: 16r0021 put: ('LineFrom' -> 4). |
|
203 |
Opcodes at: 16r0022 put: ('ShortLine' -> 6). |
|
204 |
Opcodes at: 16r0023 put: ('ShortLineFrom' -> 2). |
|
205 |
Opcodes at: 16r0024 put: ('Apple0024' -> '2 + data length'). |
|
206 |
Opcodes at: 16r0025 put: ('Apple0025' -> '2 + data length'). |
|
207 |
Opcodes at: 16r0026 put: ('Apple0026' -> '2 + data length'). |
|
208 |
Opcodes at: 16r0027 put: ('Apple0027' -> '2 + data length'). |
|
209 |
Opcodes at: 16r0028 put: ('LongText' -> '5 + text'). |
|
210 |
Opcodes at: 16r0029 put: ('DHText' -> '2 + text'). |
|
211 |
Opcodes at: 16r002A put: ('DVText' -> '2 + text'). |
|
212 |
Opcodes at: 16r002B put: ('DHDVText' -> '3 + text'). |
|
213 |
Opcodes at: 16r002C put: ('fontName' -> '5 + name length'). |
|
214 |
Opcodes at: 16r002D put: ('lineJustify' -> 10). |
|
215 |
Opcodes at: 16r002E put: ('glyphState' -> 8). |
|
216 |
Opcodes at: 16r002F put: ('Apple002F' -> '2 + data length'). |
|
217 |
! |
|
218 |
||
219 |
defineOpcodes03 |
|
220 |
Opcodes at: 16r0030 put: ('frameRect' -> 8). |
|
221 |
Opcodes at: 16r0031 put: ('paintRect' -> 8). |
|
222 |
Opcodes at: 16r0032 put: ('eraseRect' -> 8). |
|
223 |
Opcodes at: 16r0033 put: ('invertRect' -> 8). |
|
224 |
Opcodes at: 16r0034 put: ('fillRect' -> 8). |
|
225 |
Opcodes at: 16r0035 put: ('Apple0035' -> 8). |
|
226 |
Opcodes at: 16r0036 put: ('Apple0036' -> 8). |
|
227 |
Opcodes at: 16r0037 put: ('Apple0037' -> 8). |
|
228 |
Opcodes at: 16r0038 put: ('frameSameRect' -> 0). |
|
229 |
Opcodes at: 16r0039 put: ('paintSameRect' -> 0). |
|
230 |
Opcodes at: 16r003A put: ('eraseSameRect' -> 0). |
|
231 |
Opcodes at: 16r003B put: ('invertSameRect' -> 0). |
|
232 |
Opcodes at: 16r003C put: ('fillSameRect' -> 0). |
|
233 |
Opcodes at: 16r003D put: ('Apple003D' -> 0). |
|
234 |
Opcodes at: 16r003E put: ('Apple003E' -> 0). |
|
235 |
Opcodes at: 16r003F put: ('Apple003F' -> 0). |
|
236 |
! |
|
237 |
||
238 |
defineOpcodes04 |
|
239 |
Opcodes at: 16r0040 put: ('frameRRect' -> 8). |
|
240 |
Opcodes at: 16r0041 put: ('paintRRect' -> 8). |
|
241 |
Opcodes at: 16r0042 put: ('eraseRRect' -> 8). |
|
242 |
Opcodes at: 16r0043 put: ('invertRRect' -> 8). |
|
243 |
Opcodes at: 16r0044 put: ('fillRect' -> 8). |
|
244 |
Opcodes at: 16r0045 put: ('Apple0045' -> 8). |
|
245 |
Opcodes at: 16r0046 put: ('Apple0046' -> 8). |
|
246 |
Opcodes at: 16r0047 put: ('Apple0047' -> 8). |
|
247 |
Opcodes at: 16r0048 put: ('frameSameRRect' -> 0). |
|
248 |
Opcodes at: 16r0049 put: ('paintSameRRect' -> 0). |
|
249 |
Opcodes at: 16r004A put: ('eraseSameRRect' -> 0). |
|
250 |
Opcodes at: 16r004B put: ('invertSameRRect' -> 0). |
|
251 |
Opcodes at: 16r004C put: ('fillSameRRect' -> 0). |
|
252 |
Opcodes at: 16r004D put: ('Apple004D' -> 0). |
|
253 |
Opcodes at: 16r004E put: ('Apple004E' -> 0). |
|
254 |
Opcodes at: 16r004F put: ('Apple004F' -> 0). |
|
255 |
! |
|
256 |
||
257 |
defineOpcodes05 |
|
258 |
Opcodes at: 16r0050 put: ('frameOval' -> 8). |
|
259 |
Opcodes at: 16r0051 put: ('paintOval' -> 8). |
|
260 |
Opcodes at: 16r0052 put: ('eraseOval' -> 8). |
|
261 |
Opcodes at: 16r0053 put: ('invertOval' -> 8). |
|
262 |
Opcodes at: 16r0054 put: ('fillRect' -> 8). |
|
263 |
Opcodes at: 16r0055 put: ('Apple0055' -> 8). |
|
264 |
Opcodes at: 16r0056 put: ('Apple0056' -> 8). |
|
265 |
Opcodes at: 16r0057 put: ('Apple0057' -> 8). |
|
266 |
Opcodes at: 16r0058 put: ('frameSameOval' -> 0). |
|
267 |
Opcodes at: 16r0059 put: ('paintSameOval' -> 0). |
|
268 |
Opcodes at: 16r005A put: ('eraseSameOval' -> 0). |
|
269 |
Opcodes at: 16r005B put: ('invertSameOval' -> 0). |
|
270 |
Opcodes at: 16r005C put: ('fillSameOval' -> 0). |
|
271 |
Opcodes at: 16r005D put: ('Apple005D' -> 0). |
|
272 |
Opcodes at: 16r005E put: ('Apple005E' -> 0). |
|
273 |
Opcodes at: 16r005F put: ('Apple005F' -> 0). |
|
274 |
! |
|
275 |
||
276 |
defineOpcodes06 |
|
277 |
Opcodes at: 16r0060 put: ('frameArc' -> 12). |
|
278 |
Opcodes at: 16r0061 put: ('paintArc' -> 12). |
|
279 |
Opcodes at: 16r0062 put: ('eraseArc' -> 12). |
|
280 |
Opcodes at: 16r0063 put: ('invertArc' -> 12). |
|
281 |
Opcodes at: 16r0064 put: ('fillRect' -> 12). |
|
282 |
Opcodes at: 16r0065 put: ('Apple0065' -> 12). |
|
283 |
Opcodes at: 16r0066 put: ('Apple0066' -> 12). |
|
284 |
Opcodes at: 16r0067 put: ('Apple0067' -> 12). |
|
285 |
Opcodes at: 16r0068 put: ('frameSameArc' -> 4). |
|
286 |
Opcodes at: 16r0069 put: ('paintSameArc' -> 4). |
|
287 |
Opcodes at: 16r006A put: ('eraseSameArc' -> 4). |
|
288 |
Opcodes at: 16r006B put: ('invertSameArc' -> 4). |
|
289 |
Opcodes at: 16r006C put: ('fillSameArc' -> 4). |
|
290 |
Opcodes at: 16r006D put: ('Apple006D' -> 4). |
|
291 |
Opcodes at: 16r006E put: ('Apple006E' -> 4). |
|
292 |
Opcodes at: 16r006F put: ('Apple006F' -> 4). |
|
293 |
! |
|
294 |
||
295 |
defineOpcodes07 |
|
296 |
Opcodes at: 16r0070 put: ('framePoly' -> 'Polygon size'). |
|
297 |
Opcodes at: 16r0071 put: ('paintPoly' -> 'Polygon size'). |
|
298 |
Opcodes at: 16r0072 put: ('erasePoly' -> 'Polygon size'). |
|
299 |
Opcodes at: 16r0073 put: ('invertPoly' -> 'Polygon size'). |
|
300 |
Opcodes at: 16r0074 put: ('fillRect' -> 'Polygon size'). |
|
301 |
Opcodes at: 16r0075 put: ('Apple0075' -> 'Polygon size'). |
|
302 |
Opcodes at: 16r0076 put: ('Apple0076' -> 'Polygon size'). |
|
303 |
Opcodes at: 16r0077 put: ('Apple0077' -> 'Polygon size'). |
|
304 |
Opcodes at: 16r0078 put: ('frameSamePoly' -> 0). |
|
305 |
Opcodes at: 16r0079 put: ('paintSamePoly' -> 0). |
|
306 |
Opcodes at: 16r007A put: ('eraseSamePoly' -> 0). |
|
307 |
Opcodes at: 16r007B put: ('invertSamePoly' -> 0). |
|
308 |
Opcodes at: 16r007C put: ('fillSamePoly' -> 0). |
|
309 |
Opcodes at: 16r007D put: ('Apple007D' -> 0). |
|
310 |
Opcodes at: 16r007E put: ('Apple007E' -> 0). |
|
311 |
Opcodes at: 16r007F put: ('Apple007F' -> 0). |
|
312 |
! |
|
313 |
||
314 |
defineOpcodes08 |
|
315 |
Opcodes at: 16r0080 put: ('frameRgn' -> 'Region size'). |
|
316 |
Opcodes at: 16r0081 put: ('paintRgn' -> 'Region size'). |
|
317 |
Opcodes at: 16r0082 put: ('eraseRgn' -> 'Region size'). |
|
318 |
Opcodes at: 16r0083 put: ('invertRgn' -> 'Region size'). |
|
319 |
Opcodes at: 16r0084 put: ('fillRect' -> 'Region size'). |
|
320 |
Opcodes at: 16r0085 put: ('Apple0085' -> 'Region size'). |
|
321 |
Opcodes at: 16r0086 put: ('Apple0086' -> 'Region size'). |
|
322 |
Opcodes at: 16r0087 put: ('Apple0087' -> 'Region size'). |
|
323 |
Opcodes at: 16r0088 put: ('frameSameRgn' -> 0). |
|
324 |
Opcodes at: 16r0089 put: ('paintSameRgn' -> 0). |
|
325 |
Opcodes at: 16r008A put: ('eraseSameRgn' -> 0). |
|
326 |
Opcodes at: 16r008B put: ('invertSameRgn' -> 0). |
|
327 |
Opcodes at: 16r008C put: ('fillSameRgn' -> 0). |
|
328 |
Opcodes at: 16r008D put: ('Apple008D' -> 0). |
|
329 |
Opcodes at: 16r008E put: ('Apple008E' -> 0). |
|
330 |
Opcodes at: 16r008F put: ('Apple008F' -> 0). |
|
331 |
! |
|
332 |
||
333 |
defineOpcodes09 |
|
334 |
Opcodes at: 16r0090 put: ('BitsRect' -> 'Variable'). |
|
335 |
Opcodes at: 16r0091 put: ('BitsRgn' -> 'Variable'). |
|
336 |
Opcodes at: 16r0092 put: ('Apple0092' -> '2 + data length'). |
|
337 |
Opcodes at: 16r0093 put: ('Apple0093' -> '2 + data length'). |
|
338 |
Opcodes at: 16r0094 put: ('Apple0094' -> '2 + data length'). |
|
339 |
Opcodes at: 16r0095 put: ('Apple0095' -> '2 + data length'). |
|
340 |
Opcodes at: 16r0096 put: ('Apple0096' -> '2 + data length'). |
|
341 |
Opcodes at: 16r0097 put: ('Apple0097' -> '2 + data length'). |
|
342 |
Opcodes at: 16r0098 put: ('PackBitsRect' -> 'Variable'). |
|
343 |
Opcodes at: 16r0099 put: ('PackBitsRgn' -> 'Variable'). |
|
344 |
Opcodes at: 16r009A put: ('DirectBitsRect' -> 'Variable'). |
|
345 |
Opcodes at: 16r009B put: ('DirectBitsRegn' -> 'Variable'). |
|
346 |
Opcodes at: 16r009C put: ('Apple009C' -> '2 + data length'). |
|
347 |
Opcodes at: 16r009D put: ('Apple009D' -> '2 + data length'). |
|
348 |
Opcodes at: 16r009E put: ('Apple009E' -> '2 + data length'). |
|
349 |
Opcodes at: 16r009F put: ('Apple009F' -> '2 + data length'). |
|
350 |
! |
|
351 |
||
352 |
defineOpcodes10 |
|
353 |
Opcodes at: 16r00A0 put: ('ShortComment' -> 2). |
|
354 |
Opcodes at: 16r00A1 put: ('LongComment' -> '4 + data'). |
|
355 |
Opcodes at: 16r00A2 put: ('Apple00A2' -> '2 + data length'). |
|
356 |
Opcodes at: 16r00A3 put: ('Apple00A3' -> '2 + data length'). |
|
357 |
Opcodes at: 16r00A4 put: ('Apple00A4' -> '2 + data length'). |
|
358 |
Opcodes at: 16r00A5 put: ('Apple00A5' -> '2 + data length'). |
|
359 |
Opcodes at: 16r00A6 put: ('Apple00A6' -> '2 + data length'). |
|
360 |
Opcodes at: 16r00A7 put: ('Apple00A7' -> '2 + data length'). |
|
361 |
Opcodes at: 16r00A8 put: ('Apple00A8' -> '2 + data length'). |
|
362 |
Opcodes at: 16r00A9 put: ('Apple00A9' -> '2 + data length'). |
|
363 |
Opcodes at: 16r00AA put: ('Apple00AA' -> '2 + data length'). |
|
364 |
Opcodes at: 16r00AB put: ('Apple00AB' -> '2 + data length'). |
|
365 |
Opcodes at: 16r00AC put: ('Apple00AC' -> '2 + data length'). |
|
366 |
Opcodes at: 16r00AD put: ('Apple00AD' -> '2 + data length'). |
|
367 |
Opcodes at: 16r00AE put: ('Apple00AE' -> '2 + data length'). |
|
368 |
Opcodes at: 16r00AF put: ('Apple00AF' -> '2 + data length'). |
|
369 |
! |
|
370 |
||
371 |
defineOpcodes99 |
|
372 |
Opcodes at: 16r00FF put: ('OpEndPic' -> 0). |
|
373 |
Opcodes at: 16r02FF put: ('Version' -> 2). |
|
374 |
Opcodes at: 16r0C00 put: ('HeaderOp' -> 24). |
|
375 |
Opcodes at: 16r8200 put: ('CompressedQuickTime' -> '4 + data length'). |
|
376 |
Opcodes at: 16r8201 put: ('UncompressedQuickTime' -> '4 + data length'). |
|
377 |
! |
|
378 |
||
1804 | 379 |
initialize |
380 |
"install myself in the Image classes fileFormat table |
|
1806 | 381 |
for the `.pic' and '.pict' extensions." |
382 |
||
383 |
MIMETypes defineImageType:nil suffix:'pict' reader:self. |
|
384 |
MIMETypes defineImageType:nil suffix:'pic' reader:self. |
|
385 |
||
386 |
"PictReader initialize." |
|
387 |
! |
|
388 |
||
389 |
initializeOpcodes |
|
390 |
"PictImageStream initializeOpcodes." |
|
1804 | 391 |
|
1806 | 392 |
Opcodes := IdentityDictionary new: 100. |
393 |
self defineOpcodes00. |
|
394 |
self defineOpcodes01. |
|
395 |
self defineOpcodes02. |
|
396 |
self defineOpcodes03. |
|
397 |
self defineOpcodes04. |
|
398 |
self defineOpcodes05. |
|
399 |
self defineOpcodes06. |
|
400 |
self defineOpcodes07. |
|
401 |
self defineOpcodes08. |
|
402 |
self defineOpcodes09. |
|
403 |
self defineOpcodes10. |
|
404 |
self defineOpcodes99. |
|
405 |
^Opcodes |
|
1804 | 406 |
! ! |
407 |
||
1807 | 408 |
!PICTReader class methodsFor:'opcodes'! |
409 |
||
410 |
opcodeAt: opcode |
|
411 |
"PictImageStream opcodeAt: 16r8201." |
|
412 |
||
413 |
| key value string | |
|
414 |
||
415 |
Opcodes isNil ifTrue:[ |
|
416 |
self initializeOpcodes |
|
417 |
]. |
|
418 |
||
419 |
(Opcodes includesKey: opcode) |
|
420 |
ifTrue: [^Opcodes at: opcode]. |
|
421 |
||
422 |
string := opcode printStringRadix: 16. |
|
423 |
string := string leftPaddedTo:4 with:$0. "/ 4 - string size timesRepeat: [string := '0' , string]. " |
|
424 |
||
425 |
key := 'Apple' , string. |
|
426 |
(16r00B0 <= opcode and: [opcode <= 16r00CF]) |
|
427 |
ifTrue: |
|
428 |
[value := 0. |
|
429 |
^key -> value]. |
|
430 |
(16r00D0 <= opcode and: [opcode <= 16r00FE]) |
|
431 |
ifTrue: |
|
432 |
[value := '4 + data length'. |
|
433 |
^key -> value]. |
|
434 |
(16r0100 <= opcode and: [opcode <= 16r01FF]) |
|
435 |
ifTrue: |
|
436 |
[value := 2. |
|
437 |
^key -> value]. |
|
438 |
(16r0200 <= opcode and: [opcode <= 16r02FE]) |
|
439 |
ifTrue: |
|
440 |
[value := 4. |
|
441 |
^key -> value]. |
|
442 |
(16r0300 <= opcode and: [opcode <= 16r0BFF]) |
|
443 |
ifTrue: |
|
444 |
[value := 22. |
|
445 |
^key -> value]. |
|
446 |
(16r0C01 <= opcode and: [opcode <= 16r7EFF]) |
|
447 |
ifTrue: |
|
448 |
[value := 24. |
|
449 |
^key -> value]. |
|
450 |
(16r7F00 <= opcode and: [opcode <= 16r7FFF]) |
|
451 |
ifTrue: |
|
452 |
[value := 254. |
|
453 |
^key -> value]. |
|
454 |
(16r8000 <= opcode and: [opcode <= 16r80FF]) |
|
455 |
ifTrue: |
|
456 |
[value := 0. |
|
457 |
^key -> value]. |
|
458 |
(16r8100 <= opcode and: [opcode <= 16r81FF]) |
|
459 |
ifTrue: |
|
460 |
[value := '4 + data length'. |
|
461 |
^key -> value]. |
|
462 |
(16r8201 <= opcode and: [opcode <= 16rFFFF]) |
|
463 |
ifTrue: |
|
464 |
[value := '4 + data length'. |
|
465 |
^key -> value]. |
|
466 |
^nil |
|
467 |
! ! |
|
468 |
||
1804 | 469 |
!PICTReader class methodsFor:'testing'! |
470 |
||
471 |
isValidImageFile:aFileName |
|
472 |
"return true, if aFileName contains a sunraster image" |
|
473 |
||
474 |
|inStream nr| |
|
475 |
||
476 |
inStream := self streamReadingFile:aFileName. |
|
477 |
inStream isNil ifTrue:[^ false]. |
|
478 |
||
479 |
"try sun raster" |
|
480 |
inStream binary. |
|
481 |
((inStream nextWord == 16r59A6) |
|
482 |
and:[inStream nextWord == 16r6A95]) ifTrue: [ |
|
483 |
inStream close. |
|
484 |
^ true |
|
485 |
]. |
|
486 |
||
487 |
inStream isPositionable ifFalse:[^ false]. |
|
488 |
||
489 |
"try sun bitmap image format" |
|
490 |
inStream text. |
|
491 |
inStream reset. |
|
492 |
||
493 |
"must start with a comment" |
|
494 |
inStream skipSeparators. |
|
495 |
inStream next ~~ $/ ifTrue:[^ false]. |
|
496 |
inStream next ~~ $* ifTrue:[^ false]. |
|
497 |
||
498 |
(inStream skipThroughAll: 'idth') isNil ifTrue: [ |
|
499 |
inStream close. |
|
500 |
^ false |
|
501 |
]. |
|
502 |
inStream next; skipSeparators. |
|
503 |
nr := Integer readFrom: inStream. |
|
504 |
(nr isNil or:[nr <= 0]) ifTrue: [ |
|
505 |
inStream close. |
|
506 |
^ false |
|
507 |
]. |
|
508 |
||
509 |
(inStream skipThroughAll: 'eight') isNil ifTrue: [ |
|
510 |
inStream close. |
|
511 |
^ false |
|
512 |
]. |
|
513 |
inStream next; skipSeparators. |
|
514 |
nr := Integer readFrom: inStream. |
|
515 |
(nr isNil or:[nr <= 0]) ifTrue: [ |
|
516 |
inStream close. |
|
517 |
^ false |
|
518 |
]. |
|
519 |
||
520 |
inStream close. |
|
521 |
^ true |
|
522 |
! ! |
|
523 |
||
1806 | 524 |
!PICTReader methodsFor:'commands'! |
525 |
||
526 |
xBitsRect |
|
1807 | 527 |
self debug:[ Transcript show:'xBitsRect'; cr ]. |
1806 | 528 |
^self xPackBitsRect |
529 |
! |
|
530 |
||
531 |
xBitsRgn |
|
1807 | 532 |
self debug:[ Transcript show:'xBitsRgn'; cr ]. |
1806 | 533 |
^self xPackBitsRgn |
534 |
! |
|
535 |
||
536 |
xDHDVText |
|
537 |
| dh dv count string | |
|
1807 | 538 |
self debug:[ Transcript show:'xDHDVText'; cr ]. |
539 |
||
1806 | 540 |
dh := self next. |
541 |
dv := self next. |
|
542 |
count := self next. |
|
543 |
string := (self next: count) asString. |
|
544 |
self |
|
545 |
debug: |
|
546 |
[Transcript space; show: dh printString. |
|
547 |
Transcript space; show: dv printString. |
|
548 |
Transcript space; show: count printString. |
|
549 |
Transcript space; show: string printString]. |
|
550 |
^Array |
|
551 |
with: dh |
|
552 |
with: dv |
|
553 |
with: count |
|
554 |
with: string |
|
555 |
! |
|
556 |
||
557 |
xDHText |
|
558 |
| dh count string | |
|
1807 | 559 |
|
560 |
self debug:[ Transcript show:'xDHText'; cr ]. |
|
561 |
||
1806 | 562 |
dh := self next. |
563 |
count := self next. |
|
564 |
string := (self next: count) asString. |
|
565 |
self |
|
566 |
debug: |
|
567 |
[Transcript space; show: dh printString. |
|
568 |
Transcript space; show: count printString. |
|
569 |
Transcript space; show: string printString]. |
|
570 |
^Array |
|
571 |
with: dh |
|
572 |
with: count |
|
573 |
with: string |
|
574 |
! |
|
575 |
||
576 |
xDVText |
|
577 |
| dv count string | |
|
1807 | 578 |
|
579 |
self debug:[ Transcript show:'xDVText'; cr ]. |
|
580 |
||
1806 | 581 |
dv := self next. |
582 |
count := self next. |
|
583 |
string := (self next: count) asString. |
|
584 |
self |
|
585 |
debug: |
|
586 |
[Transcript space; show: dv printString. |
|
587 |
Transcript space; show: count printString. |
|
588 |
Transcript space; show: string printString]. |
|
589 |
^Array |
|
590 |
with: dv |
|
591 |
with: count |
|
592 |
with: string |
|
593 |
! |
|
594 |
||
595 |
xDirectBitsRect |
|
596 |
| record | |
|
1807 | 597 |
|
598 |
self debug:[ Transcript show:'xDirectBitsRect'; cr ]. |
|
599 |
||
1806 | 600 |
record := self readDirectPixMap: false. |
601 |
self debug: [Transcript space; show: record printString]. |
|
602 |
imageSequence add: record. |
|
603 |
^record |
|
604 |
! |
|
605 |
||
606 |
xDirectBitsRgn |
|
607 |
^self readDirectPixMap: true |
|
608 |
! |
|
609 |
||
610 |
xFontName |
|
611 |
| dataLength fontId nameLength fontName | |
|
1807 | 612 |
|
613 |
self debug:[ Transcript show:'xFontName'; cr ]. |
|
614 |
||
1806 | 615 |
dataLength := self nextWord. |
616 |
fontId := self nextWord. |
|
617 |
nameLength := self next. |
|
618 |
fontName := (self next: nameLength) asString. |
|
619 |
self |
|
620 |
debug: |
|
621 |
[Transcript space; show: dataLength printString. |
|
622 |
Transcript space; show: fontId printString. |
|
623 |
Transcript space; show: nameLength printString. |
|
624 |
Transcript space; show: fontName printString]. |
|
625 |
^Array |
|
626 |
with: dataLength |
|
627 |
with: fontId |
|
628 |
with: nameLength |
|
629 |
with: fontName |
|
630 |
! |
|
631 |
||
632 |
xLongComment |
|
633 |
| kind size bytes aStream char | |
|
1807 | 634 |
|
635 |
self debug:[ Transcript show:'xLongComment'; cr ]. |
|
636 |
||
1806 | 637 |
kind := self nextWord. |
638 |
size := self nextWord. |
|
639 |
bytes := self next: size. |
|
640 |
aStream := WriteStream on: (String new: bytes size). |
|
641 |
bytes |
|
642 |
do: |
|
643 |
[:byte | |
|
644 |
char := Character value: byte. |
|
645 |
((33 <= byte and: [byte <= 126]) |
|
646 |
or: [char = Character tab or: [char = Character space or: [char = Character cr]]]) |
|
647 |
ifTrue: [aStream nextPut: char] |
|
648 |
ifFalse: [aStream nextPut: Character space]]. |
|
649 |
self |
|
650 |
debug: |
|
651 |
[Transcript space; show: kind printString. |
|
652 |
Transcript space; show: size printString. |
|
653 |
Transcript space; show: aStream contents printString]. |
|
654 |
^Array |
|
655 |
with: kind |
|
656 |
with: size |
|
657 |
with: bytes |
|
658 |
! |
|
659 |
||
660 |
xLongText |
|
661 |
| point count string | |
|
1807 | 662 |
|
663 |
self debug:[ Transcript show:'xLongText'; cr ]. |
|
664 |
||
1806 | 665 |
point := self readPoint. |
666 |
count := self next. |
|
667 |
string := (self next: count) asString. |
|
668 |
self |
|
669 |
debug: |
|
670 |
[Transcript space; show: point printString. |
|
671 |
Transcript space; show: count printString. |
|
672 |
Transcript space; show: string printString]. |
|
673 |
^Array |
|
674 |
with: point |
|
675 |
with: count |
|
676 |
with: string |
|
677 |
! |
|
678 |
||
679 |
xPackBitsRect |
|
680 |
| position word record | |
|
1807 | 681 |
|
682 |
self debug:[ Transcript show:'xPackBitsRect'; cr ]. |
|
683 |
||
1806 | 684 |
position := self position. |
685 |
word := self nextWord. |
|
686 |
self position: position. |
|
687 |
(word bitShift: -15) |
|
688 |
= 1 |
|
689 |
ifTrue: [record := self readPixMap: false] |
|
690 |
ifFalse: [record := self readBitMap: false]. |
|
691 |
self debug: [Transcript space; show: record printString]. |
|
692 |
imageSequence add: record. |
|
693 |
^record |
|
694 |
! |
|
695 |
||
696 |
xPackBitsRgn |
|
697 |
| position word record | |
|
1807 | 698 |
|
699 |
self debug:[ Transcript show:'xPackBitsRgn'; cr ]. |
|
700 |
||
1806 | 701 |
position := self position. |
702 |
word := self nextWord. |
|
703 |
self position: position. |
|
704 |
(word bitShift: -15) |
|
705 |
= 1 |
|
706 |
ifTrue: [record := self readPixMap: true] |
|
707 |
ifFalse: [record := self readBitMap: true]. |
|
708 |
self debug: [Transcript space; show: record printString]. |
|
709 |
imageSequence add: record. |
|
710 |
^record |
|
711 |
! ! |
|
712 |
||
1807 | 713 |
!PICTReader methodsFor:'debugging'! |
714 |
||
715 |
debug: aBlock |
|
716 |
aBlock value |
|
717 |
! ! |
|
718 |
||
1806 | 719 |
!PICTReader methodsFor:'decoding'! |
720 |
||
721 |
readBitData |
|
722 |
| bitData | |
|
723 |
bitData := ByteArray new: rowBytes * bounds height. |
|
724 |
self progress: 0. |
|
725 |
1 to: bounds height |
|
726 |
do: |
|
727 |
[:column | |
|
728 |
| start stop replacement | |
|
729 |
start := column - 1 * rowBytes + 1. |
|
730 |
stop := column * rowBytes. |
|
731 |
replacement := self readBitRowData. |
|
732 |
bitData |
|
733 |
replaceBytesFrom: start |
|
734 |
to: stop |
|
735 |
with: replacement |
|
736 |
startingAt: 1. |
|
737 |
self progress: column / bounds height]. |
|
738 |
^bitData |
|
739 |
! |
|
740 |
||
741 |
readBitMap: isMaskRgn |
|
742 |
| bitData anImage pad anArray maskRgn | |
|
743 |
rowBytes := self nextWord. |
|
744 |
bounds := self readRect. |
|
745 |
srcRect := self readRect. |
|
746 |
dstRect := self readRect. |
|
747 |
mode := self nextWord. |
|
748 |
bitData := self readBitData. |
|
749 |
isMaskRgn = true ifTrue: [maskRgn := self readRegion]. |
|
750 |
pad := rowBytes * 8 - bounds width. |
|
751 |
pad >= 8 |
|
752 |
ifTrue: [pad >= 16 |
|
753 |
ifTrue: [pad := 32] |
|
754 |
ifFalse: [pad := 16]] |
|
755 |
ifFalse: [pad := 8]. |
|
756 |
||
757 |
anImage := Image |
|
758 |
extent: bounds width @ bounds height |
|
759 |
depth: 1 |
|
760 |
palette: MappedPalette monochromeDefault |
|
761 |
bits: bitData |
|
762 |
pad: pad. |
|
763 |
||
764 |
" self debug: [anImage displayOn: ScheduledControllers activeController view graphicsContext]. " |
|
1849 | 765 |
"/ OLD |
766 |
"/ anArray := Array |
|
767 |
"/ with: anImage |
|
768 |
"/ with: srcRect |
|
769 |
"/ with: dstRect |
|
770 |
"/ with: mode. |
|
771 |
"/ isMaskRgn = true ifTrue: [anArray := anArray , (Array with: maskRgn)]. |
|
772 |
"/ NEW: |
|
773 |
anArray := PICTFrame new |
|
774 |
image:anImage |
|
775 |
sourceRectangle:srcRect |
|
776 |
destinationRectangle:dstRect |
|
777 |
mode:mode. |
|
778 |
isMaskRgn = true ifTrue: [ |
|
779 |
anArray maskRegion:maskRgn |
|
780 |
]. |
|
1806 | 781 |
^anArray |
782 |
! |
|
783 |
||
784 |
readBitRowData |
|
785 |
| rawData byteCount | |
|
786 |
rowBytes < 8 |
|
787 |
ifTrue: [rawData := self next: rowBytes] |
|
788 |
ifFalse: |
|
789 |
[rowBytes > 250 |
|
790 |
ifTrue: [byteCount := self nextWord] |
|
791 |
ifFalse: [byteCount := self next]. |
|
792 |
rawData := self unPackBits: (self next: byteCount)]. |
|
793 |
^rawData |
|
794 |
! |
|
795 |
||
796 |
readColorTable |
|
797 |
ctSeed := self nextLong. |
|
798 |
ctFlags := self nextWord. |
|
799 |
ctSize := self nextWord. |
|
800 |
ctTable := Array new: ctSize + 1. |
|
801 |
1 to: ctTable size |
|
802 |
do: |
|
803 |
[:i | |
|
804 |
| value rgb | |
|
805 |
value := self nextWord. |
|
806 |
value yourself. |
|
807 |
rgb := self nextWord bitShift: 32. |
|
808 |
rgb := rgb + (self nextWord bitShift: 16). |
|
809 |
rgb := rgb + self nextWord. |
|
810 |
ctTable at: i put: rgb] |
|
811 |
! |
|
812 |
||
813 |
readDataLength2 |
|
814 |
| length bytes | |
|
815 |
length := self nextWord. |
|
816 |
bytes := self next: length. |
|
817 |
" self debug: [Transcript space; show: bytes printString]. " |
|
818 |
^Array with: length with: bytes |
|
819 |
! |
|
820 |
||
821 |
readDataLength4 |
|
822 |
| length bytes | |
|
823 |
length := self nextLong. |
|
824 |
bytes := self next: length. |
|
825 |
" self debug: [Transcript space; show: bytes printString]. " |
|
826 |
^Array with: length with: bytes |
|
827 |
! |
|
828 |
||
829 |
readDirectPixData |
|
830 |
packType = 0 ifTrue: [^self errorSorryNotSupported]. |
|
831 |
packType = 1 ifTrue: [^self errorSorryNotSupported]. |
|
832 |
packType = 2 ifTrue: [^self errorSorryNotSupported]. |
|
833 |
packType = 3 ifTrue: [^self errorSorryNotSupported]. |
|
834 |
packType = 4 ifTrue: [^self readDirectPixData4]. |
|
835 |
^self errorUnexpectedPakingType |
|
836 |
! |
|
837 |
||
838 |
readDirectPixData4 |
|
839 |
| palette image row scalingValue color index r g b | |
|
1849 | 840 |
"/ palette := FixedPalette |
841 |
"/ redShift: 16 |
|
842 |
"/ redMask: 255 |
|
843 |
"/ greenShift: 8 |
|
844 |
"/ greenMask: 255 |
|
845 |
"/ blueShift: 0 |
|
846 |
"/ blueMask: 255. |
|
1806 | 847 |
image := Image |
848 |
extent: bounds width @ bounds height |
|
849 |
depth: 24 |
|
850 |
palette: palette. |
|
851 |
self progress: 0. |
|
852 |
0 to: bounds height - 1 |
|
853 |
do: |
|
854 |
[:y | |
|
855 |
| x | |
|
856 |
x := 0. |
|
857 |
row := self readDirectPixRowData. |
|
858 |
r := row size // 3 * 0 + 1. |
|
859 |
g := row size // 3 * 1 + 1. |
|
860 |
b := row size // 3 * 2 + 1. |
|
861 |
row size // 3 |
|
862 |
timesRepeat: |
|
1849 | 863 |
[ |
864 |
"/ ST/X |
|
865 |
image pixelAtX:x y:y put:( ((((row at: r) bitShift:8) |
|
866 |
bitOr:(row at: g)) bitShift:8) |
|
867 |
bitOr:(row at: b)). |
|
868 |
||
869 |
"/ VW |
|
870 |
"/ scalingValue := ColorValue scalingValue. |
|
871 |
"/ color := ColorValue |
|
872 |
"/ scaledRed: (self |
|
873 |
"/ convertValue: ((row at: r) |
|
874 |
"/ bitAnd: 255) |
|
875 |
"/ from: 255 |
|
876 |
"/ to: scalingValue) |
|
877 |
"/ scaledGreen: (self |
|
878 |
"/ convertValue: ((row at: g) |
|
879 |
"/ bitAnd: 255) |
|
880 |
"/ from: 255 |
|
881 |
"/ to: scalingValue) |
|
882 |
"/ scaledBlue: (self |
|
883 |
"/ convertValue: (row at: b) |
|
884 |
"/ from: 255 |
|
885 |
"/ to: scalingValue). |
|
886 |
"/ index := palette indexOfPaintNearest: color. |
|
887 |
"/ image |
|
888 |
"/ atX: x |
|
889 |
"/ y: y |
|
890 |
"/ put: index. |
|
1806 | 891 |
r := r + 1. |
892 |
g := g + 1. |
|
893 |
b := b + 1. |
|
894 |
x := x + 1]. |
|
895 |
self progress: y / (bounds height - 1)]. |
|
896 |
^image |
|
897 |
! |
|
898 |
||
899 |
readDirectPixMap: isMaskRgn |
|
900 |
| anImage maskRgn anArray | |
|
901 |
||
902 |
baseAddr := self nextLong. |
|
1807 | 903 |
rowBytes := self nextWord bitAnd: 16r3FFF. |
1806 | 904 |
bounds := self readRect. |
905 |
pmVersion := self nextWord. |
|
906 |
packType := self nextWord. |
|
907 |
packSize := self nextLong. |
|
908 |
hRes := self nextLong. |
|
909 |
vRes := self nextLong. |
|
910 |
pixelType := self nextWord. |
|
911 |
pixelSize := self nextWord. |
|
912 |
cmpCount := self nextWord. |
|
913 |
cmpSize := self nextWord. |
|
914 |
planeBytes := self nextLong. |
|
915 |
pmTable := self nextLong. |
|
916 |
pmReserved := self nextLong. |
|
917 |
srcRect := self readRect. |
|
918 |
dstRect := self readRect. |
|
919 |
mode := self nextWord. |
|
920 |
isMaskRgn = true ifTrue: [maskRgn := self readRegion]. |
|
921 |
anImage := self readDirectPixData. |
|
922 |
" self debug: [anImage displayOn: ScheduledControllers activeController view graphicsContext]. " |
|
1849 | 923 |
"/ OLD: |
924 |
"/ anArray := Array |
|
925 |
"/ with: anImage |
|
926 |
"/ with: srcRect |
|
927 |
"/ with: dstRect |
|
928 |
"/ with: mode. |
|
929 |
"/ isMaskRgn = true ifTrue: [ |
|
930 |
"/ anArray := anArray , (Array with: maskRgn) |
|
931 |
"/ ]. |
|
932 |
||
933 |
"/ NEW: |
|
934 |
anArray := PICTFrame new |
|
935 |
image:anImage |
|
936 |
sourceRectangle:srcRect |
|
937 |
destinationRectangle:dstRect |
|
938 |
mode:mode. |
|
939 |
isMaskRgn = true ifTrue: [ |
|
940 |
anArray maskRegion:maskRgn |
|
941 |
]. |
|
1806 | 942 |
^anArray |
943 |
! |
|
944 |
||
945 |
readDirectPixRowData |
|
946 |
| rawData byteCount | |
|
947 |
(packType = 1 or: [rowBytes < 8]) |
|
948 |
ifTrue: [rawData := self next: rowBytes] |
|
949 |
ifFalse: [packType = 2 |
|
950 |
ifTrue: [rawData := self next: (rowBytes * (3 / 4)) asInteger] |
|
951 |
ifFalse: [packType > 2 |
|
952 |
ifTrue: |
|
953 |
[rowBytes > 250 |
|
954 |
ifTrue: [byteCount := self nextWord] |
|
955 |
ifFalse: [byteCount := self next]. |
|
956 |
rawData := self unPackBits: (self next: byteCount)]]]. |
|
957 |
^rawData |
|
958 |
! |
|
959 |
||
960 |
readHeader |
|
961 |
| position byte | |
|
962 |
picSize := self nextWord. |
|
963 |
picFrame := self readRect. |
|
964 |
position := self position. |
|
965 |
byte := self next. |
|
1807 | 966 |
byte = 16r11 |
1806 | 967 |
ifTrue: [picVersion := self next] |
968 |
ifFalse: |
|
969 |
[byte := self next. |
|
1807 | 970 |
byte = 16r11 |
1806 | 971 |
ifTrue: |
972 |
[picVersion := self next. |
|
973 |
self next] |
|
974 |
ifFalse: [^self errorCanNotRead]]. |
|
975 |
self position: position |
|
976 |
! |
|
977 |
||
978 |
readPixData |
|
979 |
| pixData | |
|
980 |
pixData := ByteArray new: rowBytes * bounds height. |
|
981 |
self progress: 0. |
|
982 |
1 to: bounds height |
|
983 |
do: |
|
984 |
[:column | |
|
985 |
| start stop replacement | |
|
986 |
start := column - 1 * rowBytes + 1. |
|
987 |
stop := column * rowBytes. |
|
988 |
replacement := self readPixRowData. |
|
989 |
pixData |
|
990 |
replaceBytesFrom: start |
|
991 |
to: stop |
|
992 |
with: replacement |
|
993 |
startingAt: 1. |
|
994 |
self progress: column / bounds height]. |
|
995 |
^pixData |
|
996 |
! |
|
997 |
||
998 |
readPixMap: isMaskRgn |
|
999 |
| pixData aPalette anImage pad maskRgn anArray | |
|
1807 | 1000 |
rowBytes := self nextWord bitAnd: 16r3FFF. |
1806 | 1001 |
bounds := self readRect. |
1002 |
pmVersion := self nextWord. |
|
1003 |
packType := self nextWord. |
|
1004 |
packSize := self nextLong. |
|
1005 |
hRes := self nextLong. |
|
1006 |
vRes := self nextLong. |
|
1007 |
pixelType := self nextWord. |
|
1008 |
pixelSize := self nextWord. |
|
1009 |
cmpCount := self nextWord. |
|
1010 |
cmpSize := self nextWord. |
|
1011 |
planeBytes := self nextLong. |
|
1012 |
pmTable := self nextLong. |
|
1013 |
pmReserved := self nextLong. |
|
1014 |
self readColorTable. |
|
1015 |
srcRect := self readRect. |
|
1016 |
dstRect := self readRect. |
|
1017 |
mode := self nextWord. |
|
1018 |
isMaskRgn = true ifTrue: [maskRgn := self readRegion]. |
|
1019 |
pixData := self readPixData. |
|
1020 |
aPalette := MappedPalette withColors: (ctTable collect: [:rgb | self colorValueFrom: rgb]). |
|
1021 |
pad := rowBytes * 8 - (bounds width * pixelSize). |
|
1022 |
pad >= 8 |
|
1023 |
ifTrue: [pad >= 16 |
|
1024 |
ifTrue: [pad := 32] |
|
1025 |
ifFalse: [pad := 16]] |
|
1026 |
ifFalse: [pad := 8]. |
|
1027 |
anImage := Image |
|
1028 |
extent: bounds width @ bounds height |
|
1029 |
depth: pixelSize |
|
1030 |
palette: aPalette |
|
1031 |
bits: pixData |
|
1032 |
pad: pad. |
|
1033 |
" self debug: [anImage displayOn: ScheduledControllers activeController view graphicsContext]. " |
|
1849 | 1034 |
"/ OLD: |
1035 |
"/ anArray := Array |
|
1036 |
"/ with: anImage |
|
1037 |
"/ with: srcRect |
|
1038 |
"/ with: dstRect |
|
1039 |
"/ with: mode. |
|
1040 |
"/ isMaskRgn = true ifTrue: [anArray := anArray , (Array with: maskRgn)]. |
|
1041 |
"/ NEW: |
|
1042 |
anArray := PICTFrame new |
|
1043 |
image:anImage |
|
1044 |
sourceRectangle:srcRect |
|
1045 |
destinationRectangle:dstRect |
|
1046 |
mode:mode. |
|
1047 |
isMaskRgn = true ifTrue: [ |
|
1048 |
anArray maskRegion:maskRgn |
|
1049 |
]. |
|
1806 | 1050 |
^anArray |
1051 |
! |
|
1052 |
||
1053 |
readPixRowData |
|
1054 |
packType = 0 ifTrue: [^self readBitRowData]. |
|
1055 |
packType = 1 ifTrue: [^self readBitRowData]. |
|
1056 |
^self errorCanNotRead |
|
1057 |
! |
|
1058 |
||
1059 |
readPoint |
|
1060 |
| x y point | |
|
1061 |
x := self nextWord. |
|
1062 |
y := self nextWord. |
|
1063 |
point := x @ y. |
|
1064 |
^point |
|
1065 |
! |
|
1066 |
||
1067 |
readPolygon |
|
1068 |
| length bytes | |
|
1069 |
length := self nextWord. |
|
1070 |
bytes := self next: length - 2. |
|
1807 | 1071 |
" self |
1806 | 1072 |
debug: |
1073 |
[Transcript space; show: length printString. |
|
1807 | 1074 |
Transcript space; show: bytes printString]. " |
1806 | 1075 |
^Array with: length with: bytes |
1076 |
! |
|
1077 |
||
1078 |
readRect |
|
1079 |
| top left bottom right rect | |
|
1080 |
top := self nextWord. |
|
1081 |
left := self nextWord. |
|
1082 |
bottom := self nextWord. |
|
1083 |
right := self nextWord. |
|
1084 |
rect := left @ top corner: right @ bottom. |
|
1085 |
^rect |
|
1086 |
! |
|
1087 |
||
1088 |
readRegion |
|
1089 |
| length bytes | |
|
1090 |
length := self nextWord. |
|
1091 |
bytes := self next: length - 2. |
|
1807 | 1092 |
" self debug: |
1093 |
[Transcript space; show: length printString. |
|
1094 |
Transcript space; show: bytes printString]. " |
|
1806 | 1095 |
^Array with: length with: bytes |
1096 |
! ! |
|
1097 |
||
1098 |
!PICTReader methodsFor:'encoding'! |
|
1099 |
||
1100 |
bitData: bitData |
|
1101 |
| imageRowBytes packStream | |
|
1102 |
imageRowBytes := bounds width * pixelSize + 31 // 32 * 4. |
|
1103 |
packStream := WriteStream on: (ByteArray new: bitData size). |
|
1104 |
self progress: 0. |
|
1105 |
1 to: bounds height |
|
1106 |
do: |
|
1107 |
[:h | |
|
1108 |
| rowBits packedBits | |
|
1109 |
rowBits := bitData copyFrom: h - 1 * imageRowBytes + 1 to: h - 1 * imageRowBytes + rowBytes. |
|
1110 |
rowBytes < 8 |
|
1111 |
ifTrue: [packStream nextPutAll: rowBits] |
|
1112 |
ifFalse: |
|
1113 |
[packedBits := self packBits: rowBits. |
|
1114 |
rowBytes > 250 |
|
1115 |
ifTrue: |
|
1116 |
[packStream nextPut: ((packedBits size bitShift: -8) |
|
1117 |
bitAnd: 255). |
|
1118 |
packStream nextPut: (packedBits size bitAnd: 255)] |
|
1119 |
ifFalse: [packStream nextPut: packedBits size]. |
|
1120 |
packStream nextPutAll: packedBits]. |
|
1121 |
self progress: h / bounds height]. |
|
1122 |
^packStream contents |
|
1123 |
! |
|
1124 |
||
1125 |
directPixData4: anImage |
|
1126 |
| packStream palette r g b index color scalingValue stream | |
|
1127 |
packStream := WriteStream on: (ByteArray new: anImage bits size). |
|
1128 |
palette := anImage palette. |
|
1129 |
self progress: 0. |
|
1130 |
0 to: bounds height - 1 |
|
1131 |
do: |
|
1132 |
[:y | |
|
1133 |
r := WriteStream on: ByteArray new. |
|
1134 |
g := WriteStream on: ByteArray new. |
|
1135 |
b := WriteStream on: ByteArray new. |
|
1136 |
0 to: bounds width - 1 |
|
1137 |
do: |
|
1138 |
[:x | |
|
1139 |
index := anImage atX: x y: y. |
|
1140 |
(palette includesKey: index) |
|
1141 |
ifTrue: [color := palette at: index] |
|
1142 |
ifFalse: [color := palette at: (index bitAnd: palette maxIndex)]. |
|
1143 |
scalingValue := ColorValue scalingValue. |
|
1144 |
r nextPut: (self |
|
1145 |
convertValue: color scaledRed |
|
1146 |
from: scalingValue |
|
1147 |
to: 255). |
|
1148 |
g nextPut: (self |
|
1149 |
convertValue: color scaledGreen |
|
1150 |
from: scalingValue |
|
1151 |
to: 255). |
|
1152 |
b nextPut: (self |
|
1153 |
convertValue: color scaledBlue |
|
1154 |
from: scalingValue |
|
1155 |
to: 255)]. |
|
1156 |
stream := WriteStream on: ByteArray new. |
|
1157 |
stream nextPutAll: r contents. |
|
1158 |
stream nextPutAll: g contents. |
|
1159 |
stream nextPutAll: b contents. |
|
1160 |
packStream nextPutAll: (self directPixRowData: stream contents). |
|
1161 |
self progress: y / (bounds height - 1)]. |
|
1162 |
^packStream contents |
|
1163 |
! |
|
1164 |
||
1165 |
directPixRowData: row |
|
1166 |
| aStream rawData byteCount | |
|
1167 |
aStream := WriteStream on: (ByteArray new: row size). |
|
1168 |
rawData := self packBits: row. |
|
1169 |
byteCount := rawData size. |
|
1170 |
rowBytes > 250 |
|
1171 |
ifTrue: |
|
1172 |
[aStream nextPut: ((byteCount bitShift: -8) |
|
1173 |
bitAnd: 255). |
|
1174 |
aStream nextPut: (byteCount bitAnd: 255)] |
|
1175 |
ifFalse: [aStream nextPut: byteCount]. |
|
1176 |
aStream nextPutAll: rawData. |
|
1177 |
^aStream contents |
|
1178 |
! |
|
1179 |
||
1180 |
nextPutImage24: image |
|
1181 |
| anImage endOpcode | |
|
1182 |
Cursor wait showWhile: [anImage := image "convertToPalette: (FixedPalette |
|
1183 |
redShift: 16 |
|
1184 |
redMask: 255 |
|
1185 |
greenShift: 8 |
|
1186 |
greenMask: 255 |
|
1187 |
blueShift: 0 |
|
1188 |
blueMask: 255) |
|
1189 |
renderedBy: ErrorDiffusion new"]. |
|
1807 | 1190 |
baseAddr := 16r000000FF. |
1806 | 1191 |
rowBytes := anImage width * 32 + 7 // 8. |
1192 |
bounds := anImage bounds. |
|
1193 |
pmVersion := 0. |
|
1194 |
packType := 4. |
|
1195 |
packSize := 0. |
|
1807 | 1196 |
hRes := 16r00480000. |
1197 |
vRes := 16r00480000. |
|
1806 | 1198 |
pixelType := 16. |
1199 |
pixelSize := 32. |
|
1200 |
cmpCount := 3. |
|
1201 |
cmpSize := 8. |
|
1202 |
planeBytes := 0. |
|
1203 |
pmTable := 0. |
|
1204 |
pmReserved := 0. |
|
1205 |
srcRect := anImage bounds. |
|
1206 |
dstRect := anImage bounds. |
|
1207 |
mode := 64. |
|
1807 | 1208 |
endOpcode := 16r00FF. |
1806 | 1209 |
self writeImage24: anImage. |
1210 |
self writeOpcode: endOpcode. |
|
1211 |
^anImage |
|
1212 |
! |
|
1213 |
||
1214 |
sortPalette: image |
|
1215 |
| max array color | |
|
1216 |
max := 1 bitShift: pixelSize. |
|
1217 |
array := Array new: image palette maxIndex + 1. |
|
1218 |
1 to: array size |
|
1219 |
do: |
|
1220 |
[:i | |
|
1221 |
color := image palette at: i - 1 ifAbsent: [ColorValue white]. |
|
1222 |
array at: i put: (self rgbIntegerFrom: color)]. |
|
1223 |
array size > max |
|
1224 |
ifTrue: [array := array copyFrom: 1 to: max] |
|
1225 |
ifFalse: [array size < max ifTrue: [array := array , (Array new: max - array size withAll: 0)]]. |
|
1226 |
array := array asSortedCollection reverse collect: [:rgb | self colorValueFrom: rgb]. |
|
1227 |
^image convertToPalette: (MappedPalette withColors: array) |
|
1228 |
! |
|
1229 |
||
1230 |
writeBits24: bits |
|
1231 |
| currentOpecode | |
|
1807 | 1232 |
currentOpecode := 16r009A. |
1806 | 1233 |
self writeOpcode: currentOpecode. |
1234 |
self nextLongPut: baseAddr. |
|
1235 |
self nextWordPut: rowBytes + (1 bitShift: 15). |
|
1236 |
self writeRect: bounds. |
|
1237 |
self nextWordPut: pmVersion. |
|
1238 |
self nextWordPut: packType. |
|
1239 |
self nextLongPut: packSize. |
|
1240 |
self nextLongPut: hRes. |
|
1241 |
self nextLongPut: vRes. |
|
1242 |
self nextWordPut: pixelType. |
|
1243 |
self nextWordPut: pixelSize. |
|
1244 |
self nextWordPut: cmpCount. |
|
1245 |
self nextWordPut: cmpSize. |
|
1246 |
self nextLongPut: planeBytes. |
|
1247 |
self nextLongPut: pmTable. |
|
1248 |
self nextLongPut: pmReserved. |
|
1249 |
self writeRect: srcRect. |
|
1250 |
self writeRect: dstRect. |
|
1251 |
self nextWordPut: mode. |
|
1252 |
self nextPutAll: bits |
|
1253 |
! |
|
1254 |
||
1255 |
writeBits: bits palette: palette |
|
1256 |
rowBytes < 8 |
|
1807 | 1257 |
ifTrue: [currentOpcode := 16r90] |
1258 |
ifFalse: [currentOpcode := 16r0098]. |
|
1806 | 1259 |
picVersion = 1 |
1260 |
ifTrue: |
|
1261 |
[self writeOpcode: currentOpcode. |
|
1262 |
self nextWordPut: rowBytes. |
|
1263 |
self writeRect: bounds. |
|
1264 |
self writeRect: srcRect. |
|
1265 |
self writeRect: dstRect. |
|
1266 |
self nextWordPut: mode. |
|
1267 |
self nextPutAll: bits] |
|
1268 |
ifFalse: |
|
1269 |
[self writeOpcode: currentOpcode. |
|
1270 |
self nextWordPut: rowBytes + (1 bitShift: 15). |
|
1271 |
self writeRect: bounds. |
|
1272 |
self nextWordPut: pmVersion. |
|
1273 |
self nextWordPut: packType. |
|
1274 |
self nextLongPut: packSize. |
|
1275 |
self nextLongPut: hRes. |
|
1276 |
self nextLongPut: vRes. |
|
1277 |
self nextWordPut: pixelType. |
|
1278 |
self nextWordPut: pixelSize. |
|
1279 |
self nextWordPut: cmpCount. |
|
1280 |
self nextWordPut: cmpSize. |
|
1281 |
self nextLongPut: planeBytes. |
|
1282 |
self nextLongPut: pmTable. |
|
1283 |
self nextLongPut: pmReserved. |
|
1284 |
self nextLongPut: ctSeed. |
|
1285 |
self nextWordPut: ctFlags. |
|
1286 |
self nextWordPut: ctSize. |
|
1287 |
ctTable := Array new: palette maxIndex + 1. |
|
1288 |
1 to: ctTable size |
|
1289 |
do: |
|
1290 |
[:i | |
|
1291 |
| color value rgb | |
|
1292 |
color := palette at: i - 1 ifAbsent: [ColorValue white]. |
|
1293 |
value := 0. |
|
1294 |
rgb := self rgbIntegerFrom: color. |
|
1295 |
ctTable at: i put: rgb. |
|
1296 |
self nextWordPut: value. |
|
1297 |
self nextWordPut: ((rgb bitShift: -32) |
|
1298 |
bitAnd: 65535). |
|
1299 |
self nextWordPut: ((rgb bitShift: -16) |
|
1300 |
bitAnd: 65535). |
|
1301 |
self nextWordPut: (rgb bitAnd: 65535)]. |
|
1302 |
self writeRect: srcRect. |
|
1303 |
self writeRect: dstRect. |
|
1304 |
self nextWordPut: mode. |
|
1305 |
self nextPutAll: bits] |
|
1306 |
! |
|
1307 |
||
1308 |
writeClip: aRectangle |
|
1309 |
picVersion = 1 |
|
1807 | 1310 |
ifTrue: [self writeOpcode: 16r01] |
1311 |
ifFalse: [self writeOpcode: 16r0001]. |
|
1806 | 1312 |
self nextWordPut: 10. |
1313 |
self writeRect: aRectangle |
|
1314 |
! |
|
1315 |
||
1316 |
writeHeader24: bits |
|
1317 |
| pictCodeSize | |
|
1318 |
pictCodeSize := 2. |
|
1319 |
picSize := 40. |
|
1320 |
picSize := picSize + pictCodeSize. |
|
1321 |
picSize := picSize + pictCodeSize + 10. |
|
1322 |
picSize := picSize + pictCodeSize + 68 + bits size. |
|
1323 |
bits size odd ifTrue: [picSize := picSize + 1]. |
|
1324 |
picSize := picSize + pictCodeSize. |
|
1325 |
self nextWordPut: picSize \\ 65535. |
|
1326 |
self writeRect: picFrame. |
|
1327 |
self nextWordPut: 17. |
|
1328 |
self nextWordPut: 767. |
|
1329 |
self nextWordPut: 3072. |
|
1330 |
1 to: 2 do: [:i | self nextWordPut: 65535]. |
|
1331 |
1 to: 4 do: [:i | self nextWordPut: 0]. |
|
1332 |
self nextWordPut: picFrame width. |
|
1333 |
1 to: 1 do: [:i | self nextWordPut: 0]. |
|
1334 |
self nextWordPut: picFrame height. |
|
1335 |
1 to: 3 do: [:i | self nextWordPut: 0] |
|
1336 |
! |
|
1337 |
||
1338 |
writeHeader: bits palette: palette |
|
1339 |
| pictCodeSize | |
|
1340 |
picVersion = 1 |
|
1341 |
ifTrue: |
|
1342 |
[pictCodeSize := 1. |
|
1343 |
picSize := 12. |
|
1344 |
picSize := picSize + pictCodeSize + 10. |
|
1345 |
picSize := picSize + pictCodeSize + 10 + 8 + 8 + 2 + bits size. |
|
1346 |
picSize := picSize + pictCodeSize] |
|
1347 |
ifFalse: |
|
1348 |
[pictCodeSize := 2. |
|
1349 |
picSize := 40. |
|
1350 |
picSize := picSize + pictCodeSize. |
|
1351 |
picSize := picSize + pictCodeSize + 10. |
|
1352 |
picSize := picSize + pictCodeSize + 46 + 8 + (palette maxIndex + 1 * 8) + 8 + 8 + 2 + bits size. |
|
1353 |
bits size odd ifTrue: [picSize := picSize + 1]. |
|
1354 |
picSize := picSize + pictCodeSize]. |
|
1355 |
self nextWordPut: picSize \\ 65535. |
|
1356 |
self writeRect: picFrame. |
|
1357 |
picVersion = 1 |
|
1358 |
ifTrue: |
|
1359 |
[self nextPut: 17. |
|
1360 |
self nextPut: 1] |
|
1361 |
ifFalse: |
|
1362 |
[self nextWordPut: 17. |
|
1363 |
self nextWordPut: 767. |
|
1364 |
self nextWordPut: 3072. |
|
1365 |
1 to: 2 do: [:i | self nextWordPut: 65535]. |
|
1366 |
1 to: 4 do: [:i | self nextWordPut: 0]. |
|
1367 |
self nextWordPut: picFrame width. |
|
1368 |
1 to: 1 do: [:i | self nextWordPut: 0]. |
|
1369 |
self nextWordPut: picFrame height. |
|
1370 |
1 to: 3 do: [:i | self nextWordPut: 0]] |
|
1371 |
! |
|
1372 |
||
1373 |
writeImage24: anImage |
|
1374 |
| bits | |
|
1375 |
bits := self directPixData4: anImage. |
|
1376 |
self writeHeader24: ByteArray new. |
|
1377 |
self writeClip: bounds. |
|
1378 |
self writeBits24: bits. |
|
1379 |
^anImage |
|
1380 |
! |
|
1381 |
||
1382 |
writeImage: anImage |
|
1383 |
| image bits | |
|
1384 |
image := self sortPalette: anImage. |
|
1385 |
bits := self bitData: image bits. |
|
1386 |
self writeHeader: bits palette: image palette. |
|
1387 |
self writeClip: bounds. |
|
1388 |
self writeBits: bits palette: image palette. |
|
1389 |
^anImage |
|
1390 |
! |
|
1391 |
||
1392 |
writeOpcode: opcode |
|
1393 |
picVersion = 1 |
|
1394 |
ifTrue: [self nextPut: opcode] |
|
1395 |
ifFalse: |
|
1396 |
[self position odd ifTrue: [self nextPut: 0]. |
|
1397 |
self nextWordPut: opcode] |
|
1398 |
! |
|
1399 |
||
1400 |
writeRect: aRectangle |
|
1401 |
self nextWordPut: aRectangle top. |
|
1402 |
self nextWordPut: aRectangle left. |
|
1403 |
self nextWordPut: aRectangle bottom. |
|
1404 |
self nextWordPut: aRectangle right |
|
1405 |
! ! |
|
1406 |
||
1407 |
!PICTReader methodsFor:'interpreting'! |
|
1408 |
||
1409 |
fixedOpcode: opcodeName additionalData: additionalData |
|
1807 | 1410 |
| bytes | |
1411 |
||
1412 |
" self debug: [Transcript space; show: opcodeName]. " |
|
1413 |
bytes := self next: additionalData. |
|
1414 |
" self debug: [Transcript space; show: bytes printString] " |
|
1806 | 1415 |
! |
1416 |
||
1417 |
interpretOpcode: association |
|
1418 |
| opcodeName additionalData | |
|
1419 |
opcodeName := association key. |
|
1420 |
additionalData := association value. |
|
1807 | 1421 |
|
1422 |
self debug:[ Transcript show: 'op:'; show:opcodeName; show:' ['; show:additionalData; show:']'; cr ]. |
|
1423 |
||
1806 | 1424 |
additionalData isString |
1425 |
ifTrue: [self variableOpcode: opcodeName additionalData: additionalData] |
|
1426 |
ifFalse: [self fixedOpcode: opcodeName additionalData: additionalData] |
|
1427 |
! |
|
1428 |
||
1429 |
nextOpcode |
|
1430 |
| association | |
|
1807 | 1431 |
" self debug: [Transcript cr. |
1432 |
Transcript show: (self hexString4: self position). |
|
1433 |
Transcript show: ':']. " |
|
1806 | 1434 |
picVersion = 1 |
1435 |
ifTrue: [currentOpcode := self next] |
|
1436 |
ifFalse: |
|
1437 |
[self position odd ifTrue: [self next]. |
|
1438 |
currentOpcode := self nextWord]. |
|
1439 |
association := self class opcodeAt: currentOpcode. |
|
1440 |
association isNil ifTrue: [^self errorUnexpectedOpcode]. |
|
1441 |
self interpretOpcode: association. |
|
1442 |
^association |
|
1443 |
! |
|
1444 |
||
1445 |
variableOpcode: opcodeName additionalData: additionalData |
|
1446 |
| aSymbol | |
|
1807 | 1447 |
|
1448 |
" self debug: [Transcript space; show: opcodeName]. " |
|
1806 | 1449 |
additionalData = 'Polygon size' ifTrue: [^self readPolygon]. |
1450 |
additionalData = 'Region size' ifTrue: [^self readRegion]. |
|
1451 |
additionalData = '2 + data length' ifTrue: [^self readDataLength2]. |
|
1452 |
additionalData = '4 + data length' ifTrue: [^self readDataLength4]. |
|
1807 | 1453 |
|
1806 | 1454 |
(opcodeName copyFrom: 1 to: ('Apple' size min: opcodeName size)) |
1455 |
= 'Apple' ifTrue: [^self errorUnexpectedOpcode]. |
|
1456 |
aSymbol := ((String with: $x with: opcodeName first asUppercase) |
|
1457 |
, (opcodeName copyFrom: 2 to: opcodeName size)) asSymbol. |
|
1458 |
(self respondsTo: aSymbol) |
|
1459 |
ifTrue: [^self perform: aSymbol]. |
|
1460 |
^self errorUnexpectedOpcode |
|
1461 |
! ! |
|
1462 |
||
1463 |
!PICTReader methodsFor:'printing'! |
|
1464 |
||
1465 |
hexString2: aNumber |
|
1466 |
| aString aStream | |
|
1467 |
aString := aNumber printStringRadix: 16. |
|
1468 |
aStream := WriteStream on: (String new: 12). |
|
1469 |
aStream nextPutAll: '16r'. |
|
1470 |
2 - aString size timesRepeat: [aStream nextPutAll: '0']. |
|
1471 |
aStream nextPutAll: aString. |
|
1472 |
^aStream contents |
|
1473 |
! |
|
1474 |
||
1475 |
hexString4: aNumber |
|
1476 |
| aString aStream | |
|
1477 |
aString := aNumber printStringRadix: 16. |
|
1478 |
aStream := WriteStream on: (String new: 12). |
|
1479 |
aStream nextPutAll: '16r'. |
|
1480 |
4 - aString size timesRepeat: [aStream nextPutAll: '0']. |
|
1481 |
aStream nextPutAll: aString. |
|
1482 |
^aStream contents |
|
1483 |
! |
|
1484 |
||
1485 |
hexString8: aNumber |
|
1486 |
| aString aStream | |
|
1487 |
aString := aNumber printStringRadix: 16. |
|
1488 |
aStream := WriteStream on: (String new: 12). |
|
1489 |
aStream nextPutAll: '16r'. |
|
1490 |
8 - aString size timesRepeat: [aStream nextPutAll: '0']. |
|
1491 |
aStream nextPutAll: aString. |
|
1492 |
^aStream contents |
|
1493 |
! ! |
|
1494 |
||
1495 |
!PICTReader methodsFor:'private'! |
|
1496 |
||
1497 |
colorValueFrom: rgbInteger |
|
1498 |
| scalingValue | |
|
1849 | 1499 |
|
1500 |
^ Color |
|
1501 |
redShort:((rgbInteger bitShift: -32) bitAnd: 65535) |
|
1502 |
greenShort:((rgbInteger bitShift: -16) bitAnd: 65535) |
|
1503 |
blueShort:(rgbInteger bitAnd: 65535) |
|
1504 |
||
1505 |
"/ scalingValue := ColorValue scalingValue. |
|
1506 |
"/ ^ColorValue |
|
1507 |
"/ scaledRed: (self |
|
1508 |
"/ convertValue: ((rgbInteger bitShift: -32) |
|
1509 |
"/ bitAnd: 65535) |
|
1510 |
"/ from: 65535 |
|
1511 |
"/ to: scalingValue) |
|
1512 |
"/ scaledGreen: (self |
|
1513 |
"/ convertValue: ((rgbInteger bitShift: -16) |
|
1514 |
"/ bitAnd: 65535) |
|
1515 |
"/ from: 65535 |
|
1516 |
"/ to: scalingValue) |
|
1517 |
"/ scaledBlue: (self |
|
1518 |
"/ convertValue: (rgbInteger bitAnd: 65535) |
|
1519 |
"/ from: 65535 |
|
1520 |
"/ to: scalingValue) |
|
1806 | 1521 |
! |
1522 |
||
1523 |
errorSorryNotSupported |
|
1524 |
self error: 'sorry, not supported'. |
|
1525 |
^nil |
|
1526 |
! |
|
1527 |
||
1528 |
errorUnexpectedOpcode |
|
1529 |
| string | |
|
1530 |
picVersion = 1 |
|
1531 |
ifTrue: [string := self hexString2: currentOpcode] |
|
1532 |
ifFalse: [string := self hexString4: currentOpcode]. |
|
1533 |
string := (self hexString8: self position) |
|
1534 |
, ': ' , string. |
|
1535 |
self error: 'unexpected opcode: ' , string. |
|
1536 |
^nil |
|
1537 |
! |
|
1538 |
||
1539 |
errorUnexpectedPakingType |
|
1540 |
self error: 'unexpected packing type: ' , packType printString. |
|
1541 |
^nil |
|
1542 |
! |
|
1543 |
||
1544 |
mergeImages |
|
1545 |
| aRectangle aDepth aPalette anImage aPattern indexValue | |
|
1546 |
aRectangle := nil. |
|
1547 |
aDepth := nil. |
|
1548 |
aPalette := nil. |
|
1549 |
imageSequence |
|
1550 |
do: |
|
1551 |
[:array | |
|
1552 |
aRectangle isNil |
|
1553 |
ifTrue: [aRectangle := array at: 3] |
|
1554 |
ifFalse: [aRectangle := aRectangle merge: (array at: 3)]. |
|
1555 |
aDepth isNil |
|
1556 |
ifTrue: |
|
1557 |
[aDepth := (array at: 1) depth. |
|
1558 |
aPalette := (array at: 1) palette] |
|
1559 |
ifFalse: [aDepth < (array at: 1) depth |
|
1560 |
ifTrue: |
|
1561 |
[aDepth := (array at: 1) depth. |
|
1562 |
aPalette := (array at: 1) palette]]]. |
|
1563 |
anImage := Image |
|
1564 |
extent: aRectangle extent |
|
1565 |
depth: aDepth |
|
1566 |
palette: aPalette. |
|
1567 |
aPattern := Image |
|
1568 |
extent: 16 @ 16 |
|
1569 |
depth: anImage depth |
|
1570 |
palette: anImage palette. |
|
1571 |
indexValue := aPattern palette indexOfPaintNearest: ColorValue white. |
|
1572 |
0 to: aPattern width - 1 do: [:x | 0 to: aPattern height - 1 do: [:y | aPattern atPoint: x @ y put: indexValue]]. |
|
1573 |
anImage |
|
1574 |
tile: aRectangle |
|
1575 |
from: Point zero |
|
1576 |
in: aPattern |
|
1577 |
rule: RasterOp over. |
|
1578 |
imageSequence |
|
1579 |
do: |
|
1580 |
[:array | |
|
1581 |
| srcImage srcR dstR | |
|
1582 |
srcImage := array at: 1. |
|
1583 |
srcR := array at: 2. |
|
1584 |
dstR := array at: 3. |
|
1585 |
srcImage palette = aPalette ifFalse: [srcImage := srcImage convertToPalette: aPalette renderedBy: ErrorDiffusion new]. |
|
1586 |
dstR := dstR translatedBy: Point zero - aRectangle origin. |
|
1587 |
anImage |
|
1588 |
copy: dstR |
|
1589 |
from: srcR origin |
|
1590 |
in: srcImage |
|
1591 |
rule: RasterOp over]. |
|
1592 |
^anImage |
|
1593 |
! |
|
1594 |
||
1595 |
packBits: bits |
|
1596 |
| packStream prev writeBlock bitSize bitPos start code replicateSize literalSize | |
|
1597 |
packStream := WriteStream on: (ByteArray new: bits size). |
|
1598 |
prev := nil. |
|
1599 |
writeBlock := [:asc | asc key < 0 |
|
1600 |
ifTrue: |
|
1601 |
["replicate" |
|
1602 |
packStream nextPut: asc key negated. |
|
1603 |
packStream nextPut: asc value] |
|
1604 |
ifFalse: |
|
1605 |
["literal" |
|
1606 |
| litStart litStop | |
|
1607 |
litStart := asc value first. |
|
1608 |
litStop := asc value last. |
|
1609 |
asc key = (litStop - litStart) ifFalse: [self error: 'can''t happen']. |
|
1610 |
[litStop - litStart + 1 > 128] |
|
1611 |
whileTrue: |
|
1612 |
[packStream nextPut: 127. |
|
1613 |
litStart to: litStart + 127 do: [:litIndex | packStream nextPut: (bits at: litIndex)]. |
|
1614 |
litStart := litStart + 128]. |
|
1615 |
litStart <= litStop |
|
1616 |
ifTrue: |
|
1617 |
[packStream nextPut: litStop - litStart + 1 - 1. |
|
1618 |
litStart to: litStop do: [:litIndex | packStream nextPut: (bits at: litIndex)]]]]. |
|
1619 |
bitSize := bits size. |
|
1620 |
bitPos := 1. |
|
1621 |
[bitPos <= bitSize] |
|
1622 |
whileTrue: |
|
1623 |
[start := bitPos. |
|
1624 |
code := bits at: start. |
|
1625 |
[(bitPos := bitPos + 1) <= bitSize and: [(bits at: bitPos) |
|
1626 |
= code]] |
|
1627 |
whileTrue: []. |
|
1628 |
replicateSize := bitPos - start. |
|
1629 |
replicateSize > 128 |
|
1630 |
ifTrue: |
|
1631 |
[prev == nil |
|
1632 |
ifFalse: |
|
1633 |
[writeBlock value: prev. |
|
1634 |
prev := nil]. |
|
1635 |
[replicateSize > 128] |
|
1636 |
whileTrue: |
|
1637 |
[writeBlock value: -129 -> code. |
|
1638 |
start := start + 128. |
|
1639 |
replicateSize := replicateSize - 128]]. |
|
1640 |
replicateSize = 2 |
|
1641 |
ifTrue: |
|
1642 |
["treat as literal" |
|
1643 |
literalSize := 2. |
|
1644 |
prev ~~ nil ifTrue: [prev key >= 0 |
|
1645 |
ifTrue: |
|
1646 |
["prev is literal" |
|
1647 |
literalSize := literalSize + prev value size. |
|
1648 |
start := prev value first] |
|
1649 |
ifFalse: |
|
1650 |
[writeBlock value: prev. |
|
1651 |
prev := nil]]. |
|
1652 |
prev := literalSize - 1 -> (start to: start + literalSize - 1)] |
|
1653 |
ifFalse: [replicateSize > 2 |
|
1654 |
ifTrue: |
|
1655 |
[prev == nil |
|
1656 |
ifFalse: |
|
1657 |
[writeBlock value: prev. |
|
1658 |
prev := nil]. |
|
1659 |
prev := (256 - (replicateSize - 1)) negated -> code] |
|
1660 |
ifFalse: ["replicateSize < 2" |
|
1661 |
bitPos := bitPos - 1]]. |
|
1662 |
(start := bitPos) <= bitSize |
|
1663 |
ifTrue: |
|
1664 |
[code := bits at: start. |
|
1665 |
[(bitPos := bitPos + 1) <= bitSize and: [(bits at: bitPos) |
|
1666 |
~= code]] |
|
1667 |
whileTrue: [code := bits at: bitPos]. |
|
1668 |
bitPos <= bitSize ifTrue: [bitPos := bitPos - 1]. |
|
1669 |
literalSize := bitPos - start. |
|
1670 |
literalSize > 0 |
|
1671 |
ifTrue: |
|
1672 |
[prev ~~ nil ifTrue: [prev key >= 0 |
|
1673 |
ifTrue: |
|
1674 |
["prev is literal" |
|
1675 |
literalSize := literalSize + prev value size. |
|
1676 |
start := prev value first] |
|
1677 |
ifFalse: |
|
1678 |
[writeBlock value: prev. |
|
1679 |
prev := nil]]. |
|
1680 |
prev := literalSize - 1 -> (start to: start + literalSize - 1)]]]. |
|
1681 |
prev == nil |
|
1682 |
ifFalse: |
|
1683 |
[writeBlock value: prev. |
|
1684 |
prev := nil]. |
|
1685 |
^packStream contents |
|
1686 |
! |
|
1687 |
||
1849 | 1688 |
progress:fraction |
1689 |
self reportProgress:fraction |
|
1690 |
! |
|
1691 |
||
1806 | 1692 |
rgbIntegerFrom: aColorValue |
1693 |
| scalingValue | |
|
1694 |
scalingValue := ColorValue scalingValue. |
|
1695 |
^((self |
|
1696 |
convertValue: aColorValue scaledRed |
|
1697 |
from: scalingValue |
|
1698 |
to: 65535) |
|
1699 |
bitShift: 32) |
|
1700 |
+ ((self |
|
1701 |
convertValue: aColorValue scaledGreen |
|
1702 |
from: scalingValue |
|
1703 |
to: 65535) |
|
1704 |
bitShift: 16) + (self |
|
1705 |
convertValue: aColorValue scaledBlue |
|
1706 |
from: scalingValue |
|
1707 |
to: 65535) |
|
1708 |
! |
|
1709 |
||
1710 |
unPackBits: bits |
|
1711 |
| unpackStream bitSize bitPos code | |
|
1712 |
unpackStream := WriteStream on: (ByteArray new: bits size). |
|
1713 |
bitSize := bits size. |
|
1714 |
bitPos := 0. |
|
1715 |
[(bitPos := bitPos + 1) <= bitSize] |
|
1716 |
whileTrue: |
|
1717 |
[code := bits at: bitPos. |
|
1718 |
code < 128 |
|
1719 |
ifTrue: [1 to: code + 1 do: [:i | unpackStream nextPut: (bits at: (bitPos := bitPos + 1))]] |
|
1720 |
ifFalse: [code > 128 |
|
1721 |
ifTrue: |
|
1722 |
[bitPos := bitPos + 1. |
|
1723 |
1 to: 256 - code + 1 do: [:i | unpackStream nextPut: (bits at: bitPos)]]]]. |
|
1724 |
^unpackStream contents |
|
1725 |
! ! |
|
1726 |
||
1727 |
!PICTReader methodsFor:'reading'! |
|
1804 | 1728 |
|
1729 |
fromStream: aStream |
|
1730 |
"read an image in my format from aStream. |
|
1731 |
Dtermine if its a raster or icon file." |
|
1732 |
||
1806 | 1733 |
|endOpcode| |
1804 | 1734 |
|
1816 | 1735 |
"/ ^ self fileFormatError:'Sorry - PICT image implementation is incomplete'. |
1807 | 1736 |
|
1804 | 1737 |
inStream := aStream. |
1738 |
aStream binary. |
|
1739 |
||
1806 | 1740 |
inStream skip:512. "apples file header" |
1804 | 1741 |
|
1806 | 1742 |
currentOpcode := nil. |
1743 |
imageSequence := OrderedCollection new. |
|
1744 |
self readHeader. |
|
1849 | 1745 |
self reportDimension. |
1806 | 1746 |
endOpcode := 16r00FF. |
1843 | 1747 |
[currentOpcode = endOpcode] whileFalse: [self nextOpcode]. |
1748 |
||
1806 | 1749 |
imageSequence isEmpty ifTrue: [^nil]. |
1807 | 1750 |
imageSequence size = 1 ifTrue: [ |
1849 | 1751 |
"/ OLD: |
1752 |
"/ ^ imageSequence first first |
|
1753 |
"/ NEW: |
|
1754 |
^ imageSequence first image |
|
1807 | 1755 |
]. |
1806 | 1756 |
^ self mergeImages |
1804 | 1757 |
|
1758 |
" |
|
1849 | 1759 |
PICTReader fromFile:'/unsaved2/stefan/nil/home/stefan/dos/winword/shared/ms.pct' |
1804 | 1760 |
" |
1806 | 1761 |
! ! |
1804 | 1762 |
|
1807 | 1763 |
!PICTReader methodsFor:'support-IO'! |
1764 |
||
1765 |
next |
|
1766 |
^ inStream nextByte |
|
1767 |
! |
|
1768 |
||
1769 |
next:numBytes |
|
1770 |
^ inStream next:numBytes |
|
1771 |
! |
|
1772 |
||
1773 |
nextLong |
|
1774 |
"/ ^ (inStream next bitShift: 24) |
|
1775 |
"/ + (inStream next bitShift: 16) + (inStream next bitShift: 8) + inStream next |
|
1776 |
^ inStream nextUnsignedLongMSB:true |
|
1777 |
! |
|
1778 |
||
1779 |
nextLongPut:a32BitW |
|
1780 |
"/ outStream nextPut: ((a32BitW bitShift: -24) |
|
1781 |
"/ bitAnd: 255). |
|
1782 |
"/ outStream nextPut: ((a32BitW bitShift: -16) |
|
1783 |
"/ bitAnd: 255). |
|
1784 |
"/ outStream nextPut: ((a32BitW bitShift: -8) |
|
1785 |
"/ bitAnd: 255). |
|
1786 |
"/ outStream nextPut: (a32BitW bitAnd: 255). |
|
1787 |
outStream nextPutLong:a32BitW MSB:true. |
|
1788 |
^a32BitW |
|
1789 |
! |
|
1790 |
||
1791 |
nextPut:aByte |
|
1792 |
outStream nextPut:aByte |
|
1793 |
! |
|
1794 |
||
1795 |
nextWord |
|
1796 |
^ inStream nextUnsignedShortMSB:true |
|
1797 |
! |
|
1798 |
||
1799 |
nextWordPut:a16BitW |
|
1800 |
"/ outStream nextPut: ((a16BitW bitShift: -8) |
|
1801 |
"/ bitAnd: 255). |
|
1802 |
"/ outStream nextPut: (a16BitW bitAnd: 255). |
|
1803 |
outStream nextPutShort:a16BitW MSB:true. |
|
1804 |
^a16BitW |
|
1805 |
! |
|
1806 |
||
1807 |
position |
|
1808 |
^ inStream position |
|
1809 |
! |
|
1810 |
||
1811 |
position:arg |
|
1812 |
inStream position:arg |
|
1813 |
! |
|
1814 |
||
1815 |
size |
|
1816 |
self halt. |
|
1817 |
^ outStream size |
|
1818 |
! |
|
1819 |
||
1820 |
skip: anInteger |
|
1821 |
self halt. |
|
1822 |
^ inStream skip: anInteger |
|
1823 |
! |
|
1824 |
||
1825 |
space |
|
1826 |
^ outStream space |
|
1827 |
! |
|
1828 |
||
1829 |
tab |
|
1830 |
^ outStream tab |
|
1831 |
! ! |
|
1832 |
||
1806 | 1833 |
!PICTReader methodsFor:'writing'! |
1834 |
||
1835 |
nextPutImage: anImage |
|
1836 |
| endOpcode | |
|
1807 | 1837 |
|
1838 |
^ self fileFormatError:'Sorry - PICT image implementation is incomplete'. |
|
1839 |
||
1806 | 1840 |
"/ (anImage isKindOf: Image) not ifTrue: [^self errorCanNotWrite]. |
1841 |
"/ ((imageStream isKindOf: ExternalStream) |
|
1842 |
"/ or: [(imageStream respondsTo: #stream) |
|
1843 |
"/ and: [imageStream stream isKindOf: ExternalStream]]) |
|
1844 |
"/ ifTrue: [self nextPutAll: (ByteArray new: 512)]. |
|
1845 |
"/ picSize := 0. |
|
1846 |
"/ picFrame := 0 @ 0 extent: anImage extent. |
|
1847 |
"/ anImage bitsPerPixel = 1 |
|
1848 |
"/ ifTrue: [picVersion := 1] |
|
1849 |
"/ ifFalse: [picVersion := 2]. |
|
1850 |
"/ anImage bitsPerPixel > 8 ifTrue: [^self nextPutImage24: anImage]. |
|
1851 |
"/ rowBytes := anImage width * anImage bitsPerPixel + 7 // 8. |
|
1852 |
"/ bounds := anImage bounds. |
|
1853 |
"/ pmVersion := 0. |
|
1854 |
"/ packType := 0. |
|
1855 |
"/ packSize := 0. |
|
1856 |
"/ hRes := '16r00480000' asNumber. |
|
1857 |
"/ vRes := '16r00480000' asNumber. |
|
1858 |
"/ pixelType := 0. |
|
1859 |
"/ pixelSize := anImage bitsPerPixel. |
|
1860 |
"/ cmpCount := 1. |
|
1861 |
"/ cmpSize := anImage bitsPerPixel. |
|
1862 |
"/ planeBytes := 0. |
|
1863 |
"/ pmTable := 0. |
|
1864 |
"/ pmReserved := 0. |
|
1865 |
"/ ctSeed := 0. |
|
1866 |
"/ ctFlags := '16r8000' asNumber. |
|
1867 |
"/ ctSize := anImage palette maxIndex. |
|
1868 |
"/ ctTable := nil. |
|
1869 |
"/ srcRect := anImage bounds. |
|
1870 |
"/ dstRect := anImage bounds. |
|
1871 |
"/ mode := 0. |
|
1872 |
"/ endOpcode := '16r00FF' asNumber. |
|
1873 |
"/ self writeImage: anImage. |
|
1874 |
"/ self writeOpcode: endOpcode. |
|
1875 |
"/ ^anImage |
|
1804 | 1876 |
! ! |
1877 |
||
1849 | 1878 |
!PICTReader::PICTFrame methodsFor:'accessing'! |
1879 |
||
1880 |
destinationRectangle |
|
1881 |
^ destinationRectangle |
|
1882 |
! |
|
1883 |
||
1884 |
image |
|
1885 |
^ image |
|
1886 |
! |
|
1887 |
||
1888 |
image:imageArg sourceRectangle:sourceRectangleArg destinationRectangle:destinationRectangleArg mode:modeArg |
|
1889 |
"set instance variables (automatically generated)" |
|
1890 |
||
1891 |
image := imageArg. |
|
1892 |
sourceRectangle := sourceRectangleArg. |
|
1893 |
destinationRectangle := destinationRectangleArg. |
|
1894 |
mode := modeArg. |
|
1895 |
! |
|
1896 |
||
1897 |
maskRegion |
|
1898 |
^ maskRegion |
|
1899 |
! |
|
1900 |
||
1901 |
maskRegion:something |
|
1902 |
maskRegion := something. |
|
1903 |
! |
|
1904 |
||
1905 |
mode |
|
1906 |
^ mode |
|
1907 |
! |
|
1908 |
||
1909 |
sourceRectangle |
|
1910 |
^ sourceRectangle |
|
1911 |
! ! |
|
1912 |
||
1804 | 1913 |
!PICTReader class methodsFor:'documentation'! |
1914 |
||
1915 |
version |
|
1850 | 1916 |
^ '$Header: /cvs/stx/stx/libview2/PICTReader.st,v 1.8 2003-11-19 19:19:27 cg Exp $' |
1804 | 1917 |
! ! |
1918 |
||
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1850
diff
changeset
|
1919 |
|
1804 | 1920 |
PICTReader initialize! |