home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
graphics
/
gif2rpc_1
/
!Help
next >
Wrap
Text File
|
1996-01-21
|
23KB
|
875 lines
db od8o.o8bo
88[ ]8[]P8` 88[
YP 88[ Y8 ]88
88[ P` ]88
o88bodboo8 .o88bo d8[ .od,o8[.odbo88o .d88o
]8[ 88,""88 88[ .8P "888"88'Y88`'88, .8P ]8[
Y8[ 88` 88 88[ d8 88P ' ]8[ Y8b 88[ "
'8bo8P 88 88[ .8` 88[ ]8[ ]88 88[
.d""` 88 88[ .8` 88[ ]8[ 88[ Y8[ .,
]8oooo,.o88b.o88bo.888888 o88bo ]88bd88 '88oo8
'888888 """" """"` """""P '"""` ]8['"" """
. """8 ]8[
8[ .8 ]8b
'88o8P` ]8888
A freeware GIF™ -> RISC O S sprite converter
By Cy Booker <cy@cheepnis.demon.co.uk>
Version 1.02 21-Jan-1996
================================================================ gif2rpc ====
[1] Synopsis . . . . . . . . . . . . . . . . . . . . . 1
[1.1] License . . . . . . . . . . . . . . . . . . . . . . 1
[1.2] Trademarks . . . . . . . . . . . . . . . . . . . . 2
[2] How to use . . . . . . . . . . . . . . . . . . . . 2
[2.1] How to use with ArcWeb . . . . . . . . . . . . . . 2
[2.2] How to use with Webster . . . . . . . . . . . . . . 3
[2.3] Command line parameters . . . . . . . . . . . . . . 3
[2.4] Default options: gif2rpc$options . . . . . . . . . 8
[3] Output image format . . . . . . . . . . . . . . . . 9
[4] Why use gif2rpc . . . . . . . . . . . . . . . . . . 10
[4.1] Speed comparisons . . . . . . . . . . . . . . . . . 10
[5] Error codes . . . . . . . . . . . . . . . . . . . . 11
[6] History . . . . . . . . . . . . . . . . . . . . . . 12
================================================================ gif2rpc ====
[1] Synopsis
gif2rpc is a program for RISC O S (>= 3.10) that converts
GIF image files to native sprite files.
A GIF file is a 2…256 colour image, with an associated
24-bit palette and an optional “transparency” mask.
This program was written mainly to allow the generation of
32K colour images that look as good as they can. This is
because, despite what you intuitively feel, a 256 colour
image displayed on a 32K colour screen does *not* look that
good.
[I mainly browse the World Wide Web in a 32K colour screen,
and am generally disappointed with the way GIFs are
displayed, and so wrote this program that provides a very
good conversion of GIFs to 32K colour modes.]
Since then it has extended to be a general image processing
program.
Note that gif2rpc is extremely lenient towards malformed
GIF's (ie it won't crash if fed garbage).
[1.1] License
This software comes with NO WARANTEE. It is distributed in
the hope that it's useful. The author will not be liable
for any incurred damages, directly or indirectly due to the
use or inability to use this software.
It is FreeWare, and remains the copyright of the author.
Portions of this code are copyright Stephen A. Bennet:
* DECODE.C - An LZW decoder for GIF
* Copyright (C) 1987, by Steven A. Bennett
*
* Permission is given by the author to freely redistribute
* and include this code in any program as long as this
* credit is given where due.
The code to match a colour to the default wimp palette is
based on a UseNet article:
Message-ID: <12463@acorn.co.uk>
Date: 30 Jan 92 12:20:23 GMT
From: RWilson@acorn.co.uk
Subject: How to find the closest colour out of
the RISC OS 256
Page 1
================================================================ gif2rpc ====
[1.2] Trademarks
GIF is a trademark of Compuserve Inc.
[2] How to use
gif2rpc is a command line utility. It takes quite a few
parameters, but basic usage is:
gif2rpc <in> <out>
If you would like a logfile of any errors that are
encountered then append “ >>& logfile” to the command
line, or use the -log parameter.
Note that if you have he DDEutils module then gif2rpc will
take advantage of the new facility for long command lines.
[2.1] How to use with ArcWeb
This applies to ArcWeb 1.14. First open the Browser
configuration window, and enable the “GIF87 handled by
gif2spr” option. Select OK. Don't forget to choose the
menu item “Configure->Save options”!
Next make a back up copy of the file “!ArcWeb.gif2spr”.
Finally copy these files:
gif2rpc -> !ArcWeb.gif2rpc
WWW.gif2spr -> !ArcWeb.gif2spr
WWW.gif2rpcFE -> !ArcWeb.gif2rpcFE
And that is that.
You may wish to modify the (new) “!ArcWeb.gif2spr” file to
change the initialisation of the system variable
“gif2rpc$options”.
Page 2
================================================================ gif2rpc ====
[2.2] How to use with Webster
This applies to Webster v0.11. First open the Choices
dialogue box, and select the “Inlne Viewers” tab. Ensure
that the “GIF Decoder” value is left at the default of
“<Webster$Dir>.gif2spr -q %0 %1”. Click the Save button.
Next make a back up copy of the file “!Webster.gif2spr”.
Finally copy the *contents* of the WWW directory into the
!Webster directory, i.e. creating the three files:
gif2rpc -> !Webster.gif2rpc
WWW.gif2spr -> !Webster.gif2spr
WWW.gif2rpcFE -> !Webster.gif2rpcFE
And that is that.
You may wish to modify the (new) “!Webster.gif2spr” file to
change the initialisation of the system variable
“gif2rpc$options”.
[2.3] Command line parameters
Here are all the parameters:
[-gif] <file-name>
this is the name of the GIF file. It does not
need to be type’d as a TIFF file, as this program
will verify that the file is in GIF format
[-sprite] <file-name>
this will be the file that is produced, containing
the single sprite representing the original GIF
image
[-help]
produce some terse help on these parameters
[-verbose <n>]
by default <n> is 0, which disables all text
output while the GIF file is being read and
processed. By setting <n> to 1, then some basic
information is displayed. This can be redirected
to a file by appending “> file” to the command
line. By setting <n> to 2 then rather more
information is displayed
Page 3
================================================================ gif2rpc ====
[-quiet]
by default, if gif2rpc detects an error in the
input GIF, then it will first display a textual
message saying where and what failed, then attempt
to continue (but see -fussy). This message can be
redirected to a a file by appending “2> file” to
the command line, or using -log (below). For a
list of the error messages, see below
[-hourglass]
because some GIFs are big, they take a long time
to process (even on an ARM 700). Therefore you
may tell gif2rpc to use the “hourglass” to
give some visual feedback over how far it has got
in processing the GIF. The percentage indicator
is used to show how much of the image has already
been decoded
After decoding, while the image is processed the
percentage counts DOWN from 100% to 0%. This is
an arbitrary aesthetic decision
[-name <text>]
by default the image saved in the -sprite
file-name will be “gif2rpc”. If this offends
you then you can rename it. Note that names of
sprites must be lower case. gif2rpc enforces this
by using the current locale’s idea of lower case.
Also note that sprite names are limited to twelve
characters. See also -autoname
Page 4
================================================================ gif2rpc ====
[-bpp <n>]
bpp stands for bits per pixel. This parameter
determines what sort of sprite image gif2rpc will
try to produce. It takes the following values
0 use GIF’s palette to produce 1/2/4/8 bpp
image. No image processing is done
1 produce a monochrome black/white image
2 produce a four colour image, using
default wimp palette (a grey scale)
4 produce a 16 colour image, using the
default wimp palette
8 produce a 256 colour image, using the
default wimp palette
16 produce a 32K colour image, with a fixed
palette
32 produce a 16M colour image
-1 (this is the good one) it uses the current
screen display to determine whether it
will produce a 2, 4, 16, 256, 32K, or 16M
colour image
also, the current screen palette is used
the default value is -1
[-accurate]
when generating a 256 colour image, this will force
the use of a more accurate colour matching
algorithm that runs about 3-4 times slower
[-force_66]
when generating a 32K colour image, this will force
the use of routines that use an internal resolution
of 22 bits per red/green/blue. Normally only 16
bits are used. These 66 bit routines are slower
[-square]
a GIF file can specify an aspect ratio for an
image. If a 32K or 16M colour image is produced
then, by default, this aspect ratio information
is embedded in the sprite. For <= 256 colour
images it is not possible for RISC O S to be told
of the aspect ratio. Using this switch will
disable embedding this aspect ratio information
Page 5
================================================================ gif2rpc ====
[-autoname]
the sprite in the spritefile can be give a name
derived from the input GIF file with this option
[stats]
this will output a single text line to show how
well (in terms of size) the conversion done,
relative to keeping the 256 colour image
The fields are
"gif2rpc "
"%s" input file name
"("
"%4d" horizontal pixel size
"x"
"%4d" vertical pixel size
":"
"%d" input bits per pixel
"p" [if palette in screen]
"s" [if palette is sorted]
"."
"i" [if interlaced]
"p" [if palette in image]
"s" [if palette is sorted]
"t" [if transparent]
") -> "
"%s" output file name
"("
"%s" output colours
") "
"%d" output size - gif2rpc output size
" "
"%f" total duration, in seconds
" "
"%f" percentage time spent filtering
" "
"%s" filter used
[-log <file>]
if present, this overrides any command line re-
direction of stdout and stderr
[-fussy]
by default gif2rpc will allow several mistakes in
a GIF file, and silently (if -quiet) ignore them.
With -fussy, these errors will cause conversion
to fail, and no sprite to be produced
Page 6
================================================================ gif2rpc ====
[-filter <name>]
If -bpp is not 0 then gif2rpc will process the
image to produce a sprite. These are the
algorithms it will use (these are listed fastest
to slowest)
nearest:
you do *not* want this. It is crap
dither2x2:
strongly recommended. It is only slightly
slower than nearest, and produces good
images (if >= 256 colours)
sierra2_4a:
very good, very fast. Personally, I think
it looks better than floyd-steinberg
floyd_steinberg:
as used by ChangeFSI. An old favourite
burkes:
a 2-line filter as per floyd_steinberg,
where the coefficients are quick to
calculate
sierra2:
very similar to burkes, but poor quality
sierra3:
a 3-line filter
stucki:
another 3-line filter, but slow to
calculate
jarvis_judice_ninke:
a 3-line filter which is very slow (22
times slower than dither2x2). It is
questionable whether it produces better
output
Note that you can *not* use shortcuts for the switches (ie
-v is not acceptable, use -verbose).
Page 7
================================================================ gif2rpc ====
[2.4] Default options: gif2rpc$options
If the system variable “gif2rpc$Options” is defined, then
it will be appended to any parameters given on the command
line.
This is particularly useful when using the logging
facilities of the program. For example, using
*Set gif2rpc$Options -stats -log $.log
will cause all calls to gif2rpc to append statistics
information to the file “$.log”.
2.5 Typical usage
For no-hassle usage use:
gif2rpc -quiet gif sprite
For some reasonable information then use something like:
gif2rpc -stats -log $.log gif sprite
and the log file will be appended with any errors, and a
single line giving some statistics of the conversion
For “problem” gif's use:
gif2rpc -verbose 2 -fussy gif sprite
Page 8
================================================================ gif2rpc ====
[3] Output image format
You may think that -bpp 0 is the best option, as this will
generate a sprite that contains all the information in the
original GIF.
But when you come to display that GIF, the OS has quite a
bit of work to do before it can plonk the data on the
screen. The miriad of options provided by gif2rpc are
there to do a lot of this work once, and not every time
the GIF is displayed.
The main processing that gif2rpc does is to remove any
explicit palette information, and alter the image so that
a default (RISC O S) palette is used. This usually saves
2K per image:
Size none 32K image 16M image
8x8 2168 184 312
16x16 2360 568 1080
32x32 3128 2104 4152
64x64 6200 8248 16440
1024x4 6200 8248 16440
And with a transparency mask
Size none 32K image 16M image
8x8 2232 216 344
16x16 2612 632 1144
32x32 4152 2232 4280
64x64 10296 8760 16952
1024x4 10296 8760 16952
Note that the -stat file may be used to give statistics
about the file size (and savings) encountered.
Page 9
================================================================ gif2rpc ====
[4] Why use gif2rpc
There are two other programs out there that perform near
identical functions:
!ChangeFSI
This program, unfortunately, does not seem
to cope with “transparent” GIFs. Since
these are the norm, rather than the
exception on the WWW, it is bad news
gif2spr
This is a nice program, but has no support
for generating 32K colour images
You’d use gif2rpc if you usually view GIFs in 32K modes,
or would like to convert GIFs to 16M colour sprites.
It’s logging facility, and fuller diagnostics of errors
may be useful to you.
Also, its' ability to use other filter algorithms (faster
ones like dither2x2, or slower ones) can be very useful.
[4.1] Speed comparisons
As a test bed, a 128 colour 640x480 GIF was used. It was
converted to a sprite 10 times, and a script recorded the
total time, accurate to +/- one second. It was ran in a
32K screen mode (1024x768), and a 32K image was generated:
ChangeFSI dithered 36 (S16,90,90)
gif2rpc floyd-steinberg 30 (-quiet, -bpp 16)
ChangeFSI simple 24 (S16,90,90, -nodither)
gif2spr 11 (-q)
gif2rpc 2x2 dither 11 (-quiet, -bpp 16)
For generating a 256 colour image in a 256 colour screen
mode (1600x1200):
ChangeFSI dither slow 67 (28r)
ChangeFSI dither fast 59 (28)
ChangeFSI simple slow 52 (28r, -nodither)
ChangeFSI simple fast 46 (28, -nodither)
gif2spr 11 (-q)
gif2rpc 8 (-quiet, -bpp 8)
Page 10
================================================================ gif2rpc ====
[5] Error codes
These are the error numbers that will be reported (unless
you use the -quiet option) if the GIF is found to be
corrupted:
10: the start of the file was not a valid GIF header
11: invalid lzw table size (not in range [2, 9])
12: short file
13: unexpected record
14: corrupt graphic extension record size
15: there was no image in the file
16: image size invalid (pixel size less than one)
17: corrupt graphic extension record terminator
18: (internal error) processing mask
19: (internal error) processing image
20: no palette defined in screen or image
21: last row was incomplete
22: extra byte(s) after image found
23: bad end of image marker
Page 11
================================================================ gif2rpc ====
[6] History
Version 1.02 21-Jan-1996
Better colour matching for 256 colour sprites
Version 1.01 14-Jan-1996
Added -autoname feature
Tidied up this documentation
Wrote the gif2rpcFE kludge program
Version 1.00 21-Sep-1995
This was never released, but was left
languishing on the hard disc
7 Author
Program and documentation by (but see copyright notice
above):
Cy Booker
86 Church View
Main Road
Crockenhill
Swanley
Kent
BR8 8JW
U.K.
Internet: cy@cheepnis.demon.co.uk
Arcade BBS (Fidonet#2:254/27.0): Cy Booker
Musical entertainment provided by Frank Zappa