protected void paintComponent(Graphics g) { if (displayImage != null) { synchronized (displayImage) { g.drawImage(displayImage.getImage(), 0, 0, null); } } }
public J2SEImmutableImage(J2SEMutableImage image) { img = Toolkit.getDefaultToolkit().createImage(image.getImage().getSource()); this.width = -1; this.height = -1; }
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); } }
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 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); } }
displayImage = new J2SEMutableImage( device.getDeviceDisplay().getFullWidth(), device.getDeviceDisplay().getFullHeight()); displayGraphics = displayImage.getImage().getGraphics();