/** * Use the getNative() method instead, which allows library interfaces to be * written in a cross-platform fashion for desktop, Android, and others. * This is still included for PGraphics objects, which may need the image. */ public Image getImage() { // ignore return (Image) getNative(); }
void processHaars(PImage piz) { // convert to IplImage... BufferedImage imgBuf = (BufferedImage) piz.getNative(); opencv_core.IplImage iplImgOut=opencv_core.IplImage.createFrom(imgBuf); for (ii=0; ii<detectors.length; ii++) faces[ii] = opencv_objdetect.cvHaarDetectObjects(iplImgOut, classifier[ii], storage, 1.1, 3, opencv_objdetect.CV_HAAR_DO_CANNY_PRUNING); opencv_core.cvClearMemStorage(storage); }
@Override public void copy(PImage src, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh) { g2.drawImage((Image) src.getNative(), dx, dy, dx + dw, dy + dh, sx, sy, sx + sw, sy + sh, null); }
BufferedImage imgBuf = (BufferedImage) piz.getNative(); opencv_core.IplImage iplImgOut=opencv_core.IplImage.createFrom(imgBuf);
@Override public void setIcon(PImage image) { Image awtImage = (Image) image.getNative(); if (PApplet.platform != PConstants.MACOSX) { frame.setIconImage(awtImage); } else { try { final String td = "processing.core.ThinkDifferent"; Class<?> thinkDifferent = Thread.currentThread().getContextClassLoader().loadClass(td); Method method = thinkDifferent.getMethod("setIconImage", new Class[] { java.awt.Image.class }); method.invoke(null, new Object[] { awtImage }); } catch (Exception e) { e.printStackTrace(); // That's unfortunate } } }
@Override public void setCursor(PImage img, int x, int y) { // Don't set cursorType, instead use cursorType to save the last // regular cursor type used for when cursor() is called. //cursor_type = Cursor.CUSTOM_CURSOR; // this is a temporary workaround for the CHIP, will be removed Dimension cursorSize = Toolkit.getDefaultToolkit().getBestCursorSize(img.width, img.height); if (cursorSize.width == 0 || cursorSize.height == 0) { return; } Cursor cursor = canvas.getToolkit().createCustomCursor((Image) img.getNative(), new Point(x, y), "custom"); canvas.setCursor(cursor); cursorVisible = true; }
public void setCursor(PImage image, int hotspotX, int hotspotY) { Display disp = window.getScreen().getDisplay(); BufferedImage bimg = (BufferedImage)image.getNative(); DataBufferInt dbuf = (DataBufferInt)bimg.getData().getDataBuffer(); int[] ipix = dbuf.getData(); ByteBuffer pixels = ByteBuffer.allocate(ipix.length * 4); pixels.asIntBuffer().put(ipix); PixelFormat format = PixelFormat.ARGB8888; final Dimension size = new Dimension(bimg.getWidth(), bimg.getHeight()); PixelRectangle pixelrect = new PixelRectangle.GenericPixelRect(format, size, 0, false, pixels); final PointerIcon pi = disp.createPointerIcon(pixelrect, hotspotX, hotspotY); display.getEDTUtil().invoke(false, new Runnable() { @Override public void run() { window.setPointerVisible(true); window.setPointerIcon(pi); } }); }
shrinkImage((BufferedImage) getNative(), w*pixelDensity, h*pixelDensity);