public Image createImage(int width, int height) { if (width <= 0 || height <= 0) { throw new IllegalArgumentException(); } return new J2SEMutableImage(width, height); }
protected void paintComponent(Graphics g) { if (displayImage != null) { synchronized (displayImage) { g.drawImage(displayImage.getImage(), 0, 0, null); } } }
displayImage = new J2SEMutableImage( device.getDeviceDisplay().getFullWidth(), device.getDeviceDisplay().getFullHeight()); displayGraphics = displayImage.getImage().getGraphics(); repaint(x, y, width, height); } else { repaint(0, 0, displayImage.getWidth(), displayImage.getHeight());
protected void paintComponent(Graphics g) { if (offg == null || offi.getWidth(null) != getSize().width || offi.getHeight(null) != getSize().height) { offi = new J2SEMutableImage(getSize().width, getSize().height).getImage(); offg = offi.getGraphics();
public MutableImage getScaledDisplayImage(int zoom) { return displayImage.scale(zoom); }
((J2SEImmutableImage) image).getRGB(rgbData, 0, width, x, y, width, height); } else { ((J2SEMutableImage) image).getRGB(rgbData, 0, width, x, y, width, height);
public void repaintRequest(int x, int y, int width, int height) { MIDletAccess ma = MIDletBridge.getMIDletAccess(); if (ma == null) { return; } DisplayAccess da = ma.getDisplayAccess(); if (da == null) { return; } Displayable current = da.getCurrent(); if (current == null) { return; } Device device = DeviceFactory.getDevice(); if (device != null) { if (displayImage == null) { displayImage = new J2SEMutableImage( device.getDeviceDisplay().getFullWidth(), device.getDeviceDisplay().getFullHeight()); } Graphics gc = displayImage.getImage().getGraphics(); J2SEDeviceDisplay deviceDisplay = (J2SEDeviceDisplay) device.getDeviceDisplay(); if (!deviceDisplay.isFullScreenMode()) { deviceDisplay.paintControls(gc); } deviceDisplay.paintDisplayable(gc, x, y, width, height); fireDisplayRepaint(displayImage); } }
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 PixelGrabber(img, x, y, width, height, argb, offset, scanlength)).grabPixels(); } catch (InterruptedException e) { Logger.error(e); } } // Andres Navarro
public J2SEImmutableImage(J2SEMutableImage image) { img = Toolkit.getDefaultToolkit().createImage(image.getImage().getSource()); this.width = -1; this.height = -1; }
public MutableImage scale(int zoom) { BufferedImage scaledImg = new BufferedImage(img.getWidth() * zoom, img.getHeight() * zoom, img.getType()); Graphics2D imgGraphics = scaledImg.createGraphics(); imgGraphics.scale(zoom, zoom); imgGraphics.drawImage(img, 0, 0, null); J2SEMutableImage scaledMutableImage = new J2SEMutableImage(scaledImg.getWidth(), scaledImg.getHeight()); scaledMutableImage.img = scaledImg; return scaledMutableImage; }
public javax.microedition.lcdui.Graphics getGraphics() { java.awt.Graphics2D g = (java.awt.Graphics2D) img.getGraphics(); g.setClip(0, 0, getWidth(), getHeight()); J2SEDisplayGraphics displayGraphics = new J2SEDisplayGraphics(g, this); displayGraphics.setColor(0x00000000); displayGraphics.translate(-displayGraphics.getTranslateX(), -displayGraphics.getTranslateY()); return displayGraphics; }
public void drawRGB(int[] rgbData, int offset, int scanlength, int x, int y, int width, int height, boolean processAlpha) { // this is less than ideal in terms of memory // but it's the easiest way if (rgbData == null) throw new NullPointerException(); if (width == 0 || height == 0) { return; } int l = rgbData.length; if (width < 0 || height < 0 || offset < 0 || offset >= l || (scanlength < 0 && scanlength * (height - 1) < 0) || (scanlength >= 0 && scanlength * (height - 1) + width - 1 >= l)) throw new ArrayIndexOutOfBoundsException(); BufferedImage targetImage = (BufferedImage) ((J2SEMutableImage) image).getImage(); if (!processAlpha) { int[] rgb = new int[width * height]; for (int row = 0; row < height; row++) { for (int px = 0; px < width; px++) { rgb[row * width + px] = rgbData[offset + px] | 0xff000000; } offset += scanlength; } targetImage.setRGB(x, y, width, height, rgb, 0, width); } else { targetImage.setRGB(x, y, width, height, rgbData, offset, scanlength); } }
private void updateScaledImage(int scale, JFrame scaledLCDFrame) { J2SEMutableImage scaledImage = (J2SEMutableImage) ((SwingDisplayComponent) emulatorContext .getDisplayComponent()).getScaledDisplayImage(scale); ((ImageIcon) (((JLabel) scaledLCDFrame.getContentPane()).getIcon())).setImage(scaledImage.getImage()); ((JLabel) scaledLCDFrame.getContentPane()).repaint(); } };
img = ((J2SEMutableImage) src).getImage(); } else { img = ((J2SEImmutableImage) src).getImage();
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); } }