View Javadoc

1   /*
2    * MicroEmulator
3    * Copyright (C) 2001 Bartek Teodorczyk <barteo@barteo.net>
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   *
19   * Contributor(s):
20   *   3GLab
21   *   Andres Navarro
22   */
23  
24  package javax.microedition.lcdui;
25  import java.io.IOException;
26  import org.microemu.device.DeviceFactory;
27  
28  
29  public class Image
30  {
31  
32  //    TODO there should be a public constructors
33  //    private Image() {
34  //        
35  //    }
36      
37  	public static Image createImage(int width, int height)
38  	{
39  		if (width <= 0 || height <= 0) {
40  			throw new IllegalArgumentException();
41  		}
42  		return DeviceFactory.getDevice().getDeviceDisplay().createImage(width, height);
43  	}
44  
45  	public static Image createImage(String name) throws IOException
46  	{
47  		return DeviceFactory.getDevice().getDeviceDisplay().createImage(name);
48  	}
49  
50  	public static Image createImage(Image source)
51  	{
52  		return DeviceFactory.getDevice().getDeviceDisplay().createImage(source);
53  	}
54  
55  	public static Image createImage(byte[] imageData, int imageOffset, int imageLength)
56  	{
57  		return DeviceFactory.getDevice().getDeviceDisplay().createImage(imageData, imageOffset, imageLength);
58  	}
59  
60  	public Graphics getGraphics()
61  	{
62  		throw new IllegalStateException("Image is immutable");
63  	}
64  
65          public int getHeight()
66  	{
67  		return 0;
68  	}
69  
70  	public int getWidth()
71  	{
72  		return 0;
73  	}
74  
75  	public boolean isMutable()
76  	{
77  		return false;
78  	}
79  
80  	// Andres Navarro
81  	// MIDP2 Methods
82  
83          public void getRGB(int []argb, int offset, int scanlenght,
84  			int x, int y, int width, int height) {
85  		// Implemented in Immutable and Mutable image
86  	}
87  
88          public static Image createImage(java.io.InputStream stream) throws IOException {
89              return DeviceFactory.getDevice().getDeviceDisplay().createImage(stream);
90          }
91          
92          public static Image createImage(Image image, int x, int y, 
93                  int width, int height, int transform) {
94              return DeviceFactory.getDevice().getDeviceDisplay().createImage(
95                      image, x, y, width, height, transform);
96          }
97          
98          public static Image createRGBImage(int[] rgb, int width, int height, 
99                  boolean processAlpha) {
100             return DeviceFactory.getDevice().getDeviceDisplay().createRGBImage(rgb, 
101                     width, height, processAlpha);
102         }
103 	// Andres Navarro
104 }