void setup() { rect = new Draw(0, 0, 0, 0, new PImage()); size (900,600); //rect.display(); }
/** * Creates a new PImage (the datatype for storing images). This provides a fresh buffer of pixels to play with. Set the size of the buffer with the <b>width</b> and <b>height</b> parameters. The <b>format</b> parameter defines how the pixels are stored. See the PImage reference for more information. */ public PImage createImage(int wide, int high, int format) { // return createImage(wide, high, format, null); // } // // // /** // * Preferred method of creating new PImage objects, ensures that a // * reference to the parent PApplet is included, which makes save() work // * without needing an absolute path. // */ // public PImage createImage(int wide, int high, int format, Object params) { PImage image = new PImage(wide, high, format); // if (params != null) { // image.setParams(g, params); // } image.parent = this; // make save() work return image; }
PImage image = new PImage(w, h, format); image.parent = this; // make save() work return image;
protected void readBitmap(DataInputStream is) throws IOException { image = new PImage(width, height, ALPHA); int bitmapSize = width * height; byte[] temp = new byte[bitmapSize]; is.readFully(temp); // convert the bitmap to an alpha channel int w = width; int h = height; int[] pixels = image.pixels; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { pixels[y * width + x] = temp[y*w + x] & 0xff; // System.out.print((image.pixels[y*64+x] > 128) ? "*" : "."); } // System.out.println(); } // System.out.println(); }
protected void readBitmap(DataInputStream is) throws IOException { image = new PImage(width, height, ALPHA); int bitmapSize = width * height; byte[] temp = new byte[bitmapSize]; is.readFully(temp); // convert the bitmap to an alpha channel int w = width; int h = height; int[] pixels = image.pixels; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { pixels[y * width + x] = temp[y*w + x] & 0xff; // System.out.print((image.pixels[y*64+x] > 128) ? "*" : "."); } // System.out.println(); } fromStream = true; // System.out.println(); }
/** * After taking a target, you must call saveTargetAsync() or * returnUnusedTarget(), otherwise one thread won't be able to run */ public PImage getAvailableTarget(int requestedWidth, int requestedHeight, // ignore int format) { try { PImage target; if (targetsCreated < TARGET_COUNT && targetPool.isEmpty()) { target = new PImage(requestedWidth, requestedHeight); targetsCreated++; } else { target = targetPool.take(); if (target.pixelWidth != requestedWidth || target.pixelHeight != requestedHeight) { // TODO: this kills performance when saving different sizes target = new PImage(requestedWidth, requestedHeight); } } target.format = format; return target; } catch (InterruptedException e) { return null; } }
protected PImage wrapTexture(Texture tex) { // We don't use the PImage(int width, int height, int mode) constructor to // avoid initializing the pixels array. PImage img = new PImage(); img.parent = parent; img.width = img.pixelWidth = tex.width; img.height = img.pixelHeight = tex.height; img.format = ARGB; setCache(img, tex); return img; }
/** * After taking a target, you must call saveTargetAsync() or * returnUnusedTarget(), otherwise one thread won't be able to run */ public PImage getAvailableTarget(int requestedWidth, int requestedHeight, // ignore int format) { try { PImage target; if (targetsCreated < TARGET_COUNT && targetPool.isEmpty()) { target = new PImage(requestedWidth, requestedHeight); targetsCreated++; } else { target = targetPool.take(); if (target.width != requestedWidth || target.height != requestedHeight) { target.width = requestedWidth; target.height = requestedHeight; // TODO: this kills performance when saving different sizes target.pixels = new int[requestedWidth * requestedHeight]; } } target.format = format; return target; } catch (InterruptedException e) { return null; } }
public void init(int frameType) { extractedPImage = new PImage(imageWidthPx, imageHeightPx, frameType); initiateImageCoordinates(); }
protected PImage wrapTexture(Texture tex) { // We don't use the PImage(int width, int height, int mode) constructor to // avoid initializing the pixels array. PImage img = new PImage(); img.parent = parent; img.width = tex.width; img.height = tex.height; img.format = ARGB; setCache(img, tex); return img; }
PImage outgoing = new PImage(width, height, RGB);
PImage outgoing = new PImage(width, height, RGB); int index = 768; count /= 3;
public PImage loadImage(String filename) { // return loadImage(filename, null); InputStream stream = createInput(filename); if (stream == null) { System.err.println("Could not find the image " + filename + "."); return null; } // long t = System.currentTimeMillis(); Bitmap bitmap = null; try { bitmap = BitmapFactory.decodeStream(stream); } finally { try { stream.close(); stream = null; } catch (IOException e) { } } // int much = (int) (System.currentTimeMillis() - t); // println("loadImage(" + filename + ") was " + nfc(much)); PImage image = new PImage(bitmap); image.parent = this; // if (params != null) { // image.setParams(g, params); // } return image; }
image = new PImage(width, height, ALPHA); int[] pixels = image.pixels; for (int y = minY; y <= maxY; y++) {
PImage target = new PImage(targetWidth / pixelDensity, targetHeight / pixelDensity, targetFormat, pixelDensity);
PImage target = new PImage(targetWidth, targetHeight, targetFormat);
image = new PImage(width, height, ALPHA); int[] pixels = image.pixels; for (int y = minY; y <= maxY; y++) {
PImage outgoing = new PImage(bi.getWidth(), bi.getHeight()); outgoing.parent = this;
ImageIcon icon = new ImageIcon(getClass().getResource("cursors/" + name + ".png")); PImage img = new PImage(icon.getImage());
shrinkImage((BufferedImage) getNative(), w*pixelDensity, h*pixelDensity); PImage temp = new PImage(img); this.pixelWidth = temp.width; this.pixelHeight = temp.height;