當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。