com.tjtieto.wap.wapix
Class WBMPMaster

java.lang.Object
  |
  +--java.awt.Component
        |
        +--com.tjtieto.wap.wapix.WBMPMaster

public class WBMPMaster
extends java.awt.Component

WBMPMaster

Tool object for creating WBMP images and dithering + simple image processing operations on them. Efficiency, variety and Java 1.2 independency where the primary design goals. Supported error diffusion dithering mappings are: Floyd-Steinberg, Stucki, Burke, Jarvis et al, Shiau et al and various well-behaving ordered dither matrixes. Floyd-Steinberg produces good results and is relatively fast so it is recommended for intense operations. Stucki usually produces the best results.

Methods transform images to greyscale and finally black & white for two reasons: the images are only supposed to be 2 color images and they are more efficient this way.

Converts any java.awt.Image, JPG or GIF to WBMP format. Other formats are supported via Sun's JIMI package.

Supported properties:

p = processing method (processing style)
w = (width)
h = (height)
s = (scaling method)
url = url to read the image from
k = (threshold limit for rendering (0-255), default 128)
b = (bgcolor, default white)
i = (invert (0 = false, 1 = true), default 0)
mh = (mirror horizontally (0 = false, 1 = true))
fv = (flip vertically (0 = false, 1 = true))
o = outputfilename

Revision history:

 150500 Initial version after several tests and enhancements to previous systems
 180500 Added Shiau et al error diffusion patterns
 180500 Some minor optimizations to Burke pattern
 190500 Added methods for decoding WBMP images
 

DISCLAIMER:

THE AUTHOR CANNOT BE HELD RESPONSIBLE FOR ANY HARM, FINANCIAL LOSS OR RELATED EVENT CAUSED BY THE USE OF THIS SOFTWARE. THE ALGORITHMS USED HERE WERE DESIGNED BY RESPECTIVE AUTHORS AND THE ACCURACY OF THEIR IMPLEMENTATION IS NOT GUARANTEED. YOU MAY NOT SELL THIS CODE OR INCLUDE IT IN COMMERCIAL PRODUCTS WITHOUT WRITTEN AUTHORIZATION AND LICENSE AGREEMENT. FURTHER, ANY ATTEMPT TO REVERSE ENGINEER, ALTER OR OTHERWISE MANIPULATE THE CODE IS PROHIBITED. YOU ARE ALLOWED TO USE THIS OBJECT FOR EVALUATION PURPOSES, BUT IN OTHER CASES CONTACT THE AUTHOR.

ALL RIGHTS RESERVED (C) Jarkko Viinamäki

Version:
1.0.3 19.05.2000
Author:
Jarkko Viinamäki
See Also:
Serialized Form

Field Summary
static int PROCESS_DITHER_BURKE
          Burke error diffusion pattern:
- - X 8 4
2 4 8 4 2
static int PROCESS_DITHER_FLOYD_STEINBERG
          Floyd and Steinberg error diffusion pattern:
- X 7
3 5 1
static int PROCESS_DITHER_JARVIS
          Jarvis, Judice, and Ninke error diffusion pattern:
- - X 7 5
3 5 7 5 3
1 3 5 3 1
static int PROCESS_DITHER_ORDERED_2X2
          Ordered dithering with map:
1 3
4 2
static int PROCESS_DITHER_ORDERED_3X3_1
          Ordered dithering with map:
1 7 4
5 8 3
6 2 9
static int PROCESS_DITHER_ORDERED_3X3_2
          Ordered dithering with map:
8 3 4
6 1 2
7 5 9
static int PROCESS_DITHER_ORDERED_4X4
          Ordered dithering with map:
1 9 3 11
13 5 15 7
4 12 2 10
16 8 14 6
static int PROCESS_DITHER_SHIAU_1
          Shiau et al error diffusion pattern 1:
- - - X 8
1 1 2 4 0
static int PROCESS_DITHER_SHIAU_2
          Shiau et al error diffusion pattern 2:
- - - X 8
2 0 2 4 0
static int PROCESS_DITHER_STUCKI
          Stucki error diffusion pattern:
- - X 8 4
2 4 8 4 2
1 2 4 2 1
static int PROCESS_HORIZONTAL_MIRROR
          Mirrors the image pixels horizontally
static int PROCESS_THRESHOLD
          Creates black and white image with defined threshold color
static int PROCESS_VERTICAL_FLIP
          Flips the image pixels vertically
static int SCALE_AUTOFIT_BY_X
          Scale image by width setting and adjust height proportionally
static int SCALE_AUTOFIT_BY_Y
          Scale image by height setting and adjust width proportionally
static int SCALE_BY_X
          Scale image by width but leave the height to its old value
static int SCALE_BY_X_Y
          Scale image by height & width setting
static int SCALE_BY_Y
          Scale image by height but leave the width to its old value
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
WBMPMaster()
          Constructor
 
Method Summary
static java.awt.Image createImage(int[] ai, int i, int j)
          Creates java.awt.Image object based on pixel values.
static int decodeBytes(java.io.InputStream is)
          Reads one Multibyte Integer from the InputStream.
static int[] decodePixels(java.io.InputStream is)
          Reads a WBMP image from the InputStream and returns the result as one dimensional int array or RGB values.
static int[] ditherBurke(int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Burke pattern: - - X 8 4 2 4 8 4 2
Efficiency: 8
Quality: 8

Notice that this is just a simplification of the Stucki filter with the bottom row removed.
static int[] ditherFloydSteinberg(int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Floyd-Steinberg pattern: - X 7 3 5 1
Efficiency: 9
Quality: 7

In this filter, the X represents the pixel you are currently scanning, and the numbers (called weights, for equally boring reasons) represent the proportion of the error distributed to the pixel in that position.
static int[] ditherJarvis(int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Jarvis, Judice, and Ninke pattern: - - X 7 5 3 5 7 5 3 1 3 5 3 1
Efficiency: 6
Quality: 8

The divisor here is 48, which is a little more expensive to calculate, and the errors are distributed over three lines, requiring extra memory and time for processing.
static int[] ditherOrdered(int[] ai, int i, int j, int[] dithermap, java.awt.Color bg, boolean invert)
          Dithers image governed by dithermap array using ordered dithering method.
static int[] ditherShiau1(int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Shiau et al pattern 1: - - - X 8 1 1 2 4 0
This distribution scheme was proposed based on the hypothesis that worm creation was a result of the lack of error distribution beyond the direction of the diagonal defined by pixel (n,l) and pixel (n-1, l+1).
static int[] ditherShiau2(int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Shiau et al pattern 2: - - - X 8 2 0 2 4 0
The present proposal improves the output of the Shiau et al distribution scheme in some circumstances, and improves the efficiency of the error diffusion process, by eliminating one of the distribution neighbors, thereby reducing the number of neighboring pixels that receive error.
static int[] ditherSimple(int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Does simple threshold transformation of the image.
static int[] ditherStucki(int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Stucki pattern: - - X 8 4 2 4 8 4 2 1 2 4 2 1
Efficiency: 7
Quality: 10

This one takes a division by 42 for each pixel and is therefore slow if math is done inside the loop.
static void encodeBytes(java.io.OutputStream o, int i)
          Transforms bytes into Wireless Bitmap format.
 void encodePixels(java.io.OutputStream o, java.awt.Image image)
          Encodes java.awt.Image to Wireless Bitmap.
static void encodePixels(java.io.OutputStream o, int[] image, int width, int height)
          Encodes image RGB pixels to Wireless Bitmap.
static int[] flipPixels(int[] buffer, int width, int height)
          Flips image vertically.
 java.awt.Image getImage(java.net.URL url)
          Reads an image from the given URL
 java.awt.Image getScaledInstance(java.awt.Image img, int w, int h, int mode)
          Scales supplied image according to scaling mode.
 int[] grabPixels(java.awt.Image img)
          Transforms java.awt.Image into an array of pixels
static void main(java.lang.String[] arg)
          This method is called when the object is invoked from command line.
static int[] mirrorPixels(int[] buffer, int width, int height)
          Mirrors image horizontally.
 void processImage(java.io.OutputStream o, java.util.Properties prop)
          Processes all arguments given in Properties container, reads an image from defined URL, does selected image processing tricks and writes the result to supplied outputstream.
static int[] processPixels(int type, int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Dithers image RGB values, renders image to greyscale and finally transforms it into 2 color black & white image.
static byte[] readURL(java.net.URL addr)
          Reads contents of certain URL as buffered stream.
static int[] threshold(int[] ai, int i, int j, int k, java.awt.Color color, boolean flag)
          Transforms image into 2 color black & white by using param k as threshold value.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROCESS_DITHER_JARVIS

public static final int PROCESS_DITHER_JARVIS
Jarvis, Judice, and Ninke error diffusion pattern:
- - X 7 5
3 5 7 5 3
1 3 5 3 1

PROCESS_DITHER_FLOYD_STEINBERG

public static final int PROCESS_DITHER_FLOYD_STEINBERG
Floyd and Steinberg error diffusion pattern:
- X 7
3 5 1

PROCESS_DITHER_BURKE

public static final int PROCESS_DITHER_BURKE
Burke error diffusion pattern:
- - X 8 4
2 4 8 4 2

PROCESS_DITHER_STUCKI

public static final int PROCESS_DITHER_STUCKI
Stucki error diffusion pattern:
- - X 8 4
2 4 8 4 2
1 2 4 2 1

PROCESS_THRESHOLD

public static final int PROCESS_THRESHOLD
Creates black and white image with defined threshold color

PROCESS_DITHER_ORDERED_2X2

public static final int PROCESS_DITHER_ORDERED_2X2
Ordered dithering with map:
1 3
4 2

PROCESS_DITHER_ORDERED_3X3_1

public static final int PROCESS_DITHER_ORDERED_3X3_1
Ordered dithering with map:
1 7 4
5 8 3
6 2 9

PROCESS_DITHER_ORDERED_3X3_2

public static final int PROCESS_DITHER_ORDERED_3X3_2
Ordered dithering with map:
8 3 4
6 1 2
7 5 9

PROCESS_DITHER_ORDERED_4X4

public static final int PROCESS_DITHER_ORDERED_4X4
Ordered dithering with map:
1 9 3 11
13 5 15 7
4 12 2 10
16 8 14 6

PROCESS_HORIZONTAL_MIRROR

public static final int PROCESS_HORIZONTAL_MIRROR
Mirrors the image pixels horizontally

PROCESS_VERTICAL_FLIP

public static final int PROCESS_VERTICAL_FLIP
Flips the image pixels vertically

PROCESS_DITHER_SHIAU_1

public static final int PROCESS_DITHER_SHIAU_1
Shiau et al error diffusion pattern 1:
- - - X 8
1 1 2 4 0

PROCESS_DITHER_SHIAU_2

public static final int PROCESS_DITHER_SHIAU_2
Shiau et al error diffusion pattern 2:
- - - X 8
2 0 2 4 0

SCALE_AUTOFIT_BY_X

public static final int SCALE_AUTOFIT_BY_X
Scale image by width setting and adjust height proportionally

SCALE_AUTOFIT_BY_Y

public static final int SCALE_AUTOFIT_BY_Y
Scale image by height setting and adjust width proportionally

SCALE_BY_X_Y

public static final int SCALE_BY_X_Y
Scale image by height & width setting

SCALE_BY_X

public static final int SCALE_BY_X
Scale image by width but leave the height to its old value

SCALE_BY_Y

public static final int SCALE_BY_Y
Scale image by height but leave the width to its old value
Constructor Detail

WBMPMaster

public WBMPMaster()
Constructor
Method Detail

processPixels

public static final int[] processPixels(int type,
                                        int[] ai,
                                        int i,
                                        int j,
                                        int k,
                                        java.awt.Color color,
                                        boolean flag)
Dithers image RGB values, renders image to greyscale and finally transforms it into 2 color black & white image.
Parameters:
type - the dithering method to use. This defines the diffusion matrix.
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)

mirrorPixels

public static final int[] mirrorPixels(int[] buffer,
                                       int width,
                                       int height)
Mirrors image horizontally.
Parameters:
buffer - the original image to be mirrored
width - image width
height - image height
Returns:
new mirrored image pixels

flipPixels

public static final int[] flipPixels(int[] buffer,
                                     int width,
                                     int height)
Flips image vertically.
Parameters:
buffer - the original image to be flipped
width - image width
height - image height
Returns:
new flipped image pixels

ditherOrdered

public static int[] ditherOrdered(int[] ai,
                                  int i,
                                  int j,
                                  int[] dithermap,
                                  java.awt.Color bg,
                                  boolean invert)
Dithers image governed by dithermap array using ordered dithering method. While this algorithm is quite fast, it produces quite ugly results.
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
dithermap - contains the matrix used for dithering
Returns:
RGB pixel values of the result image (black & white, 2 colors)

ditherJarvis

public static int[] ditherJarvis(int[] ai,
                                 int i,
                                 int j,
                                 int k,
                                 java.awt.Color color,
                                 boolean flag)

Jarvis, Judice, and Ninke pattern:

 - - X 7 5
 3 5 7 5 3
 1 3 5 3 1
 

Efficiency: 6
Quality: 8

The divisor here is 48, which is a little more expensive to calculate, and the errors are distributed over three lines, requiring extra memory and time for processing.
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)

ditherStucki

public static int[] ditherStucki(int[] ai,
                                 int i,
                                 int j,
                                 int k,
                                 java.awt.Color color,
                                 boolean flag)

Stucki pattern:

 - - X 8 4
 2 4 8 4 2
 1 2 4 2 1
 

Efficiency: 7
Quality: 10

This one takes a division by 42 for each pixel and is therefore slow if math is done inside the loop. After the initial 8/42 is calculated, some time can be saved by producing the remaining fractions by shifts.
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)
See Also:
ditherBurke(int[], int, int, int, java.awt.Color, boolean)

ditherBurke

public static int[] ditherBurke(int[] ai,
                                int i,
                                int j,
                                int k,
                                java.awt.Color color,
                                boolean flag)

Burke pattern:

 - - X 8 4
 2 4 8 4 2
 

Efficiency: 8
Quality: 8

Notice that this is just a simplification of the Stucki filter with the bottom row removed. The main improvement is that the divisor is now 32, which makes calculating the errors faster, and the removal of one row reduces the memory requirements of the method.
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)
See Also:
ditherStucki(int[], int, int, int, java.awt.Color, boolean)

ditherSimple

public static final int[] ditherSimple(int[] ai,
                                       int i,
                                       int j,
                                       int k,
                                       java.awt.Color color,
                                       boolean flag)
Does simple threshold transformation of the image. Does not apply any dithering algorithms, simply does greyscale and BW-conversion.
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)

ditherFloydSteinberg

public static int[] ditherFloydSteinberg(int[] ai,
                                         int i,
                                         int j,
                                         int k,
                                         java.awt.Color color,
                                         boolean flag)

Floyd-Steinberg pattern:

 - X 7
 3 5 1
 

Efficiency: 9
Quality: 7

In this filter, the X represents the pixel you are currently scanning, and the numbers (called weights, for equally boring reasons) represent the proportion of the error distributed to the pixel in that position. Here, the pixel immediately to the right gets 7/16 of the error (the divisor is 16 because the weights add to 16), the pixel directly below gets 5/16 of the error, and the diagonally adjacent pixels get 3/16 and 1/16. When scanning a line right-to-left, this pattern is reversed. This pattern was chosen carefully so that it would produce a checkerboard pattern in areas with intensity of 1/2 (or 128 in our image). It is also fairly easy to calculate when the division by 16 is replaced by shifts.
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)

ditherShiau1

public static int[] ditherShiau1(int[] ai,
                                 int i,
                                 int j,
                                 int k,
                                 java.awt.Color color,
                                 boolean flag)

Shiau et al pattern 1:

 - - - X 8
 1 1 2 4 0
 

This distribution scheme was proposed based on the hypothesis that worm creation was a result of the lack of error distribution beyond the direction of the diagonal defined by pixel (n,l) and pixel (n-1, l+1). The added distribution to pixels (n-2, l+1), and (n-3, l+1) were combined with the elimination of distribution to pixel (n+1, l+1). Setting the error distribution to a non-symmetric neighborhood, as compared to Floyd & Steinberg, recognizes that the behavior of error passing is dynamic. Thus, while the new weights are non-symmetric about pixel X, they propagate error more evenly about the axis through pixel (n, l) and pixel (n, l+1).
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)

ditherShiau2

public static int[] ditherShiau2(int[] ai,
                                 int i,
                                 int j,
                                 int k,
                                 java.awt.Color color,
                                 boolean flag)

Shiau et al pattern 2:

 - - - X 8
 2 0 2 4 0
 

The present proposal improves the output of the Shiau et al distribution scheme in some circumstances, and improves the efficiency of the error diffusion process, by eliminating one of the distribution neighbors, thereby reducing the number of neighboring pixels that receive error. In addition, by dividing the error into eight parts, all of which are factors of 2 as in the above distribution, this scheme requires one less shift operation in hardware and some software implementations of error diffusion.
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)

threshold

public static int[] threshold(int[] ai,
                              int i,
                              int j,
                              int k,
                              java.awt.Color color,
                              boolean flag)
Transforms image into 2 color black & white by using param k as threshold value.
Parameters:
ai - the pixels of the original image in one dimensional array of RGB values
i - the width of the image
j - the height of the image
k - the threshold value (0-255) RGB
color - the background color of the resulting image
flag - if this is true, result is inverted
Returns:
RGB pixel values of the result image (black & white, 2 colors)

createImage

public static java.awt.Image createImage(int[] ai,
                                         int i,
                                         int j)
Creates java.awt.Image object based on pixel values.
Parameters:
ai - the image pixel array
i - the width of the image
j - the height of the image

encodeBytes

public static final void encodeBytes(java.io.OutputStream o,
                                     int i)
                              throws java.io.IOException
Transforms bytes into Wireless Bitmap format. Mainly an internal help method.
Parameters:
o - the stream the result should be written to. This should be buffered.
i - this is the width or height of the image
Throws:
java.io.IOException - occurs if it is not possible to write to the OutputStream
See Also:
encodePixels(java.io.OutputStream, java.awt.Image)

decodeBytes

public static int decodeBytes(java.io.InputStream is)
                       throws java.io.IOException
Reads one Multibyte Integer from the InputStream. Each int is coded as set of octets in the stream. The most significant bit of each octet is either 0 or 1 where 1 says that there are more octets which belong to this multibyte int and 0 says that this is the last octet. The remaining 7 bits depict portion of the int.
E.g. decimal value 400 would be in binary = 110010000 and is multibyte integer = 1000001100010000
Parameters:
is - the InputStream to read the value from
Returns:
int value which was parsed as multibyte
Throws:
java.io.IOException - occurs of InputStream cannot be read or it is broken
See Also:
decodePixels(java.io.InputStream)

decodePixels

public static int[] decodePixels(java.io.InputStream is)
                          throws java.io.IOException
Reads a WBMP image from the InputStream and returns the result as one dimensional int array or RGB values. This method has been optimized for maximum performance.
Parameters:
is - the InputStream containing the WBMP encoding
Returns:
int array of RGB values which represent the image that was scanned
Throws:
java.io.IOException - occurs of InputStream cannot be read or it is broken
See Also:
decodeBytes(java.io.InputStream)

encodePixels

public final void encodePixels(java.io.OutputStream o,
                               java.awt.Image image)
                        throws java.io.IOException,
                               java.lang.InterruptedException
Encodes java.awt.Image to Wireless Bitmap.
Parameters:
o - the stream the result should be written to. This should be buffered.
image - reference to the original image to be converted
Throws:
java.io.IOException - occurs if it is not possible to write to the OutputStream
See Also:
encodeBytes(java.io.OutputStream, int)

encodePixels

public static final void encodePixels(java.io.OutputStream o,
                                      int[] image,
                                      int width,
                                      int height)
                               throws java.io.IOException
Encodes image RGB pixels to Wireless Bitmap.
Parameters:
o - the stream the result should be written to. This should be buffered.
image - RGB pixel values of the image
width - image width
height - image height
Throws:
java.io.IOException - occurs if it is not possible to write to the OutputStream
See Also:
encodeBytes(java.io.OutputStream, int)

getScaledInstance

public final java.awt.Image getScaledInstance(java.awt.Image img,
                                              int w,
                                              int h,
                                              int mode)
Scales supplied image according to scaling mode. This is useful to shorten the code and reduce the memory strain in your head.
Parameters:
img - the image to be scaled
w - width
h - height
mode - operation mode, see all SCALE_-fields in this object
Returns:
Image the resulting image

grabPixels

public final int[] grabPixels(java.awt.Image img)
                       throws java.lang.InterruptedException
Transforms java.awt.Image into an array of pixels

getImage

public final java.awt.Image getImage(java.net.URL url)
                              throws java.lang.InterruptedException,
                                     java.net.MalformedURLException,
                                     java.io.IOException
Reads an image from the given URL

readURL

public static final byte[] readURL(java.net.URL addr)
                            throws java.net.MalformedURLException,
                                   java.io.IOException
Reads contents of certain URL as buffered stream.
Parameters:
addr - the URL to be read
Returns:
the URL contents as byte array
Throws:
MalformedURLException - occurs if the URL is invalid or unreachable
java.io.IOException - occurs if the stream suddenly breaks or is corrupted

processImage

public final void processImage(java.io.OutputStream o,
                               java.util.Properties prop)
                        throws java.io.IOException,
                               java.net.MalformedURLException,
                               java.lang.InterruptedException
Processes all arguments given in Properties container, reads an image from defined URL, does selected image processing tricks and writes the result to supplied outputstream.
Parameters:
o - stream to write the result to. This MUST be buffered in order to get good performance.
prop - Properties bag containing all variables necessary to do the processing. Equal to command line params.

main

public static void main(java.lang.String[] arg)
This method is called when the object is invoked from command line.
Parameters:
arg - an array containing parameters received from the command line arguments.