Package lejos.hardware.lcd
Class Image
- java.lang.Object
-
- lejos.hardware.lcd.Image
-
- All Implemented Interfaces:
java.io.Serializable
public class Image extends java.lang.Object implements java.io.SerializableProvides support for in memory images. The format of the bitmap is in standard leJOS format (so aligned for use on EV3 LCD display). There is one bit per pixel. The pixels are packed into bytes with each byte spanning 8 scan lines. The least significant bit of each byte is the pixel for the top most scan line, the most significant bit is the 8th scan line. Values of 1 represent black. 0 white. This class implements a sub set of the standard lcdui Image class. Only mutable images are supported and the ARGB methods are not available. TODO: This file needs to be updated to match the EV3 image format.- Author:
- Andre Nijholt & Andy Shaw
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Image(int width, int height, byte[] data)Create an image using an already existing byte array.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImagecreateImage(int width, int height)Create ablank image of the requested size.static ImagecreateImage(java.io.InputStream s)Read image from file.static ImagecreateImage(Image image, int x, int y, int w, int h, int transform)Creates a new image based upon the transformed region of another imagebyte[]getData()Return the byte array used to hold the image data.GraphicsLCDgetGraphics()Returns a graphics object that can be used to draw to the image.intgetHeight()return the height of the image.intgetWidth()Return the width of the image.
-
-
-
Constructor Detail
-
Image
public Image(int width, int height, byte[] data)Create an image using an already existing byte array. The byte array is used to store the image data. The array may already be initialized with image data.
Note: This is a non standard constructor.- Parameters:
width- width of the imageheight- height of the imagedata- The byte array to be used for image store/
-
-
Method Detail
-
createImage
public static Image createImage(int width, int height)
Create ablank image of the requested size.- Parameters:
width-height-- Returns:
- Returns the new image.
-
createImage
public static Image createImage(java.io.InputStream s) throws java.io.IOException
Read image from file. An image file has the following format:1st byte - 4th byte 5th byte - 8th byte 9th byte 10th byte .... image-width (int) image-height (int) 0x00(image data delimit)byte image data.... For example:
After a file with content
was read, this method will return an object which is equivalent towidth (int) height (int) delimit byte data 00 00 00 03 00 00 00 05 00 00 02 1f new Image(3, 5, new byte[] {(byte)0x00, (byte)0x02, (byte)0x1f})- Parameters:
s- The input stream for the image file.- Returns:
- an ev3 image object.
- Throws:
java.io.IOException- if an input or output error occurs or file format is not correct.- See Also:
Image,Image(int, int, byte[])
-
createImage
public static Image createImage(Image image, int x, int y, int w, int h, int transform)
Creates a new image based upon the transformed region of another image- Parameters:
image- Source imagex- x co-ordinate of the source regiony- y co-ordinate of the source regionw- width of the source regionh- height of the source regiontransform- Transform to be applied- Returns:
- New image
-
getWidth
public int getWidth()
Return the width of the image.- Returns:
- Image width
-
getHeight
public int getHeight()
return the height of the image.- Returns:
- image height
-
getData
public byte[] getData()
Return the byte array used to hold the image data.
Note: This is a non standard method.- Returns:
- The image byte array.
-
getGraphics
public GraphicsLCD getGraphics()
Returns a graphics object that can be used to draw to the image.- Returns:
- graphics object.
- See Also:
GraphicsLCD
-
-