public Image createImage(javax.microedition.lcdui.Image source) { if (source.isMutable()) { return new J2SEImmutableImage((J2SEMutableImage) source); } else { return source; } }
public void getRGB(int[] argb, int offset, int scanlength, int x, int y, int width, int height) { if (width <= 0 || height <= 0) return; if (x < 0 || y < 0 || x + width > getWidth() || y + height > getHeight()) throw new IllegalArgumentException("Specified area exceeds bounds of image"); if ((scanlength < 0 ? -scanlength : scanlength) < width) throw new IllegalArgumentException("abs value of scanlength is less than width"); if (argb == null) throw new NullPointerException("null rgbData"); if (offset < 0 || offset + width > argb.length) throw new ArrayIndexOutOfBoundsException(); if (scanlength < 0) { if (offset + scanlength * (height - 1) < 0) throw new ArrayIndexOutOfBoundsException(); } else { if (offset + scanlength * (height - 1) + width > argb.length) throw new ArrayIndexOutOfBoundsException(); } try { (new java.awt.image.PixelGrabber(img, x, y, width, height, argb, offset, scanlength)).grabPixels(); } catch (InterruptedException e) { Logger.error(e); } }
public void paintControls(Graphics g) { Device device = DeviceFactory.getDevice(); g.setColor(backgroundColor); g.fillRect(0, 0, displayRectangle.width, displayPaintable.y); g.fillRect(0, displayPaintable.y, displayPaintable.x, displayPaintable.height); g.fillRect(displayPaintable.x + displayPaintable.width, displayPaintable.y, displayRectangle.width - displayPaintable.x - displayPaintable.width, displayPaintable.height); g.fillRect(0, displayPaintable.y + displayPaintable.height, displayRectangle.width, displayRectangle.height - displayPaintable.y - displayPaintable.height); g.setColor(foregroundColor); for (Enumeration s = device.getSoftButtons().elements(); s.hasMoreElements();) { ((J2SESoftButton) s.nextElement()).paint(g); } int inputMode = device.getInputMethod().getInputMode(); if (inputMode == InputMethod.INPUT_123) { g.drawImage(((J2SEImmutableImage) mode123Image.getImage()).getImage(), mode123Image.getRectangle().x, mode123Image.getRectangle().y, null); } else if (inputMode == InputMethod.INPUT_ABC_UPPER) { g.drawImage(((J2SEImmutableImage) modeAbcUpperImage.getImage()).getImage(), modeAbcUpperImage .getRectangle().x, modeAbcUpperImage.getRectangle().y, null); } else if (inputMode == InputMethod.INPUT_ABC_LOWER) { g.drawImage(((J2SEImmutableImage) modeAbcLowerImage.getImage()).getImage(), modeAbcLowerImage .getRectangle().x, modeAbcLowerImage.getRectangle().y, null); } }
int[] rgbTransformedData = new int[height * width]; if (image instanceof J2SEImmutableImage) { ((J2SEImmutableImage) image).getRGB(rgbData, 0, width, x, y, width, height); } else { ((J2SEMutableImage) image).getRGB(rgbData, 0, width, x, y, width, height);
img = ((J2SEMutableImage) src).getImage(); } else { img = ((J2SEImmutableImage) src).getImage();
return new J2SEImmutableImage(Toolkit.getDefaultToolkit().createImage(imageSource)); } else { return new J2SEImmutableImage(img);
public void drawImage(Image img, int x, int y, int anchor) { int newx = x; int newy = y; if (anchor == 0) { anchor = javax.microedition.lcdui.Graphics.TOP | javax.microedition.lcdui.Graphics.LEFT; } if ((anchor & javax.microedition.lcdui.Graphics.RIGHT) != 0) { newx -= img.getWidth(); } else if ((anchor & javax.microedition.lcdui.Graphics.HCENTER) != 0) { newx -= img.getWidth() / 2; } if ((anchor & javax.microedition.lcdui.Graphics.BOTTOM) != 0) { newy -= img.getHeight(); } else if ((anchor & javax.microedition.lcdui.Graphics.VCENTER) != 0) { newy -= img.getHeight() / 2; } if (img.isMutable()) { g.drawImage(((J2SEMutableImage) img).getImage(), newx, newy, null); } else { g.drawImage(((J2SEImmutableImage) img).getImage(), newx, newy, null); } }
public Image createSystemImage(URL url) throws IOException { java.awt.Image resultImage = Toolkit.getDefaultToolkit().createImage(url); // TODO not elegant solution, maybe use ImageObserver in // image.getWitdth(..) instead MediaTracker mediaTracker = new MediaTracker(new java.awt.Canvas()); mediaTracker.addImage(resultImage, 0); try { mediaTracker.waitForID(0); } catch (InterruptedException ex) { } if (mediaTracker.isErrorID(0)) { throw new IOException(); } return new J2SEImmutableImage(resultImage); }
offg.drawImage(((J2SEImmutableImage) device.getNormalImage()).getImage(), 0, 0, this); drawImageInShape(offg, ((J2SEImmutableImage) device.getNormalImage()).getImage(), shape); org.microemu.device.impl.Shape shape = overButton.getShape(); if (shape != null) { drawImageInShape(offg, ((J2SEImmutableImage) device.getOverImage()).getImage(), shape); org.microemu.device.impl.Shape shape = pressedButton.getShape(); if (shape != null) { drawImageInShape(offg, ((J2SEImmutableImage) device.getPressedImage()).getImage(), shape);
return new J2SEImmutableImage(resultImage);