FileDocCategorySizeDatePackage
ScreenGrabber.javaAPI DocJ2ME MIDP 2.02526Thu Nov 07 12:02:22 GMT 2002com.sun.midp.lcdui

ScreenGrabber

public class ScreenGrabber extends Object
ScreenGrabber is a class that returns a hash of the pixels on the MIDP display drawing region. If two screens have the same pixels and color depth, the result of a getScreenDigest call on each screen should be identical. This class is designed to automate UI testing, allowing a screen capture of a current test run to be compared against the stored value of a previous run.

Fields Summary
private static ScreenGrabber
sg
A singleton ScreenGrabber instance is used to save space.
Constructors Summary
private ScreenGrabber()
default constructor

Methods Summary
public byte[]getData()
This method returns a digest of the pixelmap of the current MIDP display area. For now, this is defined as the drawing area, as well as the status bar at the top of the screen and the area of the screen devoted to scroll arrows and softkey menu labels. It does not digest the entire MIDP window, i.e. the handset graphics. WARNING: Minimal safety checks are done within the native code called by this method to determine that the native display data has been initialized. This method should only be called from within a MIDlet with a valid Display instance.

return
A digest of the current screen's pixmap. Returns null on error.


	byte[] data = new byte[4];

	int digest = sysGetScreenDigest();
	if (digest == 0) 
	    return null;

	data[0] = (byte)((digest >> 24) & 0xff);
	data[1] = (byte)((digest >> 16) & 0xff);
	data[2] = (byte)((digest >> 8) & 0xff);
	data[3] = (byte)(digest & 0xff);

	return data;
    
public static com.sun.midp.lcdui.ScreenGrabbergetInstance()
Use to obtain a reference to a ScreenGrabber instance.

return
a ScreenGrabber instance

	if (sg == null)
	    sg = new ScreenGrabber();
	return sg;
    
private static native intsysGetScreenDigest()
Native method sysGetScreenDigest is defined in file screenGrabber.c

return
A CRC32 digest of the MIDP display area. Returns 0 if an error occurs