Package javax.microedition.lcdui

Examples of javax.microedition.lcdui.Image


    public final void renderPageSelected(
            final ColorScheme cp,
            final int firstElement,
            final int lastElement) {

        final Image img = (BUFFER == null ? canvas : BUFFER);

        final Graphics g = img.getGraphics();
        final int w = img.getWidth();
        final int h = img.getHeight();

        final int color_bg = cp.colors[ColorScheme.COLOR_BACKGROUND];

        g.setColor(color_bg);
        g.fillRect(0, 0, w, h);
View Full Code Here


                textTopCorner = regions[0].y;
                final Region r = regions[regions.length - 1];
                textHeight = r.y + r.height - textTopCorner;
            }

            Image image = imageRegion.getImage(
                    booklet.width, booklet.height, textHeight);

            final int margin = ImageRegion.MARGIN;

            final int imageW = image.getWidth() + 4 * margin + 2;
            final int imageH = image.getHeight() + 4 * margin + 2;

            final int imageX = (booklet.width - imageW) / 2;
                  int imageY = (booklet.height - imageH) / 2;

            if (regionsSize > 0) {
                /*
                 * There is alt text
                 */
                final int h = imageH + textHeight;

                int offset = (booklet.height - h) / 2;

                imageY = offset;

                offset += imageH - textTopCorner;

                for (int i = 0; i < regionsSize; i++) {
                    regions[i].y += offset;
                }
            }

            g.setColor(cp.colors[ColorScheme.COLOR_FRAME]);
            g.drawRect(
                    imageX + margin,
                    imageY + margin,
                    image.getWidth()  + 2 * margin + 1,
                    image.getHeight() + 2 * margin + 1);

            g.drawImage(image,
                    imageX + 2 * margin + 1,
                    imageY + 2 * margin + 1,
                    Graphics.TOP | Graphics.LEFT);
View Full Code Here

            final int fontHeight) {
       
        boolean rescale = false;
        int width;
        int height;
        Image image = null;

        if (entry == null) {
            image = getBrokenImage();
        } else {
            /*
             * file found
             */
            final WeakReference ref = imageReference;
            if (ref != null) {
                image = (Image) ref.get();
            }

            if (image == null) {
                try {
                    InputStream in = entry.openInputStream();
                    try {
                        image = Image.createImage(in);

                        int maxWidth = (canvasWidth - 4 * MARGIN - 1);
                        int maxHeight = (canvasHeight - 4 * MARGIN - 1);

                        if (altTextBufferLength > 0) {
                            maxHeight -= fontHeight;
                        }

                        width = image.getWidth();
                        height = image.getHeight();

                        float ratio = 1;

                        /*
                         * check width
                         */
                        if (width > maxWidth) {
                            ratio = (float) maxWidth / (float) width;
                            width = maxWidth;
                            height *= ratio;
                            rescale = true;
                        }

                        /*
                         * check height
                         */

                        if (height > maxHeight) {
                            ratio = (float) maxHeight / (float) height;
                            height = maxHeight;
                            width *= ratio;
                            rescale = true;
                        }

                        /*
                         * got to check width again for h may have modified it
                         */
                        if (width > maxWidth) {
                            ratio = (float) maxWidth / (float) width;
                            width = maxWidth;
                            height *= ratio;
                            rescale = true;
                        }

                        /*
                         * Try to resize, if image is too big
                         */
                        if (rescale) {
                            try {
                                Image rescaled =
                                        AlbiteImage.rescale(image, width, height);
                                image = rescaled;
                            } catch (OutOfMemoryError e) {
                                /*
                                 * The rescaled version will be used,
View Full Code Here

        return image;
    }

    private static Image getBrokenImage() {
        Image image = null;

        if (BROKEN_IMAGE != null) {
            image = (Image) BROKEN_IMAGE.get();
        }
View Full Code Here

    private Image getCache() {
        WeakReference   cache = this.cache;

        if (cache != null) {
            Image image = (Image) cache.get();
            if (image != null) {
                if (cacheColor == color) {
                    return image;
                }
            }
        }

        /*
         * Update the cache
         */
        Image image = Image.createRGBImage(argbData, width, height, true);
        cache = new WeakReference(image);

        return image;
    }
View Full Code Here

            final Image image, final int thumbWidth, final int thumbHeight) {

        int sourceWidth = image.getWidth();
        int sourceHeight = image.getHeight();

        Image thumb = Image.createImage(thumbWidth, thumbHeight);
        Graphics g = thumb.getGraphics();

        int dx, dy;
        int anchor = Graphics.LEFT | Graphics.TOP;

        for (int y = 0; y < thumbHeight; y++) {
View Full Code Here

        applyStyle();
      }
    } else if (resource instanceof Image) {
      Vector targets = (Vector) pendingResourceRequests.get(resUrl);
      if (targets != null) {
        Image image = (Image) resource;
        pendingResourceRequests.remove(resUrl);

        for (int i = 0; i < targets.size(); i++) {
          Object t = targets.elementAt(i);
          if (t instanceof BlockWidget) {
View Full Code Here

              break;

            case CssTokenizer.TT_URI:
              if (id == MULTIVALUE_BACKGROUND || "background-image".equals(name)) {
                backgroundImage = new Image[1];
                Image bg = (Image) tokenizer.htmlWidget.getResource(tokenizer.sval,
                    SystemRequestHandler.TYPE_IMAGE, backgroundImage);
                // null check necessary to avoid overwriting image inserted in a separate thread!
                if (bg != null) {
                  backgroundImage[0] = bg;
                }
View Full Code Here

    if ((bg & 0x0ff000000) != 0) {
      g.setColor(bg);
      g.fillRect(x0 + 1, y0 + 1, x1 - x0 - 1, y1 - y0 - 1);
    }
    if (style.backgroundImage != null && style.backgroundImage[0] != null) {
      Image img = style.backgroundImage[0];
      int cx = g.getClipX();
      int cy = g.getClipY();
      int cw = g.getClipWidth();
      int ch = g.getClipHeight();
      int repeat = style.getEnum(Style.BACKGROUND_REPEAT);

      int bgX = repeat == Style.REPEAT_X || repeat == Style.REPEAT ? 0 :
        style.getBackgroundReferencePoint(Style.BACKGROUND_POSITION_X,
            x1 - x0 - 1, img.getWidth());
      int bgY = repeat == Style.REPEAT_Y || repeat == Style.REPEAT ? 0 :
        style.getBackgroundReferencePoint(Style.BACKGROUND_POSITION_Y,
            y1 - y0 - 1, img.getHeight());

      g.clipRect(x0 + 1, y0 + 1, x1 - x0 - 1, y1 - y0 - 1);
      if (repeat == Style.REPEAT_Y || repeat == Style.REPEAT) {
        do {
          if (repeat == Style.REPEAT) {
            do {
              g.drawImage(img, x0 + 1 + bgX, y0 + 1 + bgY, Graphics.TOP | Graphics.LEFT);
              bgX += img.getWidth();
            } while (bgX < x1 - x0);
            bgX = 0;
          } else {
            g.drawImage(img, x0 + 1 + bgX, y0 + 1 + bgY, Graphics.TOP | Graphics.LEFT);
          }
          bgY += img.getHeight();
        } while (bgY < y1 - y0);
      } else if (repeat == Style.REPEAT_X) {
        do {
          g.drawImage(img, x0 + 1 + bgX, y0 + 1 + bgY, Graphics.TOP | Graphics.LEFT);
          bgX += img.getWidth();
        } while (bgX < x1 - x0);
      } else {
        g.drawImage(img, x0 + 1 + bgX, y0 + 1 + bgY, Graphics.TOP | Graphics.LEFT);
      }
      g.setClip(cx, cy, cw, ch);
View Full Code Here

              encoding);
          break;

        case SystemRequestHandler.TYPE_IMAGE:
          try {
            Image image = Image.createImage(responseData, 0, responseData.length);
            screen.htmlWidget.addResource(url, image, SystemRequestHandler.TYPE_IMAGE);
          } catch (IllegalArgumentException e) {
            System.err.println("Img fmt err: " + e);
          }
          break;
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.