Mail Archives: djgpp/1997/03/25/20:24:02
Michael Bevin writes:
>i've got a programme which uses an allegro datafile to store heaps of
>jpgs and then uses this jpg library to decode them except the jpg library
>needs the input coming from a stream (ie *fp) so i have to write
>each jpg to disk and then fopen it which is pretty
>pointless... is there any way i can get around this?
As of Allegro 2.2 you can use the register_datafile_object() function to
define your own loading routines for custom object types. The trouble is
that Allegro will give you a pointer to a PACKFILE stream rather than a
regular stdio file, and there's no easy way around that. You could
investigate the possibility of modifying the jpeg library to use Allegro
functions (the syntax is mostly the same, just replace FILE with
PACKFILE and prefix all the reading functions with "pack_").
Alternatively you might be able to use the djgpp filesystem extensions
to hook the Allegro decompression code into the regular disk access
system, but I don't know anything about how that works, and suspect it
would be quite complex...
The easy solution would of course be just not to use datafiles :-) The
main benefit of them is the compression, and since jpegs are already
heavily compressed I doubt my LZSS code will work very well...
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -