当前位置: 首页>>代码示例>>Java>>正文


Java Image类代码示例

本文整理汇总了Java中lejos.hardware.lcd.Image的典型用法代码示例。如果您正苦于以下问题:Java Image类的具体用法?Java Image怎么用?Java Image使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Image类属于lejos.hardware.lcd包,在下文中一共展示了Image类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setItems

import lejos.hardware.lcd.Image; //导入依赖的package包/类
/**
 * set the array of items to be displayed
 * @param items
 */
public void setItems(String[] items,String[] icons)
{
	super.setItems(items);
	if (icons == null){
		_icons = null;
		return;
	}
	_icons = new byte[icons.length][];
    _iconImages = new Image[icons.length];
	for(int i = 0; i < icons.length;i++){
		if (icons[i] != null) {
			_icons[i] = Utils.stringToBytes8(icons[i]);
			_iconImages[i] = new Image(32,32,_icons[i]);
		}
	}
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:21,代码来源:GraphicMenu.java

示例2: loadImage

import lejos.hardware.lcd.Image; //导入依赖的package包/类
/**
 * Load LEGO RGF file format.
 * <p>
 * Description of the format:
 * <ul>
 * <li>1st byte: width (max 180)</li>
 * <li>2nd byte: height (max 128)</li>
 * <li>image data: line by line, 1 line is stored on a full number of byte (so 180 => 23 bytes, some of the bits of the last bytes are not used)</li>
 * </ul>
 * </p>
 */
@ScriptApi(versionAdded = "TBD", isIncubating = true)
public SimpleEV3Image loadImage(String name) throws EV3ScriptException {
  if (name == null) {
    throw new EV3ScriptException(EV3ScriptException.CANT_READ_FILE, MapBuilder.buildHashMap("filename", String.valueOf(name)).put("error", "name is null").build());
  }

  try (DataInputStream in = new DataInputStream(new FileInputStream(name))) {
    int width = in.readUnsignedByte();
    int height = in.readUnsignedByte();
    byte[] ev3ImageData = new byte[(width + 7) / 8 * height]; // + 7 in order to have a full number of bytes
    if (in.read(ev3ImageData) != ev3ImageData.length) {
      throw new EV3ScriptException(EV3ScriptException.IMAGE_CORRUPTED, MapBuilder.buildHashMap("filename", name).build());
    }
    return new SimpleEV3Image(new Image(width, height, ev3ImageData));
  } catch (IOException e) {
    throw new EV3ScriptException(EV3ScriptException.CANT_READ_FILE, MapBuilder.buildHashMap("filename", name).put("error", e.toString()).build());
  }
}
 
开发者ID:jbenech,项目名称:gnikrap,代码行数:30,代码来源:SimpleEV3Screen.java

示例3: drawIconAtTick

import lejos.hardware.lcd.Image; //导入依赖的package包/类
/**
 * Helper method to draw a menu icon at a variable location (determined by tick) between two icon positions.
 * @param sID -1 to 6
 * @param eID -1 to 6
 * @param tick #0-10
 */
protected void drawIconAtTick(Image iconImage,int sID, int eID,int tick){
	// Determine sID Coordinates
	int fx = X_AREA + X_OFFSET+sID*X_WIDTH;
	int fy = yArea + Y_OFFSET+(Math.abs(sID-2)*Y_WIDTH);
	// Determine eID Coordinates
	int sx = X_AREA + X_OFFSET+eID*X_WIDTH;
	int sy = yArea + Y_OFFSET+(Math.abs(eID-2)*Y_WIDTH);
	// Determine Icon Offset from sID
	int ix = (int) (((sx-fx)/10.0)*tick);
	int iy = (int) (((sy-fy)/10.0)*tick);
	// Paint Icon
	g.drawRegion(iconImage, 0, 0, 32, 32, 0,fx+ix,fy+iy,0);
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:20,代码来源:GraphicMenu.java

示例4: decodeRgfImage

import lejos.hardware.lcd.Image; //导入依赖的package包/类
private SimpleEV3Image decodeRgfImage(byte[] imageData) throws EV3ScriptException {
  if ((imageData != null) && (imageData.length > 2)) {
    int width = imageData[0] & 0xFF; // TODO: JDK8, replace by Byte.toUnsignedInt
    int height = imageData[1] & 0xFF;
    byte[] ev3ImageData = new byte[(width + 7) / 8 * height]; // + 7 in order to have a full number of bytes
    if (imageData.length >= ev3ImageData.length + 2) {
      System.arraycopy(imageData, 2, ev3ImageData, 0, ev3ImageData.length);
      return new SimpleEV3Image(new Image(width, height, ev3ImageData));
    }
    throw new EV3ScriptException(EV3ScriptException.CANT_DECODE_IMAGE_INVALID_DATA_SIZE, MapBuilder.buildHashMap("width", String.valueOf(width)).put("height", String.valueOf(height)).build());
  }
  throw new EV3ScriptException(EV3ScriptException.CANT_DECODE_IMAGE, MapBuilder.buildHashMap("reason", "Binary data is invalid").build());
}
 
开发者ID:jbenech,项目名称:gnikrap,代码行数:14,代码来源:SimpleEV3Screen.java

示例5: load

import lejos.hardware.lcd.Image; //导入依赖的package包/类
public static Image load(String file) {
	try {
		return Image.createImage(new FileInputStream(new File(file)));
	}catch(Exception e) {
		return null;
	}
}
 
开发者ID:MisaZhu,项目名称:EV3GUI.leJOS,代码行数:8,代码来源:ImageLoader.java

示例6: setImage

import lejos.hardware.lcd.Image; //导入依赖的package包/类
/**
 * Set image of the view;
 */
public void setImage(Image img) {
	this.image = img;
	
	if(img == null)
		resizeTo(0, 0);
	else
		resizeTo(image.getWidth(), image.getWidth());
}
 
开发者ID:MisaZhu,项目名称:EV3GUI.leJOS,代码行数:12,代码来源:ImageButton.java

示例7: SimpleEV3Image

import lejos.hardware.lcd.Image; //导入依赖的package包/类
SimpleEV3Image(Image img) {
  image = img;
}
 
开发者ID:jbenech,项目名称:gnikrap,代码行数:4,代码来源:SimpleEV3Screen.java

示例8: getImage

import lejos.hardware.lcd.Image; //导入依赖的package包/类
Image getImage() {
  return image;
}
 
开发者ID:jbenech,项目名称:gnikrap,代码行数:4,代码来源:SimpleEV3Screen.java

示例9: drawImage

import lejos.hardware.lcd.Image; //导入依赖的package包/类
protected void drawImage(GraphicsLCD g, Image img, int x, int y, int anchor) {
	g.drawImage(img, x+getAX(), y+getAY(), anchor);
}
 
开发者ID:MisaZhu,项目名称:EV3GUI.leJOS,代码行数:4,代码来源:Canvas.java

示例10: drawPicture

import lejos.hardware.lcd.Image; //导入依赖的package包/类
/**
 * Draw picture on the display of the brick.<br>
 * <br>
 * Client must provide the picture that should be displayed and the location of the screen (<b>x</b> and <b>y</b> coordinate).
 * See {@link ShowPicture} for all possible pictures that can be displayed.
 *
 * @param picture to be displayed
 * @param x coordinate of the display
 * @param y coordinate of the display
 */
public void drawPicture(String picture, float x, float y) {
    Image image = new Image(178, 128, Utils.stringToBytes8(picture));
    this.brick.getGraphicsLCD().drawImage(image, (int) x, (int) y, 0);
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:15,代码来源:Hal.java


注:本文中的lejos.hardware.lcd.Image类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。