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


Java PImage类代码示例

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


PImage类属于processing.core包,在下文中一共展示了PImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: xmlEvent

import processing.core.PImage; //导入依赖的package包/类
public void xmlEvent(XMLElement element){
	data = element;
	if(!data.getName().contentEquals("data")){
		PApplet.println("SettingsManager:xmlEvent: settings file is not compatible ("+data.getName()+") -> reset");
		data = new XMLElement("data");
		addSettings("default");
		xmlInOut.saveElement(data,settingsPath);
		setup();
	}else if(!data.hasChildren()){
		PApplet.println("SettingsManager:xmlEvent: loaded settings file was empty");
		addSettings("default");
		xmlInOut.saveElement(data,settingsPath);
		setup();
	}else{
		ready = true;
		if(parent.current == 999){
			parent.current = data.getIntAttribute("current");
		}
		PApplet.println("SettingsManager:xmlEvent: successfully loaded");
		if(parent.config){
			parent.configurator.enable();
		}
		parent.textures = new PImage[data.getChild(parent.current).countChildren()];
		parent.createEmptyTextures();
	}
}
 
开发者ID:sebastian-meier,项目名称:projectionMapper,代码行数:27,代码来源:SettingsManager.java

示例3: ControllerSprite

import processing.core.PImage; //导入依赖的package包/类
public ControllerSprite(ControlP5 theControlP5, PImage theImage, int theWidth, int theHeight, int theStates) {
	sprite = theImage;
	width = theWidth;
	height = theHeight;
	wh = width * height;
	_myState = 0;

	// cc - added to support a specified # of states
	// specify total states, not index - e.g.:
	// two total states arg should = 2, even though
	// max state index is 1.

	theStates--;

	// cc - make sure we have at least one state
	_totalStates = (theStates >= 0) ? theStates : 0;

	display = new PImage(theWidth, theHeight);
	display = theControlP5.papplet.createImage(theWidth, theHeight, PApplet.RGB);
	update();

}
 
开发者ID:hyounesy,项目名称:ChAsE,代码行数:23,代码来源:ControllerSprite.java

示例4: putchar

import processing.core.PImage; //导入依赖的package包/类
private void putchar(
		final int theC,
		final int theX,
		final int theY,
		final int theColor,
		boolean theHighlight,
		final PImage theImage,
		final PImage theMask,
		final int theFontIndex) {
	final int myWH = theImage.width * theImage.height;
	final int len = charWidth[theFontIndex][theC] * charHeight[theFontIndex];
	final int w = theY * theImage.width;
	for (int i = 0; i < len; i++) {
		final int xpos = theX + i % charWidth[theFontIndex][theC];
		final int pos = xpos + w + (i / charWidth[theFontIndex][theC]) * theImage.width;
		if (chars[theFontIndex][theC][i] == 0xff000000 && xpos < theImage.width && xpos >= 0 && pos >= 0 && pos < myWH) {
			theImage.pixels[pos] = (!theHighlight) ? theColor : 0xffff0000;
			theMask.pixels[pos] = 0xffffffff;
		}
	}
}
 
开发者ID:hyounesy,项目名称:ChAsE,代码行数:22,代码来源:BitFontRenderer.java

示例5: update

import processing.core.PImage; //导入依赖的package包/类
protected void update() {
	if (isControlFont) {
		ControlP5.papplet.textFont(_myControlFont.getPFont(), _myControlFontSize);
		_myWidth = (int) ControlP5.papplet.textWidth(isToUpperCase ? _myText.toUpperCase() : _myText);
	} else {
		if (!isFixedSize) {
			_myHeight = BitFontRenderer.font[_myFontIndex].height;
			_myWidth = bitFontRenderer.getWidth(this);
			_myWidth += _myText.length() * _myLetterSpacing;

		}
		_myImage = new PImage(_myWidth, _myHeight);
		_myImageMask = new PImage(_myWidth, _myHeight);

		set(_myText, _myColor, _myCursorPosition);
	}
}
 
开发者ID:hyounesy,项目名称:ChAsE,代码行数:18,代码来源:Label.java

示例6: 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

示例7: getImageDecoded

import processing.core.PImage; //导入依赖的package包/类
public PImage getImageDecoded(int imageId, int mode, int differenceThreshold) {

        PImage out = parent.createImage(cameraResX, cameraResY, RGB);
        out.loadPixels();
        this.mode = mode;
        this.threshold = differenceThreshold;

        for (int y = 0; y < cameraResY; y += 1) {
            for (int x = 0; x < cameraResX; x += 1) {
                int offset = x + y * cameraResX;
                boolean newValue = decodePixel(imageId, offset);

                // TODO: bug here ?!
//                if (mode == GrayCode.DECODE_REF) {
//                    newValue = !newValue;
//                }
                out.pixels[offset] = newValue ? 255 : 0;
            }
        }

        return out;

    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:24,代码来源:GrayCode.java

示例8: 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

示例9: remapImage

import processing.core.PImage; //导入依赖的package包/类
public static void remapImage(PVector[] in, PVector[] out, opencv_core.IplImage imgIn, opencv_core.IplImage imgTmp, PImage Pout) {
    opencv_core.CvMat srcPoints;
    opencv_core.CvMat dstPoints;
    int nbPoints = in.length;
    opencv_core.CvMat homography;
    // TODO: no create map
    srcPoints = cvCreateMat(2, in.length, opencv_core.CV_32FC1);
    dstPoints = cvCreateMat(2, in.length, opencv_core.CV_32FC1);
    homography = cvCreateMat(3, 3, opencv_core.CV_32FC1);
    for (int i = 0; i < in.length; i++) {
        srcPoints.put(i, in[i].x);
        srcPoints.put(i + nbPoints, in[i].y);
        dstPoints.put(i, out[i].x);
        dstPoints.put(i + nbPoints, out[i].y);
    }
    cvFindHomography(srcPoints, dstPoints, homography);
    //       It is better to use : GetPerspectiveTransform
    opencv_imgproc.cvWarpPerspective(imgIn, imgTmp, homography);
    // opencv_imgproc.CV_INTER_LINEAR ); //                opencv_imgproc.CV_WARP_FILL_OUTLIERS);
    //                getFillColor());
    IplImageToPImage(imgTmp, false, Pout);
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:23,代码来源:ImageUtils.java

示例10: GrayCode

import processing.core.PImage; //导入依赖的package包/类
public GrayCode(PApplet applet, int width, int height, int downScale) {
    this.parent = applet;
    this.width = width / downScale;
    this.height = height / downScale;
    this.displayWidth = width;
    this.displayHeight = height;
    this.downScale = downScale;

    nbCols = (int) ceil(log2(width));
    colShift = (int) floor((pow(2.0f, nbCols) - width) / 2);

    nbRows = (int) ceil(log2(height));
    rowShift = (int) floor((pow(2.0f, nbRows) - height) / 2);

    nbCodes = nbCols + nbRows + 2;
    grayCodesCaptures = new PImage[nbCodes];
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:18,代码来源:GrayCode.java

示例11: apply

import processing.core.PImage; //导入依赖的package包/类
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  
  List<Object> params = ProcessingUtil.parseParams(stack, 3);
      
  PGraphics pg = (PGraphics) params.get(0);
  
  if (params.get(3) instanceof PImage) {
    pg.set(
      ((Number) params.get(1)).intValue(),
      ((Number) params.get(2)).intValue(),
      (PImage) params.get(3)
    );            
  } else {
    pg.set(
      ((Number) params.get(1)).intValue(),
      ((Number) params.get(2)).intValue(),
      ((Number) params.get(3)).intValue()
    );      
  }
  
  stack.push(pg);
  
  return stack;
}
 
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:26,代码来源:Pset.java

示例12: initParticleShapes

import processing.core.PImage; //导入依赖的package包/类
public void initParticleShapes(){
  papplet.shapeMode(PConstants.CORNER);
  shp_particlesystem = papplet.createShape(PShape.GROUP);
  
  PImage sprite = createSprite(0);
  papplet.colorMode(PConstants.HSB, 360, 100, 100);
  
  for (int i = 0; i < PARTICLE_COUNT; i++) {
    PShape shp_particle = createParticleShape(particles[i], sprite);
    particles[i].setShape(shp_particle);
    if(i != IDX_MOUSE_PARTICLE){
      shp_particlesystem.addChild(shp_particle);
    }
  }
  papplet.colorMode(PConstants.RGB, 255, 255, 255);
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:17,代码来源:ParticleSystem.java

示例13: createImageFrom

import processing.core.PImage; //导入依赖的package包/类
public static opencv_core.IplImage createImageFrom(PImage in) {
        // TODO: avoid this creation !!
        opencv_core.CvSize outSize = new opencv_core.CvSize();
        outSize.width(in.width);
        outSize.height(in.height);
//        System.out.println("inputImage to create an IPL:" + in.width + " " + in.height + " " + in.format);
        opencv_core.IplImage imgOut = null;
        if (in.format == PConstants.RGB) {
            imgOut = cvCreateImage(outSize, opencv_core.IPL_DEPTH_8U, // depth
            3);
        }
        if (in.format == PConstants.ALPHA || in.format == PConstants.GRAY) {
            imgOut = cvCreateImage(outSize, opencv_core.IPL_DEPTH_8U, // depth
            1);
        }
        if (in.format == PConstants.ARGB) {
            imgOut = cvCreateImage(outSize, opencv_core.IPL_DEPTH_8U, // depth
            4);
        }
        //        imgIn.w
        return imgOut;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:23,代码来源:ImageUtils.java

示例14: render

import processing.core.PImage; //导入依赖的package包/类
public void render(PGraphics2D dst, PImage sprite, int display_mode){
    int[] sprite_tex_handle = new int[1];
    if(sprite != null){
      sprite_tex_handle[0] = dst.getTexture(sprite).glName;
    }

    int w = dst.width;
    int h = dst.height;

    dst.beginDraw();
//    dst.blendMode(PConstants.BLEND);
    dst.blendMode(PConstants.ADD);

    context.begin();
    shader_particleRender.begin();
    shader_particleRender.uniform2f     ("wh_viewport", w, h);
    shader_particleRender.uniform2i     ("num_particles", particles_x, particles_y);
    shader_particleRender.uniformTexture("tex_particles", tex_particles.src);
    shader_particleRender.uniformTexture("tex_sprite"   , sprite_tex_handle[0]);
    shader_particleRender.uniform1i     ("display_mode" , display_mode); // 0 ... 1px points, 1 = sprite texture,  2 ... falloff points
    shader_particleRender.drawFullScreenPoints(particles_x * particles_y);
    shader_particleRender.end();
    context.end("ParticleSystem.render");
    
    dst.endDraw();
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:27,代码来源:DwFluidParticleSystem2D.java

示例15: 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


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