is the
string supplied by the -name command line argument (or the default of
"image").
Each element of the static array encodes the value for one
pixel in the form 0xaarrggbb, where aa is the hex value for alpha
(transparency) rr for red, etc. Currently all alpha values are set to
ff (fully opaque).
The program can be invoked from the command line using the -name argument
to control the declared names. Reads a PPM file from standard input,
and produces the resulting declarations on standard output.
This program now handles both ASCII and Binary encoded PPM files.
Field Summary |
protected static java.util.StringTokenizer |
current_line
A tokenizer attached to the string for the current line |
protected static java.io.BufferedReader |
input_file
The input stream we are reading from (this will get wrapped around
System.in). |
Method Summary |
protected static void |
do_binary_data(int w,
int h)
Process binary coded data body. |
static void |
main(java.lang.String[] argv)
Main program so we can be invoked from the command line. |
protected static int |
next_int(java.lang.String message)
Get the next token from standard input and try to interpret it as a
decimal integer. |
protected static java.lang.String |
next_token()
Get the next white-space delimited token from the input file |
protected static void |
usage()
Print a "usage" message and exit |
protected static void |
write_hex_color(long alpha,
long r,
long g,
long b)
Write a color out to standard input encoded in a 32 bit hex constant (we
use longs here so everything will be unsigned. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
input_file
protected static java.io.BufferedReader input_file
- The input stream we are reading from (this will get wrapped around
System.in).
current_line
protected static java.util.StringTokenizer current_line
- A tokenizer attached to the string for the current line
next_token
protected static java.lang.String next_token()
- Get the next white-space delimited token from the input file
next_int
protected static int next_int(java.lang.String message)
- Get the next token from standard input and try to interpret it as a
decimal integer. If this fails we print the given message on System.err
and exit.
- Parameters:
String
- message error message to print on System.err if we fail.- Returns:
- int integer value of next token treated as a decimal integer.
write_hex_color
protected static void write_hex_color(long alpha,
long r,
long g,
long b)
- Write a color out to standard input encoded in a 32 bit hex constant (we
use longs here so everything will be unsigned. The result will be in the
form "0xaarrggbb".
- Parameters:
long
- alpha transparency value.long
- r red value.long
- g green value.long
- b blue value.
usage
protected static void usage()
- Print a "usage" message and exit
main
public static void main(java.lang.String[] argv)
- Main program so we can be invoked from the command line.
- Parameters:
String
- argv[] arguments passed from the command line.
do_binary_data
protected static void do_binary_data(int w,
int h)
- Process binary coded data body. We expect to see 3*w*h bytes of data
each representing a color value. We write out initialization code based
on this data.
- Parameters:
int
- w width of image.int
- h height of image.