本文整理汇总了Java中javax.microedition.lcdui.Image类的典型用法代码示例。如果您正苦于以下问题:Java Image类的具体用法?Java Image怎么用?Java Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Image类属于javax.microedition.lcdui包,在下文中一共展示了Image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCategoryImage
import javax.microedition.lcdui.Image; //导入依赖的package包/类
private Image getCategoryImage(String id) {
Image image = null;
String path;
if(id.equals("Family"))
path = "/family.png";
else if(id.equals("Work"))
path = "/work.png";
else
path = "/school.png";
try {
image = Image.createImage(path);
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
示例2: processImage
import javax.microedition.lcdui.Image; //导入依赖的package包/类
public IAnswerData processImage(Image image)
throws ImageProcessingException {
MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(
image);
Reader reader = new QRCodeReader();
Hashtable hints = new Hashtable();
// hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
try {
Result result = reader.decode(source, hints);
if ((result != null) && (result.getText() != null)) {
String scannedCode = result.getText();
return new StringData(scannedCode);
} else {
throw new ImageProcessingException("Barcode scanning failed");
}
} catch (ReaderException re) {
throw new ImageProcessingException("Barcode scanning failed");
}
}
示例3: getListRowImage
import javax.microedition.lcdui.Image; //导入依赖的package包/类
private Image getListRowImage(int priority){
Image image = null;
String path;
if (priority < 3)
path = "/low.png";
else if (priority < 7)
path = "/normal.png";
else
path = "/important.png";
try {
image = Image.createImage(path);
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
示例4: setImage
import javax.microedition.lcdui.Image; //导入依赖的package包/类
public void setImage(final Image image) {
activity.post(new Runnable() {
public void run() {
if (image == null) {
imageView.setVisibility(GONE);
imageView.setImageBitmap(null);
} else {
imageView.setVisibility(VISIBLE);
if (image.isMutable()) {
imageView.setImageBitmap(((AndroidMutableImage) image).getBitmap());
} else {
imageView.setImageBitmap(((AndroidImmutableImage) image).getBitmap());
}
}
}
});
}
示例5: createRGBImage
import javax.microedition.lcdui.Image; //导入依赖的package包/类
public Image createRGBImage(int[] rgb, int width, int height, boolean processAlpha) {
if (rgb == null)
throw new NullPointerException();
if (width <= 0 || height <= 0)
throw new IllegalArgumentException();
// TODO processAlpha is not handled natively, check whether we need to create copy of rgb
int[] newrgb = rgb;
if (!processAlpha) {
newrgb = new int[rgb.length];
for (int i = 0; i < rgb.length; i++) {
newrgb[i] = (0x00ffffff & rgb[i]) | 0xff000000;
}
}
return new AndroidImmutableImage(Bitmap.createBitmap(newrgb, width, height, Bitmap.Config.ARGB_8888));
}
示例6: init
import javax.microedition.lcdui.Image; //导入依赖的package包/类
/**
* ���������ʼ��
* @param score ����
* @throws IOException
*/
public void init(int score) throws IOException
{
/*��Ϸ����:42,23
gameover:42,38
������:38,58
����ͼƬ:45,107*/
gameovertip=Image.createImage("/gameovertip.GIF");
endtip=Image.createImage("/endtip.GIF");
scorebg=Image.createImage("/scorebg.GIF");
gameoverbg=Image.createImage("/gameoverbg.GIF");
Graphics gra=super.getGraphics();
gra.setColor(255, 255, 255);
gra.fillRect(0, 0, sw, sh);
gra.drawImage(endtip, 42, 23,Graphics.LEFT|Graphics.TOP);
gra.drawImage(gameovertip, 42, 38,Graphics.LEFT|Graphics.TOP);
gra.drawImage(scorebg, 38, 58,Graphics.LEFT|Graphics.TOP);
gra.drawImage(gameoverbg, 45, 107,Graphics.LEFT|Graphics.TOP);
flushGraphics();
repaint();
super.ShowScore(score);
System.out.println("��������������");
}
示例7: getImageItem
import javax.microedition.lcdui.Image; //导入依赖的package包/类
public static ImageItem getImageItem(FormEntryPrompt fep,int height,int width) {
String IaltText;
IaltText = fep.getShortText();
Image im = ImageUtils.getImage(fep.getImageText());
if(im!=null){
//scale
int[] newDimension = ImageUtils.getNewDimensions(im, height, width);
if(newDimension[0] != height || newDimension[1] != width) {
im = ImageUtils.resizeImage(im, newDimension[1], newDimension[0]);
}
ImageItem imItem = new ImageItem(null,im, ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_VCENTER, IaltText);
imItem.setLayout(Item.LAYOUT_CENTER);
return imItem;
}else{
return null;
}
}
示例8: raiseAlert
import javax.microedition.lcdui.Image; //导入依赖的package包/类
private void raiseAlert() {
if(alertTitle != null || msg != null) {
Runnable r = new Runnable() {
String at = alertTitle;
String m = msg;
Image alIm = alertImage;
String aURI = audioURI;
long time = new Date().getTime();
public void run() {
J2MEDisplay.showError(at, m, alIm);
if(aURI != null) {
MediaUtils.playAudio(aURI);
}
}
};
new HandledThread(r).start();
alertTitle = null;
msg = null;
alertImage = null;
audioURI = null;
}
}
示例9: getNewDimensions
import javax.microedition.lcdui.Image; //导入依赖的package包/类
/**
* Used for scaling an image. Checks to see if an image is bigger than the
* provided dimensions, and provides new dimensions such that the image
* scales to fit within the dimensions given. If the image is smaller (in both width and height)
* than the given dimensions, returns the original image dimensions.
* @param source image
* @return int array [height, width]
*/
public static int[] getNewDimensions(Image im, int height, int width){
double scalef = im.getHeight()*1.0/im.getWidth();
int w = 1;
int h = 1;
if(im.getHeight() > height && im.getWidth() <= width){ //height is overbounds
h = height;
w = (int)Math.floor(h/scalef);
}else if (im.getHeight() <= height && im.getWidth() > width){ //width is overbouds
w = width;
h = (int)Math.floor(w*scalef);
}else if (im.getHeight() > height && im.getWidth() > width){ //both are overbounds
if(height > width){ //screen width is smaller dimension, so reduce im width and scale height
w = width;
h = (int)Math.floor(w*scalef);
}else if(height <= width){ //reduce height and scale width
h = height;
w = (int)Math.floor(h/scalef);
}
}else{
h = im.getHeight();
w = im.getWidth();
}
int[] dim = {h,w};
return dim;
}
示例10: CBitmap
import javax.microedition.lcdui.Image; //导入依赖的package包/类
CBitmap(Image img) {
Larg = img.getWidth();
Alt = img.getHeight();
raw = new int[Larg*Alt];
img.getRGB(raw, 0, Larg, 0, 0, Larg, Alt);
PMCor = new Cor[Alt][Larg];
for (int y = 0; y < Alt; y++) {
for (int x = 0; x < Larg; x++) {
PMCor[y][x] = new Cor(raw[x+y*Larg]);
}
}
}
示例11: CTonsCinza
import javax.microedition.lcdui.Image; //导入依赖的package包/类
/**
* Constrói um CTonsCinza a partir de uma Image
*/
CTonsCinza(Image img) {
Larg = img.getWidth();
Alt = img.getHeight();
TonsCinza = new int[Alt][Larg];
raw = new int[Larg*Alt];
img.getRGB(raw, 0, Larg, 0, 0, Larg, Alt);
for (int y = 0; y < Alt; y++) {
for (int x = 0; x < Larg; x++) {
pixel=raw[x+y*Larg];
azul=pixel & 0x0000FF;
verde=(pixel & 0xFF00) >> 8;
vermelho=(pixel & 0xFF0000) >> 16;
pixel=azul*11+verde*59+vermelho*30;
pixel*=0.01;
TonsCinza[y][x] = pixel;
}
}
}
示例12: paint
import javax.microedition.lcdui.Image; //导入依赖的package包/类
/**
* @see javax.microedition.lcdui.CustomItem#paint(javax.microedition.lcdui.Graphics, int, int)
*/
protected void paint(Graphics g, int w, int h) {
// Draw the title text
Util.drawStringCenteredAndTruncated(g, "Rating:", font, 0, 0, w, font.getHeight(),
Graphics.TOP | Graphics.LEFT );
for(int i = 0; i < zones.length; i++) {
GestureInteractiveZone zone = zones[i];
Image image = null;
// Determine whether a full or empty star needs to be drawn
if(i < rating){
image = starImgFilled;
} else{
image = starImgEmpty;
}
// Draw a star image
Util.drawImageCentered(g, image, zone.getX(), zone.getY(),
zone.getWidth(), zone.getHeight());
}
}
示例13: SaveImage
import javax.microedition.lcdui.Image; //导入依赖的package包/类
/**
* Retorna uma Image gerada a partir do CTonsCinza
*/
Image SaveImage() {
int[] rawRGB = new int[Larg*Alt];
int ponteiro = 0;
for (int y = 0; y < Alt; y++) {
for (int x = 0; x < Larg; x++) {
rawRGB[ponteiro] = TonsCinza[y][x];
rawRGB[ponteiro] = TonsCinza[y][x];
rawRGB[ponteiro++] = TonsCinza[y][x];
}
}
Image img = Image.createRGBImage(rawRGB, Larg, Alt, false);
return img;
}
示例14: Screen
import javax.microedition.lcdui.Image; //导入依赖的package包/类
public Screen(Display display) {
super();
this.setFullScreenMode(true);
this.parentDisplay = display;
updateOrientation();
try {
// Create background image
this.background = Image.createImage("midlets/blogwriter/images/Background.png");
} catch (IOException e) {
this.parentDisplay.setCurrent(
new Alert("Cannot create graphics."), this);
}
VirtualKeyboard.setVisibilityListener(this);
}
示例15: loadImage
import javax.microedition.lcdui.Image; //导入依赖的package包/类
public Image loadImage(int zoom, int x, int y, int mapSource, boolean goDown, Vector obs) {
String key = mapSource + "/" + zoom + "/" + x + "/" + y;
synchronized(this.keys) {
if(this.isEnabled && this.keys.containsKey(key)) {
int id = Integer.parseInt((String)this.keys.get(key));
try {
byte[] buf = rsImages.getRecord(id);
Image img = Image.createImage(buf, 0, buf.length);
return img;
} catch(RecordStoreException ex) {
ex.printStackTrace();
return this.successor.loadImage(zoom, x, y, mapSource, goDown, obs);
}
} else if(goDown) {
if(obs == null) {
obs = new Vector();
}
obs.addElement(this);
return this.successor.loadImage(zoom, x, y, mapSource, goDown, obs);
} else {
return null;
}
}
}