b85b5d2cf7500d09dc6480a4629df7ce78f88e5f
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
91 var
104 var
107 begin
110 begin
113 begin
114 // RLE data
120 //Inc(Source);
123 end
124 else
125 begin
126 // Uncompressed data
134 begin
138 begin
139 // Read PCX header and store input position (start of image data)
143 // Determine image's data format and find its Imaging equivalent
144 // (using some custom TImageFormat constants)
161 // No compatible Imaging format found, exit
163 Exit;
165 // Get width, height, and output data format (unsupported formats
166 // like ifMono are converted later to ifIndex8)
170 Format := FileDataFormat
171 else
177 begin
178 // other formats use palette embedded to file header
180 begin
188 // Now we determine various data sizes
193 try
195 begin
196 // Image data is compressed -> read and decompress
198 end
199 else
200 begin
201 // Just read uncompressed data
206 begin
207 // RGB and ARGB images are stored in layout different from
208 // Imaging's (and most other file formats'). First there is
209 // Width red values then there is Width green values and so on
213 begin
216 begin
222 begin
231 end
232 else
233 begin
236 begin
241 begin
250 end
252 begin
253 // Just copy 8bit lines
256 end
258 begin
259 // Convert 1bit images to ifIndex8
261 end
263 begin
264 // Convert 2bit images to ifIndex8. Note that 2bit PCX images
265 // usually use (from specs, I've never seen one myself) CGA palette
266 // which is not array of RGB tripplets. So 2bit PCXs are loaded but
267 // their colors would be wrong
269 end
271 begin
272 // 4bit images can be stored similar to RGB images (in four one bit planes)
273 // or like array of nibbles (which is more common)
275 begin
279 begin
286 begin
299 end
301 begin
302 // Convert 4bit images to ifIndex8
304 end
308 begin
309 // 8bit palette is appended at the end of the file
310 // with $0C identifier
311 //Seek(Handle, -769, smFromEnd);
314 begin
317 begin
323 end
324 else
328 finally
336 var
339 begin
342 begin
356 initialization
359 {
360 File Notes:
362 -- TODOS ----------------------------------------------------
363 - nothing now
365 -- 0.21 Changes/Bug Fixes -----------------------------------
366 - Made loader stream-safe - stream position is exactly at the end of the
367 image after loading and file size doesn't need to be know during the process.
368 - Initial TPCXFileFormat class implemented.
370 }