/** * Returns a copy of this PImage. Equivalent to get(0, 0, width, height). * Deprecated, just use copy() instead. */ public PImage get() { // Formerly this used clone(), which caused memory problems. // http://code.google.com/p/processing/issues/detail?id=42 return get(0, 0, pixelWidth, pixelHeight); }
/** * Duplicate an image, returns new PImage object. * The pixels[] array for the new object will be unique * and recopied from the source image. This is implemented as an * override of Object.clone(). We recommend using get() instead, * because it prevents you from needing to catch the * CloneNotSupportedException, and from doing a cast from the result. */ @Override public Object clone() throws CloneNotSupportedException { // ignore return get(); }
/** * Returns a copy of this PImage. Equivalent to get(0, 0, width, height). */ public PImage get() { // Formerly this used clone(), which caused memory problems. // http://code.google.com/p/processing/issues/detail?id=42 return get(0, 0, width, height); }
/** * Duplicate an image, returns new PImage object. * The pixels[] array for the new object will be unique * and recopied from the source image. This is implemented as an * override of Object.clone(). We recommend using get() instead, * because it prevents you from needing to catch the * CloneNotSupportedException, and from doing a cast from the result. */ @Override public Object clone() throws CloneNotSupportedException { // ignore return get(); }
public PImage copy() { return get(0, 0, pixelWidth, pixelHeight); }
public PImage getReversePImage( PImage image ) { PImage reverse = new PImage( image.width, image.height ); for( int i=0; i < image.width; i++ ){ for(int j=0; j < image.height; j++){ reverse.set( image.width - 1 - i, j, image.get(i, j) ); } } return reverse; }
PImage sand,fossil; int side = 40;//size of square 'brush' void setup() { size(400, 400); fossil = loadImage("CellNoise.jpg"); sand = loadImage("CellVoronoi.jpg"); } void draw() { image(fossil, 0, 0, 400, 400); if(mousePressed) { for(int y = 0 ; y < side ; y++){ for(int x = 0; x < side; x++){ //copy pixel from 'bottom' image to the top one //map sketch dimensions to sand/fossil an dimensions to copy from/to right coords int srcX = (int)map(mouseX+x,0,width+side,0,sand.width); int srcY = (int)map(mouseY+y,0,height+side,0,sand.height); int dstX = (int)map(mouseX+x,0,width+side,0,fossil.width); int dstY = (int)map(mouseY+y,0,height+side,0,fossil.height); fossil.set(dstX, dstY, sand.get(srcX,srcY)); } } } }
yourY -= floor(widthOfBrush / 2); PImage brushImage = img1.get((int)yourX, (int)yourY, widthOfBrush * (width / img1.width), widthOfBrush * (width / img1.width)); //Draw the image at your destination image(brushImage, mouseX, mouseY);
@Override protected void setImpl(PImage sourceImage, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int targetX, int targetY) { WritableRaster raster = getRaster(); // ((BufferedImage) (useOffscreen && primarySurface ? offscreen : image)).getRaster(); if ((sourceX == 0) && (sourceY == 0) && (sourceWidth == sourceImage.pixelWidth) && (sourceHeight == sourceImage.pixelHeight)) { // System.out.format("%d %d %dx%d %d%n", targetX, targetY, // sourceImage.width, sourceImage.height, // sourceImage.pixels.length); raster.setDataElements(targetX, targetY, sourceImage.pixelWidth, sourceImage.pixelHeight, sourceImage.pixels); } else { // TODO optimize, incredibly inefficient to reallocate this much memory PImage temp = sourceImage.get(sourceX, sourceY, sourceWidth, sourceHeight); raster.setDataElements(targetX, targetY, temp.pixelWidth, temp.pixelHeight, temp.pixels); } }
if (src == this) { if (intersect(sx, sy, sx2, sy2, dx, dy, dx2, dy2)) { blit_resize(get(sx, sy, sx2 - sx, sy2 - sy), 0, 0, sx2 - sx - 1, sy2 - sy - 1, pixels, width, height, dx, dy, dx2, dy2, mode);
if (src == this) { if (intersect(sx, sy, sx2, sy2, dx, dy, dx2, dy2)) { blit_resize(get(sx, sy, sw, sh), 0, 0, sw, sh, pixels, pixelWidth, pixelHeight, dx, dy, dx2, dy2, mode);