com.nokia.mid.ui
Class DirectUtils

java.lang.Object
  extended by com.nokia.mid.ui.DirectUtils

public class DirectUtils
extends java.lang.Object

This class is a placeholder for utility methods. It contains methods for converting standard lcdui classes to Nokia UI classes and vice versa, and a method for creating images that are empty with pixels either transparent or colored, and creating mutable images from encoded image byte arrays.


Constructor Summary
DirectUtils()
           
 
Method Summary
static Image createImage(byte[] imageData, int imageOffset, int imageLength)
          Creates a mutable image that is decoded from the data stored in the specified byte array at the specified offset and length.
static Image createImage(int width, int height, int argb)
          The method will return a newly created mutable Image with the specified dimension and all the pixels of the image defined by the specified ARGB color.
static DirectGraphics getDirectGraphics(Graphics g)
          Converts standard javax.microedition.lcdui.Graphics to DirectGraphics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectUtils

public DirectUtils()
Method Detail

getDirectGraphics

public static DirectGraphics getDirectGraphics(Graphics g)
Converts standard javax.microedition.lcdui.Graphics to DirectGraphics. The returned object refers to the same graphics context. This means that calling draw operations or changing the state, for example, drawing color etc., via the original Graphics reference affect the DirectGraphics object, and vice versa. Note that even though the graphics context that the DirectGraphics and Graphics refer to is the same, the object reference returned from this method may or may not be equal compared to the Graphics reference passed to this method. This means that purely casting Graphics object (g) passed in paint method of lcdui Canvas to DirectGraphics may not work ok. The safest way is to always do the conversion with this method.

Parameters:
g - Graphics object for which DirectGraphics should be returned
Returns:
the DirectGraphics object based on Graphics

createImage

public static Image createImage(byte[] imageData,
                                int imageOffset,
                                int imageLength)
Creates a mutable image that is decoded from the data stored in the specified byte array at the specified offset and length. The data must be in a self-identifying image file format supported by the implementation, e.g., PNG. Note that the semantics of this method are exactly the same as Image.createImage(byte[],int,int) except that the returned image is mutable.

Parameters:
imageData - the array of image data in a supported image format
imageOffset - the offset of the start of the data in the array
imageLength - the length of the data in the array
Returns:
the created mutable image

createImage

public static Image createImage(int width,
                                int height,
                                int argb)
The method will return a newly created mutable Image with the specified dimension and all the pixels of the image defined by the specified ARGB color. The color can contain alpha channel transparency information.

Parameters:
width - the width of the new image, in pixels
height - the height of the new image, in pixels
argb - the initial color for image
Note: This is argb color, but alpha channel is currently not supported by this emulation.
Returns:
the created image


Copyright © 2001-2010 MicroEmulator Team. All Rights Reserved.