当前位置: 首页>>代码示例>>Java>>正文


Java PImage.updatePixels方法代码示例

本文整理汇总了Java中processing.core.PImage.updatePixels方法的典型用法代码示例。如果您正苦于以下问题:Java PImage.updatePixels方法的具体用法?Java PImage.updatePixels怎么用?Java PImage.updatePixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在processing.core.PImage的用法示例。


在下文中一共展示了PImage.updatePixels方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSprite

import processing.core.PImage; //导入方法依赖的package包/类
static public PImage createSprite(PApplet papplet, int size, float exp1, float exp2, float mult){
  size = Math.max(32, size);
  
  PImage pimg = papplet.createImage(size, size, PConstants.ARGB);
  pimg.loadPixels();
  for(int y = 0; y < size; y++){
    for(int x = 0; x < size; x++){
      int pid = y * size + x;
      
      float xn = ((x+0.5f) / (float)size) * 2f - 1f;
      float yn = ((y+0.5f) / (float)size) * 2f - 1f;
      float dd = (float) Math.sqrt(xn*xn + yn*yn);
      
      dd = DwUtils.clamp(dd, 0, 1);
      dd = (float) Math.pow(dd, exp1);
      dd = 1.0f - dd;
      dd = (float) Math.pow(dd, exp2);
      dd *= mult;
      dd = DwUtils.clamp(dd, 0, 1);
      pimg.pixels[pid] = ((int)(dd * 255)) << 24 | 0x00FFFFFF;
    }
  }
  pimg.updatePixels();
  return pimg;
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:26,代码来源:DwUtils.java

示例2: KinectPoints

import processing.core.PImage; //导入方法依赖的package包/类
/**
 * Constructs a KinectPoints object from the provided Kinect output data
 * 
 * @param p the parent Processing applet
 * @param points the Kinect 3D points
 * @param rgbImg the Kinect color image
 * @param depthMap the Kinect depth map
 * @param reductionFactor the scale reduction factor
 */
public KinectPoints(PApplet p, PVector[] points, PImage rgbImg, int[] depthMap, int reductionFactor) {
	reductionFactor = Math.max(1, reductionFactor);
	this.p = p;
	this.width = rgbImg.width / reductionFactor;
	this.height = rgbImg.height / reductionFactor;
	this.nPoints = this.width * this.height;
	this.points = new PVector[this.nPoints];
	this.colors = new int[this.nPoints];
	this.visibilityMask = new boolean[this.nPoints];

	// Populate the arrays
	rgbImg.loadPixels();

	for (int row = 0; row < this.height; row++) {
		for (int col = 0; col < this.width; col++) {
			int index = col + row * this.width;
			int indexOriginal = col * reductionFactor + row * reductionFactor * rgbImg.width;
			this.points[index] = points[indexOriginal].copy();
			this.colors[index] = rgbImg.pixels[indexOriginal];
			this.visibilityMask[index] = depthMap[indexOriginal] > 0;
		}
	}

	rgbImg.updatePixels();
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:35,代码来源:KinectPoints.java

示例3: createSprite

import processing.core.PImage; //导入方法依赖的package包/类
static public PImage createSprite(PApplet papplet, int size, float exp1, float exp2, float mult){
  PImage pimg = papplet.createImage(size, size, PConstants.ARGB);
  pimg.loadPixels();
  for(int y = 0; y < size; y++){
    for(int x = 0; x < size; x++){
      int pid = y * size + x;
      
      float xn = ((x + 0.5f) / (float)size) * 2f - 1f;
      float yn = ((y + 0.5f) / (float)size) * 2f - 1f;
      float dd = (float) Math.sqrt(xn*xn + yn*yn);
      
      dd = clamp(dd, 0, 1);
      dd = (float) Math.pow(dd, exp1);
      dd = 1.0f - dd;
      dd = (float) Math.pow(dd, exp2);
      dd *= mult;
      dd = clamp(dd, 0, 1);
      pimg.pixels[pid] = ((int)(dd * 255)) << 24 | 0x00FFFFFF;
    }
  }
  pimg.updatePixels();
  return pimg;
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:24,代码来源:DwUtils.java

示例4: getProjectorImage

import processing.core.PImage; //导入方法依赖的package包/类
public PImage getProjectorImage(PApplet applet, int projWidth, int projHeight) {

        PImage projectorImage = applet.createImage(projWidth, projHeight, RGB);
        projectorImage.loadPixels();
        refImage.loadPixels();

        int imSize = width * height;
        for (int i = 0; i < imSize; i++) {
            if (validMask[i]) {
                int x = decodedX[i];
                int y = decodedY[i];

                int offset = y * projWidth + x;
                projectorImage.pixels[offset] = refImage.pixels[i];
            }
        }

        projectorImage.updatePixels();
        return projectorImage;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:21,代码来源:DecodedCode.java

示例5: getProjectorImageScaled

import processing.core.PImage; //导入方法依赖的package包/类
public PImage getProjectorImageScaled(PApplet applet, int projWidth, int projHeight, int precision) {

        PImage projectorImage = applet.createImage(projWidth / precision, projHeight / precision, RGB);
        projectorImage.loadPixels();
        refImage.loadPixels();

        int imSize = width * height;
        for (int i = 0; i < imSize; i++) {
            if (validMask[i]) {
                int x = decodedX[i];
                int y = decodedY[i];

                x = x / precision;
                y = y / precision;
                int offset = y * projWidth / precision + x;
                projectorImage.pixels[offset] = refImage.pixels[i];
            }
        }

        projectorImage.updatePixels();
        return projectorImage;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:23,代码来源:DecodedCode.java

示例6: set

import processing.core.PImage; //导入方法依赖的package包/类
protected void set(String theText, final int theColor, final int theCursorPosition, final int theOffsetX) {
	_myOffsetX = theOffsetX;
	_myCursorPosition = theCursorPosition;
	if (theText == null) {
		theText = "";
	}
	_myText = theText;
	// this conflicts with setting the captionLabel with
	// controller.captionLabel().set("blabla");
	if (!isControlFont) {
		if (!isFixedSize) {
			// !!! take out +8, there is still some issues with calculating
			// the
			// width of a label, assuming its an issue with upper and lower
			// case
			// of theText.
			int myWidth = bitFontRenderer.getWidth(this); // + 8
			if (myWidth > _myWidth) {
				_myWidth = myWidth;
				_myImage = new PImage(myWidth, _myHeight);
				_myImageMask = new PImage(_myWidth, _myHeight);
			}
		}

		_myColor = theColor;
		textHeight = bitFontRenderer.write(this);
		_myImage.updatePixels();
	}
}
 
开发者ID:hyounesy,项目名称:ChAsE,代码行数:30,代码来源:Label.java

示例7: light

import processing.core.PImage; //导入方法依赖的package包/类
/**
 * Burn lighting onto decal.
 */
public void light() {
	
	// Generate alpha map.
	PImage alpha = sprite.get();
	alpha.loadPixels();
	for (int i = 0; i < alpha.pixels.length; i ++) {
		alpha.pixels[i] = ((alpha.pixels[i] >> 8) & 0xFFFFFF) << 8 | (alpha.pixels[i] >> 24) & 0xFF;
	}
	alpha.updatePixels();
	
	// Create the light map.
	PImage lightMapCopy = pie.app.createImage(sprite.width, sprite.height, PConstants.ARGB);
	
	// Copy light map portion from main light map image.
	if (!isTile) {
		for (int i = 0; i <= objFrames; i++) {
			lightMapCopy.copy(pie.lightMap, x, y, objWidth, objHeight, i * objWidth, 0, objWidth, objHeight);
		}
	} else {
		lightMapCopy.copy(pie.lightMap, x, y, objWidth, objHeight, 0, 0, objWidth, objHeight);
	}
	
	// Add on ilumMap if any, using SCREEN blend mode.
	if (IlumSprite != null) {
		lightMapCopy.blend(IlumSprite, 0, 0, sprite.width, sprite.height, 0, 0, sprite.width, sprite.height, PConstants.SCREEN);
		IlumSprite = null;		// We don't need this anymore, free resources.
	}
	
	// Burn light map onto sprite.
	sprite.blend(lightMapCopy, 0, 0, sprite.width, sprite.height, 0, 0, sprite.width, sprite.height, PConstants.MULTIPLY);
	
	// Re-apply the original alpha onto the lighted sprite.
	sprite.mask(alpha);
}
 
开发者ID:AliasBlack,项目名称:pixelpie,代码行数:38,代码来源:decal.java

示例8: createGradientImg

import processing.core.PImage; //导入方法依赖的package包/类
/**
 * Creates an image with a circular color gradient
 * 
 * @param p the parent Processing applet
 * @param centralColor the image central color
 * @param borderColor the image border color
 * @return the image with the circular color gradient
 */
public static PImage createGradientImg(PApplet p, int centralColor, int borderColor) {
	// Create the image with the same dimensions as the sketch applet
	PImage img = p.createImage(p.width, p.height, PApplet.RGB);

	// Set the image pixel colors
	float rowCenter = 0.5f * img.height;
	float colCenter = 0.5f * img.width;
	float maxRadiusSq = PApplet.sq(colCenter) + PApplet.sq(rowCenter);
	int centralRed = (centralColor >> 16) & 0xff;
	int centralGreen = (centralColor >> 8) & 0xff;
	int centralBlue = centralColor & 0xff;
	int borderRed = (borderColor >> 16) & 0xff;
	int borderGreen = (borderColor >> 8) & 0xff;
	int borderBlue = borderColor & 0xff;

	img.loadPixels();

	for (int row = 0; row < img.height; row++) {
		for (int col = 0; col < img.width; col++) {
			float relativeDist = PApplet
					.sqrt((PApplet.sq(col - colCenter) + PApplet.sq(row - rowCenter)) / maxRadiusSq);
			int pixelRed = Math.round((1 - relativeDist) * centralRed + relativeDist * borderRed);
			int pixelGreen = Math.round((1 - relativeDist) * centralGreen + relativeDist * borderGreen);
			int pixelBlue = Math.round((1 - relativeDist) * centralBlue + relativeDist * borderBlue);
			img.pixels[col + row * img.width] = (pixelRed << 16) | (pixelGreen << 8) | pixelBlue | 0xff000000;
		}
	}

	img.updatePixels();

	return img;
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:41,代码来源:ImageHelper.java

示例9: createAnaglyph

import processing.core.PImage; //导入方法依赖的package包/类
public static void createAnaglyph(PImage imgL, PImage imgR, PImage imgOut) {
    imgL.loadPixels();
    imgR.loadPixels();
    imgOut.loadPixels();
    int[] pL = imgL.pixels;
    int[] pR = imgR.pixels;
    int[] pO = imgOut.pixels;
    for (int i = 0; i < pL.length; i++) {
        pO[i] = (pR[i] >> 16) << 16 | (pL[i] >> 8) & 255 << 8 | pL[i] & 255;
        //            pO[i] = pL[i];
    }
    imgOut.updatePixels();
    //        imgL.updatePixels();
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:15,代码来源:ImageUtils.java

示例10: applyTransColor

import processing.core.PImage; //导入方法依赖的package包/类
private void applyTransColor(PImage source, String c){
  int trans = this.readColor(c);
  source.loadPixels();
  for (int p = 0; p < source.pixels.length; p++) if(source.pixels[p] == trans) source.pixels[p] = parent.color(255, 1);
  source.updatePixels();
}
 
开发者ID:linux-man,项目名称:ptmx,代码行数:7,代码来源:Ptmx.java

示例11: fastblur

import processing.core.PImage; //导入方法依赖的package包/类
/**
 * Super Fast Blur (by Mario Klingemann <http://incubator.quasimondo.com>)
 * @param img
 * @param radius
 */
private static void fastblur(PImage img, int radius) {
	if (radius < 1) {
		return;
	}
	img.loadPixels();
	int w = img.width;
	int h = img.height;
	int wm = w - 1;
	int hm = h - 1;
	int wh = w * h;
	int div = radius + radius + 1;
	int r[] = new int[wh];
	int g[] = new int[wh];
	int b[] = new int[wh];
	int rsum, gsum, bsum, x, y, i, p, p1, p2, yp, yi, yw;
	int vmin[] = new int[PApplet.max(w, h)];
	int vmax[] = new int[PApplet.max(w, h)];
	int[] pix = img.pixels;
	int dv[] = new int[256 * div];
	for (i = 0; i < 256 * div; i++) {
		dv[i] = (i / div);
	}
	yw = yi = 0;
	for (y = 0; y < h; y++) {
		rsum = gsum = bsum = 0;
		for (i = -radius; i <= radius; i++) {
			p = pix[yi + PApplet.min(wm, PApplet.max(i, 0))];
			rsum += (p & 0xff0000) >> 16;
		gsum += (p & 0x00ff00) >> 8;
	bsum += p & 0x0000ff;
		}
		for (x = 0; x < w; x++) {
			r[yi] = dv[rsum];
			g[yi] = dv[gsum];
			b[yi] = dv[bsum];
			if (y == 0) {
				vmin[x] = PApplet.min(x + radius + 1, wm);
				vmax[x] = PApplet.max(x - radius, 0);
			}
			p1 = pix[yw + vmin[x]];
			p2 = pix[yw + vmax[x]];
			rsum += ((p1 & 0xff0000) - (p2 & 0xff0000)) >> 16;
		gsum += ((p1 & 0x00ff00) - (p2 & 0x00ff00)) >> 8;
	bsum += (p1 & 0x0000ff) - (p2 & 0x0000ff);
	yi++;
		}
		yw += w;
	}
	for (x = 0; x < w; x++) {
		rsum = gsum = bsum = 0;
		yp = -radius * w;
		for (i = -radius; i <= radius; i++) {
			yi = PApplet.max(0, yp) + x;
			rsum += r[yi];
			gsum += g[yi];
			bsum += b[yi];
			yp += w;
		}
		yi = x;
		for (y = 0; y < h; y++) {
			pix[yi] = 0xff000000 | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
			if (x == 0) {
				vmin[y] = PApplet.min(y + radius + 1, hm) * w;
				vmax[y] = PApplet.max(y - radius, 0) * w;
			}
			p1 = x + vmin[y];
			p2 = x + vmax[y];
			rsum += r[p1] - r[p2];
			gsum += g[p1] - g[p2];
			bsum += b[p1] - b[p2];
			yi += w;
		}
	}
	img.updatePixels();
}
 
开发者ID:AliasBlack,项目名称:pixelpie,代码行数:81,代码来源:levelLoader.java


注:本文中的processing.core.PImage.updatePixels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。