當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。