1 {
2 Vampyre Imaging Library
3 by Marek Mauder
4 http://imaginglib.sourceforge.net
6 The contents of this file are used with permission, subject to the Mozilla
7 Public License Version 1.1 (the "License"); you may not use this file except
8 in compliance with the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/MPL-1.1.html
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
13 the specific language governing rights and limitations under the License.
15 Alternatively, the contents of this file may be used under the terms of the
16 GNU Lesser General Public License (the "LGPL License"), in which case the
17 provisions of the LGPL License are applicable instead of those above.
18 If you wish to allow use of your version of this file only under the terms
19 of the LGPL License and not to allow others to use your version of this file
20 under the MPL, indicate your decision by deleting the provisions above and
21 replace them with the notice and other provisions required by the LGPL
22 License. If you do not delete the provisions above, a recipient may use
23 your version of this file under either the MPL or the LGPL License.
25 For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html
26 }
28 { This unit contains image format loader for ZSoft Paintbrush images known as PCX.}
31 {$I ImagingOptions.inc}
33 interface
35 uses
38 type
39 { Class for loading ZSoft Paintbrush images known as PCX. It is old
40 format which can store 1bit, 2bit, 4bit, 8bit, and 24bit (and 32bit but is
41 probably non-standard) images. Only loading is supported (you can still come
42 accross some PCX files) but saving is not (I don't wont this venerable format
43 to spread).}
45 protected
49 public
53 implementation
55 const
59 type
77 { TPCXFileFormat }
80 begin
90 var
103 var
106 begin
109 begin
112 begin
113 // RLE data
119 //Inc(Source);
122 end
123 else
124 begin
125 // Uncompressed data
133 begin
137 begin
138 // Read PCX header and store input position (start of image data)
142 // Determine image's data format and find its Imaging equivalent
143 // (using some custom TImageFormat constants)
160 // No compatible Imaging format found, exit
162 Exit;
164 // Get width, height, and output data format (unsupported formats
165 // like ifMono are converted later to ifIndex8)
169 Format := FileDataFormat
170 else
176 begin
177 // other formats use palette embedded to file header
179 begin
187 // Now we determine various data sizes
192 try
194 begin
195 // Image data is compressed -> read and decompress
197 end
198 else
199 begin
200 // Just read uncompressed data
205 begin
206 // RGB and ARGB images are stored in layout different from
207 // Imaging's (and most other file formats'). First there is
208 // Width red values then there is Width green values and so on
212 begin
215 begin
221 begin
230 end
231 else
232 begin
235 begin
240 begin
249 end
251 begin
252 // Just copy 8bit lines
255 end
257 begin
258 // Convert 1bit images to ifIndex8
260 end
262 begin
263 // Convert 2bit images to ifIndex8. Note that 2bit PCX images
264 // usually use (from specs, I've never seen one myself) CGA palette
265 // which is not array of RGB tripplets. So 2bit PCXs are loaded but
266 // their colors would be wrong
268 end
270 begin
271 // 4bit images can be stored similar to RGB images (in four one bit planes)
272 // or like array of nibbles (which is more common)
274 begin
278 begin
285 begin
298 end
300 begin
301 // Convert 4bit images to ifIndex8
303 end
307 begin
308 // 8bit palette is appended at the end of the file
309 // with $0C identifier
310 //Seek(Handle, -769, smFromEnd);
313 begin
316 begin
322 end
323 else
327 finally
335 var
338 begin
341 begin
355 initialization
358 {
359 File Notes:
361 -- TODOS ----------------------------------------------------
362 - nothing now
364 -- 0.21 Changes/Bug Fixes -----------------------------------
365 - Made loader stream-safe - stream position is exactly at the end of the
366 image after loading and file size doesn't need to be know during the process.
367 - Initial TPCXFileFormat class implemented.
369 }