📄 image.java
字号:
/*
* Created on 2004-12-21 by Tianlei
* version 1.0.0.3
* since MIDP1.0
*
* ģ��J2ME��Image��,ͨ����java.awt.Image����һ�����4ʵ��
* 2.0�İ���Щûʵ��
* TODO �Ժ�����õ�����Ŀǰûʵ�ֵ�MIDP2.0�Ľӿ�,����ʵ����4
*/
package javax.microedition.lcdui;
import a.a.a.midp.lcdui.*;
import java.io.*;
/**
* @author Tianlei
* @version 1.0.0.3
* @since MIDP1.0
*
* ģ��J2ME��Image��,ͨ����java.awt.Image����һ�����4ʵ��
* 2.0�İ���Щûʵ��
* TODO �Ժ�����õ�����Ŀǰûʵ�ֵ�MIDP2.0�Ľӿ�,����ʵ����4
*/
public class Image {
/**
* ʵ���������õ�java.awt.Image����
*/
private BQImage instance;
public Image(BQImage image) {
this.instance = image;
this.instance.setShell(this);
}
/**
* ��imageData�����д���һ��Image����
*
* @param imageData
* ��ij�ֿ��Խ���ĸ�ʽ���������ֵ����
* @param imageOffset
* ��ʼλ��
* @param imageLength
* ��ݳ���
* @return ���imageData������offset��ʼ,length������ݹ����Image����
* @since MIDP1.0
*/
public static Image createImage(byte[] imageData, int imageOffset,
int imageLength) {
BQImage img=BQImage.createImage(imageData,imageOffset,imageLength);
if(img!=null){
return new Image(img);
}
return null;
}
/**
* ��source�����д���һ��ɱ��Image
*
* @param source
* ԴImage����
* @return ������4�IJ��ɱ�Image����
* @since MIDP1.0
*/
public static Image createImage(Image source) {
BQImage img=BQImage.createImage(source.getBQImage());
if(img!=null){
return new Image(img);
}
return null;
}
/**
* ��iamge�д�����һ��ɱ��image
*
* @param image
* ��Ҫ����image�Ķ���,��ΪԴ
* @param x
* Ŀ���������Ͻ���image�е�xƫ��
* @param y
* Ŀ���������Ͻ���image�е�yƫ��
* @param width
* Ҫ������image�Ŀ��
* @param height
* Ҫ������image�ĸ߶�
* @param transform
* ��ԭ4���ǿ�image�Ƿ������ת
* @see Sprite����
* @return image��x,y�㿪ʼ,width��,height�ߵ�һ����transform��ת�����ͼ
* @since MIDP2.0
*/
public static Image createImage(Image image, int x, int y, int width,
int height, int transform) {
BQImage img=BQImage.createImage(image.getBQImage(),x,y,width,height,transform);
if(img!=null){
return new Image(img);
}
return null;
}
/**
* ��istream���д���һ��ɸı��image
*
* @param istream
* ��ij�ֿ��Ա�����ĸ�ʽ����ݵ���
* @return ���istream�е����,������4�IJ��ɱ��Image����
* @throws IOException
* ������쳣,�׳�
* @since MIDP1.0
*/
public static Image createImage(InputStream istream) throws IOException {
BQImage img=BQImage.createImage(istream);
if(img!=null){
return new Image(img);
}
return null;
}
/**
* ����һ��ɸı��image����
*
* @param width
* ������iamge�Ŀ��
* @param height
* ������iamge�ĸ߶�
* @return ������4�Ŀɱ��Image����
* @since MIDP1.0
*/
public static Image createImage(int width, int height) {
BQImage img=BQImage.createImage(width,height);
if(img!=null){
return new Image(img);
}
return null;
}
/**
* ��nameָ�����ļ��д���һ��image
*
* @param name
* ���
* @return ���ļ��д�����4�IJ��ɱ��Image����
* @throws java.io.IOException
* ������쳣,�׳�
* @since MIDP1.0
*/
public static Image createImage(String name) throws java.io.IOException {
BQImage img=BQImage.createImage(name);
if(img!=null){
return new Image(img);
}
return null;
}
public static Image createRGBImage(int[] rgb,
int width,
int height,
boolean processAlpha){
BQImage img=BQImage.createRGBImage(rgb,width,height,processAlpha);
if(img!=null){
return new Image(img);
}
return null;
}
/**
* ����image�ǿɸı��,�õ����������image�ϻ�ͼ��Graphics �����׳��쳣
*
* @since MIDP1.0
*/
public Graphics getGraphics() {
if (instance.isMutable()) {
return new Graphics(instance.getGraphics());
} else{
throw new IllegalStateException();
}
}
public void getRGB(int[] rgbData, int offset, int scanlength,
int x, int y, int width, int height){
instance.getRGB(rgbData,offset,scanlength,x,y,width,height);
}
/** �õ���Image����ĸ�
*
* @return ��Image����ĸ�
* @since MIDP1.0
*/
public int getHeight() {
return instance.getHeight();
}
/**
* �õ���Image����Ŀ�
*
* @return ��Image����Ŀ�
* @since MIDP1.0
*/
public int getWidth() {
return instance.getWidth();
}
public BQImage getBQImage() {
return instance;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -