Package javax.microedition.lcdui

Examples of javax.microedition.lcdui.Graphics


            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);
       
        page.drawSelected(g, cp, firstElement, lastElement);

        renderRotate(img);
    }
View Full Code Here


    private void renderRotate(final Image img) {
        /*
         * Rotate, if necessary
         */
        if (orientation != BookCanvas.ORIENTATION_0) {
            final Graphics gx = canvas.getGraphics();
            gx.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(),
                    orientation, 0, 0,
                    Graphics.LEFT | Graphics.TOP);
        }
    }
View Full Code Here

        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++) {
            for (int x = 0; x < thumbWidth; x++) {
                g.setClip(x, y, 1, 1);
                dx = x * sourceWidth / thumbWidth;
                dy = y * sourceHeight / thumbHeight;
                g.drawImage(image, x - dx, y - dy, anchor);
            }
        }

        return thumb;
    }
View Full Code Here

*
*/
public class GraphicsSample {
 
  public static void main(String [] options) throws Exception {
    Graphics g = new Graphics();
    g.drawLine(5,5,60,60);
    g.drawRect(62, 10, 25, 35);
    g.refresh();
    Button.waitForPress();
  }
View Full Code Here

    public static Image getAdjustedImage(Image image, int _width, int _height)
    {
        int srcWidth = image.getWidth();
  int srcHeight = image.getHeight();
  Image tmp = Image.createImage(_width, srcHeight);
  Graphics g = tmp.getGraphics();
  int ratio = (srcWidth << 16) / _height;
  int pos = ratio/2;

  //Horizontal Resize

  for (int x = 0; x < _width; x++)
        {
            g.setClip(x, 0, 1, srcHeight);
      g.drawImage(image, x - (pos >> 16), 0, Graphics.LEFT | Graphics.TOP);
            pos += ratio;
        }

   Image resizedImage = Image.createImage(_width, _height);
   g = resizedImage.getGraphics();
   ratio = (srcHeight << 16) / _height;
   pos = ratio/2;

   //Vertical resize

    for (int y = 0; y < _height; y++)
          {
              g.setClip(0, y, _width, 1);
              g.drawImage(tmp, 0, y - (pos >> 16), Graphics.LEFT | Graphics.TOP);
              pos += ratio;
          }
         return resizedImage;
    }
View Full Code Here

TOP

Related Classes of javax.microedition.lcdui.Graphics

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.