精华内容
下载资源
问答
  • 本文整理匯總了Java中javax.microedition.lcdui.Image.createImage方法典型用法代碼示例。如果您正苦於以下問題:Java Image.createImage方法具體用法?Java Image.createImage怎麽用?Java Image.createImage...

    本文整理匯總了Java中javax.microedition.lcdui.Image.createImage方法的典型用法代碼示例。如果您正苦於以下問題:Java Image.createImage方法的具體用法?Java Image.createImage怎麽用?Java Image.createImage使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.microedition.lcdui.Image的用法示例。

    在下文中一共展示了Image.createImage方法的24個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

    示例1: getListRowImage

    ​點讚 3

    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;

    }

    開發者ID:NotesTeam,項目名稱:TaskBook-J2ME,代碼行數:18,

    示例2: getCategoryImage

    ​點讚 3

    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;

    }

    開發者ID:NotesTeam,項目名稱:TaskBook-J2ME,代碼行數:19,

    示例3: init

    ​點讚 3

    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("��������������");

    }

    開發者ID:cabbage89,項目名稱:danceGame,代碼行數:29,

    示例4: PaintCanvas

    ​點讚 3

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public PaintCanvas(ApplicationListener listener, boolean isLandscape) {

    this.listener = listener;

    this.isLandscape = isLandscape;

    setFullScreenMode(true);

    width = getWidth();

    height = getHeight();

    if (isLandscape) {

    width = height;

    height = getWidth();

    }

    image = Image.createImage(width, height);

    Graphics g = image.getGraphics();

    graphics = new JecpGraphics(g);

    listener.onStartApp(width, height);

    thread = new DrawingThread();

    thread.keepRunning = true;

    thread.start();

    }

    開發者ID:aNNiMON,項目名稱:JECP,代碼行數:21,

    示例5: GameCanvasLFImpl

    ​點讚 3

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    /**

    * Create new implementation instance for the given GameCanvas

    * @param c GameCanvas instance to create the implementation for

    */

    public GameCanvasLFImpl(GameCanvas c) {

    owner = c;

    graphicsAccess = GameMap.getGraphicsAccess();

    /* IMPL_NOTE: The initial off-screen buffer has the same width

    * and height as the entire screen. Further resizing will not

    * cause memory reallocation until new geometry is bigger than

    * the current one. Screen rotation is one of the cases the

    * reallocation is needed.

    *

    * User can override the methods getWidth() and getHeight() of

    * GameCanvas, so they should not be used for off-screen buffer

    * initial allocation.

    */

    offscreenBuffer = Image.createImage(

    graphicsAccess.getScreenWidth(),

    graphicsAccess.getScreenHeight());

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:24,

    示例6: Screen

    ​點讚 3

    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);

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:17,

    示例7: MyCanvas

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    protected MyCanvas(boolean suppressKeyEvents,boolean hasreadhistory) {

    super(suppressKeyEvents);

    // TODO Auto-generated constructor stub

    try {

    bg=Image.createImage("/bg.GIF");

    oready=Image.createImage("/oready.GIF");

    o1=Image.createImage("/o1.GIF");

    o3=Image.createImage("/o3.GIF");

    o7=Image.createImage("/o7.GIF");

    o9=Image.createImage("/o9.GIF");

    lift=Image.createImage("/lift.GIF");

    liftbg=Image.createImage("/liftbg.GIF");

    pass=Image.createImage("/pass.GIF");

    notpass=Image.createImage("/notpass.GIF");

    passbg=Image.createImage("/passbg.GIF");

    passarea=Image.createImage("/passarea.GIF");

    scorearea=Image.createImage("/scorearea.GIF");

    n0=Image.createImage("/0.GIF");

    n1=Image.createImage("/1.GIF");

    n2=Image.createImage("/2.GIF");

    n3=Image.createImage("/3.GIF");

    n4=Image.createImage("/4.GIF");

    n5=Image.createImage("/5.GIF");

    n6=Image.createImage("/6.GIF");

    n7=Image.createImage("/7.GIF");

    n8=Image.createImage("/8.GIF");

    n9=Image.createImage("/9.GIF");

    ispass=getClass().getResourceAsStream("/pass.wav");

    System.out.println("ͼƬ��������ʼ�����...");

    } catch (IOException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    System.out.println("��ȡͼƬ�쳣");

    }

    init(hasreadhistory);//��ʼ����Ϸ����

    }

    開發者ID:cabbage89,項目名稱:danceGame,代碼行數:40,

    示例8: MyCanvas

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    protected MyCanvas(boolean suppressKeyEvents) {

    super(suppressKeyEvents);

    // TODO Auto-generated constructor stub

    try {

    bg=Image.createImage("/bg.GIF");

    oready=Image.createImage("/oready.GIF");

    o1=Image.createImage("/o1.GIF");

    o3=Image.createImage("/o3.GIF");

    o7=Image.createImage("/o7.GIF");

    o9=Image.createImage("/o9.GIF");

    lift=Image.createImage("/lift.GIF");

    liftbg=Image.createImage("/liftbg.GIF");

    pass=Image.createImage("/pass.GIF");

    notpass=Image.createImage("/notpass.GIF");

    passbg=Image.createImage("/passbg.GIF");

    passarea=Image.createImage("/passarea.GIF");

    scorearea=Image.createImage("/scorearea.GIF");

    n0=Image.createImage("/0.GIF");

    n1=Image.createImage("/1.GIF");

    n2=Image.createImage("/2.GIF");

    n3=Image.createImage("/3.GIF");

    n4=Image.createImage("/4.GIF");

    n5=Image.createImage("/5.GIF");

    n6=Image.createImage("/6.GIF");

    n7=Image.createImage("/7.GIF");

    n8=Image.createImage("/8.GIF");

    n9=Image.createImage("/9.GIF");

    } catch (IOException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    System.out.println("��ȡͼƬ�쳣");

    }

    init();//��ʼ����Ϸ����

    }

    開發者ID:cabbage89,項目名稱:danceGame,代碼行數:36,

    示例9: createImages

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public void createImages()

    {

    try

    {

    active = Image.createImage("/images/button_in(red).png");

    inactive = Image.createImage("/images/button(red).png");

    overin = Image.createImage("/images/button_in_over(red).png");

    overout = Image.createImage("/images/button_over(red).png");

    }

    catch (IOException e) {

    System.out.println("Images not found");

    }

    }

    開發者ID:WernerLDev,項目名稱:Beatmaker,代碼行數:14,

    示例10: getImageItemForScreen

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    protected ImageItem getImageItemForScreen(InputStream is) {

    Image im = null;

    try {

    im = Image.createImage(is);

    } catch(OutOfMemoryError ome ){

    ome.printStackTrace();

    Logger.die("GetImageOOM", new RuntimeException(ome.getMessage()));

    return null;

    } catch (IOException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    Logger.die("GetImageioe", e);

    }

    if(im !=null){

    Logger.log("file", "got an image");

    int height = scrHeight/2;

    int width = scrWidth-16;

    //scale

    int[] newDimension = ImageUtils.getNewDimensions(im, height, width);

    if(newDimension[0] != height || newDimension[1] != width) {

    im = ImageUtils.resizeImage(im, newDimension[1], newDimension[0]);

    }

    Logger.log("file", "resized it");

    ImageItem imItem = new ImageItem(null,im, ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_VCENTER, "Cannot Display Image");

    imItem.setLayout(Item.LAYOUT_CENTER);

    return imItem;

    }else{

    return null;

    }

    }

    開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:34,

    示例11: start

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public synchronized void start()

    {

    //Afbeeldingen maken voor de achtergrond en het pijltje wat aangeeft op welke positie

    //de beatmaker is

    try

    {

    positie = Image.createImage("/images/pijl.png");

    bgimage = Image.createImage("/background.jpg");

    }

    catch (IOException e) {

    System.out.println("Images not found");

    }

    //Knoppen om van instrument te wissen aanmaken

    piano = new InstrumentButton(30,4, g, "piano");

    gitaar = new InstrumentButton(30,130, g, "gitaar");

    drums = new InstrumentButton(30, 260, g, "overig");

    play = new PlayKnop(g, 30, 570);

    //standaard krijg je de piano voor je neus dus deze zetten we aan

    piano.turnOn();

    //DIt is om te controlleren op welke pad we geklikt hebben

    action = new TouchActions();

    createInstruments();

    draw();

    playLoop();

    }

    開發者ID:WernerLDev,項目名稱:Beatmaker,代碼行數:30,

    示例12: start

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public void start() {

    Image image = null;

    try {

    image = Image.createImage(this.picture);

    } catch (Exception e) {

    throw new RuntimeException("Busted splash screen image. Fix this");

    }

    InitializerSplashScreen splashScreen = new InitializerSplashScreen(Display.getInstance(),

    image, backgroundColor, null, messageColor, this);

    J2MEDisplay.setView(splashScreen);

    }

    開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:13,

    示例13: ButtonState

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public ButtonState(CanvasItem owner, String image, int color)

    throws Exception {

    this.owner = owner;

    this.labelColor = color;

    try {

    this.background = Image.createImage(image);

    } catch (IOException e) {

    throw new Exception("Unable to load graphics resources.");

    }

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:11,

    示例14: loadImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    /**

    * Inefficient way to read the image data from the InputStream but

    * necessary for some servers.

    * @param in

    * @param out

    * @return

    * @throws IOException

    */

    private Image loadImage(InputStream in, ByteArrayOutputStream out) throws IOException {

    int b;

    while ((b = in.read()) != -1) {

    out.write(b);

    }

    byte[] buf = out.toByteArray();

    return Image.createImage(buf, 0, buf.length);

    }

    開發者ID:cli,項目名稱:worldmap-classic,代碼行數:17,

    示例15: createImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public static Image createImage(int width, int height, int argb) {

    // Image::createImage(int width, int height)

    // in turn calls

    // ImageDataFactory::createMutableImageData(ImageData data, int width, int height)

    Image image = Image.createImage(width, height);

    setPixels(image, argb);

    return image;

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:9,

    示例16: readImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    /**

    * Reads next frame image

    */

    protected void readImage() {

    ix = readShort(); // (sub)image position & size

    iy = readShort();

    iw = readShort();

    ih = readShort();

    int packed = read();

    lctFlag = (packed & 0x80) != 0; // 1 - local color table flag

    interlace = (packed & 0x40) != 0; // 2 - interlace flag

    // 3 - sort flag

    // 4-5 - reserved

    lctSize = 2 << (packed & 7); // 6-8 - local color table size

    if (lctFlag) {

    lct = readColorTable(lctSize); // read table

    act = lct; // make local table active

    } else {

    act = gct; // make global table active

    if (bgIndex == transIndex) {

    bgColor = 0;

    }

    }

    int save = 0;

    if (transparency) {

    save = act[transIndex];

    act[transIndex] = 0; // set transparent color if specified

    }

    if (act == null) {

    status = STATUS_FORMAT_ERROR; // no color table defined

    }

    if (err()) {

    return;

    }

    decodeImageData(); // decode pixel data

    skip();

    if (err()) {

    return;

    }

    frameCount++;

    // create new image to receive frame data

    image = Image.createImage(width, height);

    setPixels(); // transfer pixel data to image

    frames.addElement(new GifFrame(image, delay)); // add image to frame

    // list

    if (transparency) {

    act[transIndex] = save;

    }

    resetFrame();

    }

    開發者ID:cabbage89,項目名稱:danceGame,代碼行數:63,

    示例17: ImageME

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public ImageME(InputStream is) throws IOException {

    image = Image.createImage(is);

    if (is != null) is.close();

    }

    開發者ID:aNNiMON,項目名稱:JECP,代碼行數:5,

    示例18: populateEntries

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    private void populateEntries() {

    Vector entriesVec = new Vector();

    FormIndex index = FormIndex.createBeginningOfFormIndex();

    FormDef form = model.getForm();

    int prevDepth = 0;

    while (!index.isEndOfFormIndex()) {

    if (index.isInForm() && model.isIndexRelevant(index)) {

    String text = "";

    boolean isHeader = false;

    Image img = null;

    if (model.getEvent(index) == FormEntryController.EVENT_QUESTION) {

    FormEntryPrompt prompt = model.getQuestionPrompt(index);

    text = getText(prompt);

    } else if (model.getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT) {

    FormEntryCaption[] hierachy = model.getCaptionHierarchy(index);

    text = "Add "

    + (index.getElementMultiplicity() == 0 ? "a "

    : "another ")

    + hierachy[hierachy.length - 1].getLongText() + "?";

    try {

    img = Image.createImage(Localization.get("plussign"));

    } catch (IOException ioe) {

    img = null;

    Logger.exception(ioe);

    }

    } else if ((model.getEvent(index) == FormEntryController.EVENT_GROUP)

    || (model.getEvent(index) == FormEntryController.EVENT_REPEAT)) {

    text = getHeaderText(model.getCaptionHierarchy(index));

    isHeader = true;

    }

    if (!text.equals("")) {

    Style style = isHeader ? StyleSheet

    .getStyle(Constants.STYLE_HEADER) : StyleSheet

    .getStyle(Constants.STYLE_PROMPT);

    String spacer="";

    int i = isHeader?-1:0;

    while (i < index.getDepth() - 2) {

    //ctsims : Huh?

    //spacer = "――" + spacer;

    spacer = "> > " + spacer;

    i++;

    }

    text=img==null?spacer+text:text;

    entriesVec.addElement(new Entry(text, img, style, index));

    }

    }

    prevDepth = index.getDepth();

    index = model.incrementIndex(index);

    }

    entries = new Entry[entriesVec.size()];

    entriesVec.copyInto(entries);

    }

    開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:55,

    示例19: LoginScreen

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public LoginScreen(Display display) {

    super(display);

    try {

    this.userNameTextBox = new CanvasTextBox(

    this, "Login", TextField.ANY, this.maxLoginLength);

    this.userNameTextBox.setTextEditorListener(this);

    this.passwordTextBox = new CanvasTextBox(

    this, "Password", TextField.PASSWORD, this.maxLoginLength);

    this.passwordTextBox.setTextEditorListener(this);

    } catch (IllegalStateException e1) {

    // TODO Auto-generated catch block

    this.parentDisplay.setCurrent(

    new Alert("e1 " + e1),

    this);

    //e1.printStackTrace();

    }

    //Disable Password box. It will be enabled once username is not empty.

    this.passwordTextBox.setEnabled(false);

    try {

    this.exitButton = new Button(

    this, "Exit",

    new Runnable() {

    public void run() {

    // When Exit is tapped, close the application

    removeItems();

    Display.getDisplay(parent).setCurrent(null);

    parent.notifyDestroyed();

    }

    });

    this.loginButton = new Button(

    this, "Log in",

    new Runnable() {

    public void run() {

    // When Login is tapped, create a new screen and set it current

    if(BlogWriter.isAshaPlatform())

    removeItems();

    EditScreen editScreen = new EditScreen(parentDisplay);

    editScreen.setParent(parent);

    parentDisplay.setCurrent(editScreen);

    }

    });

    // Disable Login button - it is enabled once username and password are entered

    this.loginButton.setEnabled(false);

    } catch (Exception ex) {

    this.parentDisplay.setCurrent(

    new Alert("Cannot create controls."),

    this);

    }

    // Create the logo image

    try {

    this.logoImage = Image.createImage("midlets/blogwriter/images/LogoImage.png");

    } catch (IOException e) {

    this.parentDisplay.setCurrent(

    new Alert("Cannot create graphics."), this);

    }

    // Set the default position of items and buttons

    this.layoutControls();

    this.userNameTextBox.setVisible(true);

    if (!BlogWriter.isFullTouch() && !BlogWriter.isAshaPlatform()) {

    this.userNameTextBox.setFocused(true);

    }

    this.passwordTextBox.setVisible(true);

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:70,

    示例20: createImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public static javax.microedition.lcdui.Image createImage(byte[] b, int i1, int i2) {

    return Image.createImage(0,0);

    }

    開發者ID:Orange-OpenSource,項目名稱:matos-profiles,代碼行數:4,

    示例21: loadImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    private Image loadImage(String url)

    {

    Image image = null;

    if (image == null)

    {

    try

    {

    StreamConnection connection = ProtocolFactory.getInstance().getConnection(url);

    InputStream is = connection.openInputStream();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    byte[] buf = new byte[1024];

    int bytesRead;

    do

    {

    bytesRead = is.read(buf);

    if (bytesRead > 0)

    {

    bos.write(buf, 0, bytesRead);

    }

    }

    while (bytesRead >= 0);

    buf = bos.toByteArray();

    //#debug

    System.out.println("Image requested: " + url);

    image = Image.createImage(buf, 0, buf.length);

    // this.imageCache.put(url, image);

    return image;

    }

    catch (Exception e)

    {

    // TODO: Implement proper error handling.

    //#debug debug

    e.printStackTrace();

    return null;

    }

    }

    return image;

    }

    開發者ID:okoskimi,項目名稱:Xfolite,代碼行數:48,

    示例22: imageCreateFromByteArray

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public Object imageCreateFromByteArray(byte[] data, int offset, int length) {

    return Image.createImage(data, offset, length);

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:4,

    示例23: loadImageInternal

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    private Image loadImageInternal(String url)

    {

    Image image = null; // (Image) this.imageCache.get(url);

    if (image == null)

    {

    try

    {

    StreamConnection connection = ProtocolFactory.getInstance().getConnection(url);

    InputStream is = connection.openInputStream();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    byte[] buf = new byte[1024];

    int bytesRead;

    do

    {

    bytesRead = is.read(buf);

    if (bytesRead > 0)

    {

    bos.write(buf, 0, bytesRead);

    }

    }

    while (bytesRead >= 0);

    buf = bos.toByteArray();

    //#debug

    System.out.println("Image requested: " + url);

    image = Image.createImage(buf, 0, buf.length);

    // this.imageCache.put(url, image);

    return image;

    }

    catch (Exception e)

    {

    // TODO: Implement proper error handling.

    //#debug debug

    e.printStackTrace();

    return null;

    }

    }

    return image;

    }

    開發者ID:okoskimi,項目名稱:Xfolite,代碼行數:48,

    示例24: getImage

    ​點讚 1

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public javax.microedition.lcdui.Image getImage() { return Image.createImage( (Image) null); }

    開發者ID:Orange-OpenSource,項目名稱:matos-profiles,代碼行數:2,

    注:本文中的javax.microedition.lcdui.Image.createImage方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

    展开全文
  • import java.awt.Component; //导入方法依赖package包/类public void draw(Graphics g, int x, int y, Component obs, double zoom) {if (alpha == 1.0) {piece.draw(g, x, y, obs, zoom);return;}if (opaque.is...

    import java.awt.Component; //导入方法依赖的package包/类

    public void draw(Graphics g, int x, int y, Component obs, double zoom) {

    if (alpha == 1.0) {

    piece.draw(g, x, y, obs, zoom);

    return;

    }

    if (opaque.isChanged()) {

    int trans = VASSAL.tools.TransparentFilter.getOffscreenEquivalent(obs.getBackground().getRGB(), obs);

    VASSAL.tools.TransparentFilter filter = new VASSAL.tools.TransparentFilter();

    filter.setAlpha(alpha);

    filter.setAlpha(0.0, trans);

    im = opaque.getImage(obs);

    Image im2 = obs.createImage(im.getWidth(obs), im.getHeight(obs));

    Graphics2D gg = (Graphics2D) im2.getGraphics();

    gg.drawImage(im, 0, 0, obs);

    gg.dispose();

    im = obs.createImage(new FilteredImageSource

    (im2.getSource(), filter));

    offset = new Point(piece.boundingBox().x,

    piece.boundingBox().y);

    /*

    im = opaque.getImage(obs);

    final Image im2 = obs.createImage(im.getWidth(obs), im.getHeight(obs));

    final Graphics2D gg = (Graphics2D) im2.getGraphics();

    gg.setComposite(

    AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) alpha));

    gg.drawImage(im, 0, 0, obs);

    gg.dispose();

    offset = new Point(piece.boundingBox().x,

    piece.boundingBox().y);

    */

    }

    Image scaled = im;

    if (zoom != 1.0) {

    scaled = GameModule.getGameModule().getDataArchive().getScaledImage(im,zoom);

    }

    g.drawImage(scaled,

    x + (int) (zoom * offset.x),

    y + (int) (zoom * offset.y),

    obs);

    }

    展开全文
  • 我正在尝试使用LWUIT创建启动画面。我想要一个表单加载并显示文本和图像5秒钟,...java.io.IOException可能是什么问题呢?这是代码package tungPackage;import com.sun.lwuit.Display;import com.sun.lwuit.Form;im...

    我正在尝试使用LWUIT创建启动画面。我想要一个表单加载并显示文本和图像5秒钟,然后继续下一个表单。我有一个代码,但未能显示图像。类和图像一起存储在同一个包中。相反,它显示一个错误。

    java.io.IOException可能是什么问题呢?这是代码

    package tungPackage;

    import com.sun.lwuit.Display;

    import com.sun.lwuit.Form;

    import com.sun.lwuit.Image;

    import com.sun.lwuit.Label;

    import javax.microedition.midlet.MIDlet;

    public class photoMidlet extends MIDlet {

    public void startApp() {

    Display.init(this);

    try {

    Form splashscreen = new Form();

    // Label splashText = new Label("Baldy");

    Image image = Image.createImage("/splash.png");

    Label pictureLabel = new Label(image);

    splashscreen.addComponent(pictureLabel);

    splashscreen.show();

    } catch (Exception ex) {

    Form x = new Form("ERROR");

    String y = ex.toString();

    Label g = new Label(y);

    x.addComponent(g);

    x.show();

    }

    }

    public void pauseApp() {

    }

    public void destroyApp(boolean unconditional) {

    }

    }

    展开全文
  • 通过鼠标位置改变图像ColorModel对象索引,从而实现图像像素自动变化BufferedImage由图像数据ColorModel和Raster组成。RasterSampleModel中 band 数量和类型必须与ColorModel所要求数量和类型相匹配,以表示...

    通过鼠标位置改变图像ColorModel对象索引,从而实现图像像素自动变化

    BufferedImage 由图像数据的 ColorModel 和 Raster 组成。Raster 的 SampleModel 中 band 的数量和类型必须与 ColorModel 所要求的数量和类型相匹配,以表示其颜色和 alpha 分量。所有 BufferedImage 对象的左上角坐标都为 (0, 0)。因此,用来构造 BufferedImage 的任何 Raster 都必须满足:minX=0 且 minY=0。

    此类依靠 Raster 的数据获取方法、数据设置方法,以及 ColorModel 的颜色特征化方法。

    package chapter2;

    import javax.swing.*;

    import java.awt.*;

    import java.awt.event.MouseEvent;

    import java.awt.event.MouseMotionListener;

    import java.awt.image.*;

    /**

    * Created by LENOVO on 18-1-27.

    */

    public class BufferedImageDemo extends JPanel implements MouseMotionListener{

    private BufferedImage image = null;

    private int width = 350;

    private int height = 350;

    public BufferedImageDemo(){

    image = createImage();

    addMouseMotionListener(this);

    }

    @Override

    public void mouseDragged(MouseEvent e) {

    }

    @Override

    public void mouseMoved(MouseEvent e) {

    //创建新的图片

    image = new BufferedImage(createColorModel(e.getX()),image.getRaster(),false,null);

    repaint();

    }

    public void paintComponent(Graphics g){

    Graphics2D g2d = (Graphics2D) g.create();

    if(image != null){

    g2d.drawImage(image,2,2,width,height,null);

    }

    }

    //颜色特征获取

    private static ColorModel createColorModel(int n){

    byte[] r = new byte[16];

    byte[] g = new byte[16];

    byte[] b = new byte[16];

    for(int i=0;i

    r[i] = (byte) n;

    g[i] = (byte) n;

    b[i] = (byte) n;

    }

    return new IndexColorModel(4,16,r,g,b);

    }

    private BufferedImage createImage(){

    byte[] pixels = new byte[width*height];

    /*

    * public DataBufferByte(byte[] dataArray, int size, int offset)

    使用指定数组、大小和偏移量构造具有单个存储单元且基于字节的 DataBuffer。dataArray

    至少必须有 offset + size 个元素。此 DataBuffer 的访问器只能使用 offset 到 offset + size - 1 个元素。

    * */

    DataBuffer dataBuffer = new DataBufferByte(pixels,width*height,0);

    //SampleModel为抽象类,压缩的样本数据:SinglePixelPackedSampleModel实现类

    //将多个样本打包到一个元素中去

    /*

    * public SinglePixelPackedSampleModel(int dataType,int w, int h,int[] bitMasks)

    * dataType - 存储样本使用的数据类型。

    w - 所描述的图像数据区域的宽度(以像素为单位)。

    h - 所描述的图像数据区域的高度(以像素为单位)。

    bitMasks - 所有 band 的位掩码。

    * */

    SampleModel sampleModel = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,width,height,new int[]{(byte)0xf});

    //null代表位置为(0,0)

    WritableRaster raster = Raster.createWritableRaster(sampleModel,dataBuffer,null);

    return new BufferedImage(createColorModel(0),raster,false,null);

    }

    public static void main(String args[]){

    JFrame jf = new JFrame("BufferedImage Demo");

    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jf.getContentPane().setLayout(new BorderLayout());

    jf.getContentPane().add(new BufferedImageDemo(),BorderLayout.CENTER);

    jf.setPreferredSize(new Dimension(380,380));

    jf.pack();

    jf.setVisible(true);

    }

    }

    展开全文
  • Java Image功能一直都在增强,但是向磁盘写一个图像文件或者返回一个PNG或JPEG依然比较难实现。但是我们可以使用Java Advanced Imaging(JAI)API来解决这个问题。JAI可以从SUN的Java站点下载,它包含在JDK 1.4javax...
  • Image.createImage异常

    千次阅读 2009-05-21 22:58:00
    在用Image.createImage加载图片时,显示java.lang.nullpointerexception,确认图片没问题,路径也没问题(createImage("/owen.jpg")),图片是放在res下,开发环境为Eclipse+wtk+EclipseMe。网上看到一些解决方法,...
  • 原因…JavaCV 0.11引入了FrameConverter概念.目标是不要在使用JavaCV应用程序和另一个API(FFmpeg,Java 2D ……)之间创建不必要耦合....解决方法……始终可以将createFrom方法代码复制并粘贴到您自己代码...
  • 今天在学习j2me过程中遇到了一个问题,就是使用CreateImage显示不了图像,在网上找了一下。需要将图片放在RES目录下,尝试了一下,发现还是不行。而且提示两个错误:System.IO.Exception 和 java.lang....
  • 然后用component的createImage(image1.getWidth,image1.getHeight)造了个image2,也在paint(g)draw了然后调用image2.getgraphi...我先在一个component里draw 了一个image1,是个实体图象;然后 用component的createI....
  • 将一个背景色是透明图片改变宽和高之后,重新生成 Image 对象,并用 Graphics2D 重新绘制后,透明背景色变成了白色,这是怎么回事? 我也并没有调用 setColor()方法设置背景色。主要代码如下:data = bos....
  • 1. 生成png图片int width = 400;...// 创建BufferedImage对象BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);// 获取Graphics2DGraphics2D g2d = image.createGraphi...
  • 通过Toolkit.createImage(str)创建Image对象为什么获取不了图片? Image image = Toolkit.getDefaultToolkit().createImage("test.jpg"); System.out.println(image.getWidth(null)); 输出-1,没获取到图片...
  • 准备工作,在库Im_Test中建立一张表Im_Info,此表...其语法如下:CREATE TEALE Im_Info (Pr_Id INT NULL ,Pr_Info IMAGE NULL)第一步: 往表中插入一条记录,并初始化PR_INFO字段。其语法如下:INSERT INTO Im_Info ...
  • java advance image相关

    2009-06-29 10:29:37
    [code="java"] public Image render(InputStream is) { PlanarImage resultImage = null; SeekableStream seekableStream = SeekableStream.wrapInputStream(is,true); ParameterBlock pb = new Parameter...
  • Java Image CMYK2RGB

    千次阅读 2013-08-30 11:05:27
    常用方法1: private BufferedImage convertCMYK2RGB(BufferedImage image) throws IOException{ log.info("Converting a CYMK image to RGB");... //Create a new RGB image BufferedImage rgbImage = new Bu
  • 小编典典这是GIFanim的createImage()方法。也许那会给您一个开始。public byte[] createImage() throws Exception {ImageWriter iw = ImageIO.getImageWritersByFormatName("gif").next();ByteArrayOutputStream os ...
  • 使用Jenkins打包docker镜像时报这个错,并且还是在有别...[Docker] ERROR: Failed to create docker image: org.apache.http.client.ClientProtocolException ERROR: Build step failed with exception java.net.Socket
  • 我想用Java制作简单相册...我有我照片'bufferedimages,我试图用下面代码将它们添加到gridlayout中,BufferedImage a = GUI.createImage(current);Image b = Toolkit.getDefaultToolkit().createImage(a.getSo...
  • 前言最近不知道怎么搞,WebstormTerminal无法使用,一打开就报错java.io.IOException: Couldn't create PTY,百度了好多资料,都说使用管理员权限打开即可,结果发现然并卵,后来一直找答案,最终还是找到了。...
  • 该问题可能与无法正确读取某些JPG图像...作为替代方案,您可以尝试使用似乎正确处理指定图像Toolkit.createImage.例如:import java.awt.Image;import java.awt.Toolkit;import java.awt.image.BufferedImage;im...
  • ABOUTYOU如果 你 oracle 里面存放...用 一 servlet 传输:注册到web.xml中,映射路径为/CreateImage,:[code="java"]import java.io.*; import java.awt.*; import java.awt.image.*; import javax.servlet.*;...
  • 如果 你 oracle 里面...用 一 servlet 传输:注册到web.xml中,映射路径为/CreateImage,:[code="java"]import java.io.*;import java.awt.*;import java.awt.image.*;import javax.servlet.*;import javax.servl...
  • 的java应用程序使用看起来或多或少代码在系统托盘上显示其图标:Toolkit mainToolkit = Toolkit.getDefaultToolkit();...Image trayIconImage = mainToolkit.createImage(getClass().getResourc...
  • java窗体图标设置

    2018-12-28 16:52:40
    一般采用gif格式图像文件来作为java图标文件,图像文件位置一般采用类路径,而不采用绝对路径,以方便移植;...Image image=kit.createImage("./resources/cion.gif"); setIcon...
  • 的java应用程序使用看起来或多或少代码在系统托盘上显示其图标:Toolkit mainToolkit = Toolkit.getDefaultToolkit();...Image trayIconImage = mainToolkit.createImage(getClass().getResourc...
  • 文件结构: 源包- -/code/Jframe1.java -/image/1.png 目标: Jframe1.java 使用"/image/1.png"作为左上角...this.setIconImage(this.getToolkit().createImage(this.getClass().getResource("/image/1.png"...
  • Aspose.Page for Java 20.4 Java 20.4Aspose.Page玩鹅啊2632386163 Aspose.Page for Java is an XPS and PostScript document processing and parsing API. Developers can convert PS & EPS files to PDF and...
  • java Swing GUI 入门-图片和控件可视化觉得有用话,欢迎一起讨论相互学习~加入一张图片一个Imagelabel 设置居中,命名为logoLabel,Custom Create 打勾.注意要保持图片尺寸,要不然太大了把其他内容都遮住了...
  •  image = Image.createImage(fileName[index]); // 以指定文件创建一个固定图像  } catch (java.io.IOException err) {}  ImageItem imageItem = new ImageItem(null,image,ImageItem.LAYOUT_CENTER,"img"); // ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 470
精华内容 188
关键字:

java的createimage

java 订阅