Package javax.microedition.lcdui

Examples of javax.microedition.lcdui.Image


        }
    }

    private void adjustImage()
    {
        final Image image = this.image;
        if( image != null )
        {
            final int wrRatio = image.getWidth() * 100 /
                                image.getHeight();
            final int rwRatio = image.getHeight() * 100 /
                                image.getWidth();
            switch( zoom )
            {
                case ZOOM_FIT:
                {
                    int width = getWidth();
                    int height = (width * wrRatio) / 100;
                    if( height > getHeight() )
                    {
                        height = getHeight();
                        width = (height * rwRatio) / 100;
                    }
                    scaled = Util.scale( image, width, height );
                }
                    break;

                case ZOOM_FIT_HEIGHT:
                {
                    int height = getHeight();
                    int width = (height * rwRatio) / 100;
                    scaled = Util.scale( image, width, height );
                }
                    break;

                case ZOOM_FIT_WIDTH:
                {
                    int width = getWidth();
                    int height = (width * wrRatio) / 100;
                    scaled = Util.scale( image, width, height );
                }
                    break;

                default:
                    if( zoom == 100 )
                    {
                        shown = Image.createImage( image );
                    }
                    else
                    {
                        int width = image.getWidth() * zoom / 100;
                        int height = (width * wrRatio) / 100;
                        scaled = Util.scale( image, width, height );
                    }
            }
            shown = Util.crop( scaled, x, y, getWidth(), getHeight() );
View Full Code Here


    int clipY = g.getClipY();
    int clipW = g.getClipWidth();
    int clipH = g.getClipHeight();
    int fontH = statusFont.getHeight();
    // Calculate the appropriate tile set.
    Image tiles = tileSet[ 0 ];
    tileSize = tiles.getHeight();
    for( int idx = 1; idx < tileSet.length; idx++ ) {
      int size = tileSet[ idx ].getHeight();
      if( width >= mapWidth * size
        && height >= mapHeight * size + fontH + fontH ) {
        tiles = tileSet[ idx ];
View Full Code Here

  } //constructor

  /* Get image.  Need retry to handle sometimes failure. */
  private Image getImage(String imagePath) {
    Image rtnImage = null;

    try {
      try {
        // createImage("/icons/(image)") does not always work
        // with the emulator.  so, I do an alternate which is
View Full Code Here

    return szMimeType;
  }//getMimeType

  public Image getThumbnail(int width, int height)
  {
    Image thumbImage = FILE_IMAGE;
    String fileType = getFileMimeType();

    if (null != fileType)
    {
      try {
        byte[] datablock = getFileData();
        thumbImage = Image.createImage(datablock,0,datablock.length);
      }
      catch (java.lang.OutOfMemoryError oom) {
        //#ifdef DTEST
        if (bDebug) System.err.println("### OOM on createImage: "  + Runtime.getRuntime().freeMemory());
        //#endif
      }
      catch (Exception ex) {
        //#ifdef DTEST
        if (bDebug)  {
          System.err.println("### Couldn't create image: " + ex);
          ex.printStackTrace();
        }
        //#endif

      }
    }

    if (thumbImage.getWidth() > (2*width)) {
      thumbImage = FILE_IMAGE;
    }

    //#ifdef DTEST
    if (bDebug) System.out.println("...getThumbnail");
View Full Code Here

  /* Create prompt alert. */
  public void run() {
    // Due to a quirk on T637 (MIDP 1.0), we need to create a form
    // before the alert or the alert will not be seen.
    Form formAlert = new Form(origCmd.getLabel());
    Image question = UiUtil.getImage("/icons/questionMk.png");
    formAlert.append(question);
    int ix = formAlert.append(new StringItem(null,
          (String)promptCommands.get(origCmd)));
    Command okCmd = UiUtil.getCmdRsc("cmd.ok", Command.OK, 1);
    formAlert.addCommand(okCmd);
View Full Code Here

   * @return    Image - image for path
   *
   * @author Irv Bunton
   */
  final public static Image getImage(final String imagePath) {
    Image image = null;
    try {
      try {
        // createImage("/icons/unread.png") does not always work
        // with the emulator.  so, I do an alternate which is
        // effectively the same thing.
View Full Code Here

        g.fillRect(0, 0, getWidth(), getHeight());
        if (SCREEN_TYPE == 0) {

            try {
                //Draw title
                Image header = Image.createImage("/res/title.png");
                g.drawImage(header, getWidth()/2, 40, Graphics.HCENTER|Graphics.TOP);

                //Draw options
                for(int o = 0; o < options[0][type].length; o++) {
                    Image optionSrc = Image.createImage("/res/"+options[0][type][o]+".png");
                    g.drawImage(optionSrc, getWidth()/2, 40*(o+1)+90, Graphics.HCENTER|Graphics.VCENTER);
                }

                //Draw the Selection
                Image selection = Image.createImage("/res/backcard.png");
                g.drawImage(selection, getWidth()/2-80, 40*(getAtualOption()+1)+90,
                            Graphics.HCENTER|Graphics.VCENTER);

            } catch(IOException io) {

View Full Code Here

        }
        return Image.createImage(fileConn.openInputStream());
    }

    public static Image downloadAndSaveImage(String url, final String fileUrl) throws IOException {
        Image result = null;
        // long beforeRequest = System.currentTimeMillis();
        HttpConnection http = (HttpConnection) Connector.open(url);
        http.setRequestMethod(HttpConnection.GET);
        Options options = Options.getInstance();
View Full Code Here

        if(discarded.size() > 1) {

            int len = discarded.size();
            if(len % 2 == 0) {

                Image toDraw = ((Card) discarded.elementAt(len-2)).getGraphic().getRender();
                gTable.drawRegion(toDraw, 0, 0, toDraw.getWidth(), toDraw.getHeight(),
                                  Sprite.TRANS_ROT270, HX, HY, Graphics.TOP|Graphics.LEFT);
                gTable.drawImage(((Card) discarded.elementAt(len-1))
                                .getGraphic().getRender(), VX, VY,
                                Graphics.TOP|Graphics.LEFT);
            } else {

                gTable.drawImage(
                                ((Card) discarded.elementAt(len-2))
                                .getGraphic().getRender(), VX, VY,
                                Graphics.TOP|Graphics.LEFT);
                Image toDraw = ((Card)discarded.elementAt(len-1)).getGraphic().getRender();
                gTable.drawRegion(toDraw, 0, 0, toDraw.getWidth(), toDraw.getHeight(),
                                   Sprite.TRANS_ROT270, HX, HY, Graphics.TOP|Graphics.LEFT);
            }
        } else {

            gTable.drawImage(
View Full Code Here

                                YELLOW //Yellow Color
                             };

    public static GraphicCard createGraphicCard(Card card) {
       
       Image srcImage = null;
      
        try {
            String p2 = "";
            switch(card.getColor()) {
                case Card.BLUE:
                    p2 = "blue";
                break;

                case Card.GREEN:
                    p2 = "green";
               break;

                case Card.RED:
                    p2 = "red";
               break;

                case Card.YELLOW:
                    p2 = "yellow";
               break;

                case Card.NONE:
               break;

                default:
                    throw new IllegalArgumentException("Invalid color for graphic card.");
            }

            String p1 = "";
            switch(card.getType()) {
                case Card.GET2:
                    p1 = "get2";
                break;

                case Card.REVERSE:
                    p1 = "reverse";
                break;

                case Card.SKIP:
                    p1 = "skip";
                break;

                case Card.JOKER:
                    p1 = "joker";
                break;

                case Card.JOKER4:
                    p1 = "joker4";
                break;

                case Card.NORMAL:
                    p1 = "base";
                break;

                case Card.BACK:
                    p1 = "backcard";
                break;

                default:
                    throw new IllegalArgumentException("Invalid type for graphic card");
            }

            srcImage = Image.createImage("/res/"+p1+p2+".png");
        } catch(IOException io) {

            //#ifdef DEBUG
            System.out.println("Exception in GraphicCard");
            //#endif
        }

        GraphicCard newCard = new GraphicCard();
        newCard.render = Image.createImage(srcImage.getWidth(), srcImage.getHeight());
        Graphics gCard = newCard.render.getGraphics();

        //Draw base image
        gCard.drawImage(srcImage, 0, 0, Graphics.TOP|Graphics.LEFT);
View Full Code Here

TOP

Related Classes of javax.microedition.lcdui.Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.