• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ofFloatImage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了ofFloatImage类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: draw

//----------------------------------------------------------
void ofGLRenderer::draw(ofFloatImage & image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh){
	if(image.isUsingTexture()){
		ofTexture& tex = image.getTextureReference();
		if(tex.bAllocated()) {
			tex.drawSubsection(x,y,z,w,h,sx,sy,sw,sh);
		} else {
			ofLogWarning() << "ofGLRenderer::draw(): texture is not allocated";
		}
	}
}
开发者ID:3snail,项目名称:openFrameworks,代码行数:11,代码来源:ofGLRenderer.cpp


示例2: draw

//----------------------------------------------------------
void ofGLRenderer::draw(const ofFloatImage & image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh) const{
	if(image.isUsingTexture()){
		const ofTexture& tex = image.getTextureReference();
		if(tex.bAllocated()) {
			tex.bind();
			draw(tex.getMeshForSubsection(x,y,z,w,h,sx,sy,sw,sh),false,true,false);
			tex.unbind();
		} else {
			ofLogWarning("ofGLRenderer") << "draw(): texture is not allocated";
		}
	}
}
开发者ID:cooperyoo,项目名称:openFrameworks,代码行数:13,代码来源:ofGLRenderer.cpp


示例3: ofNoise

void
testApp::renderNoise(ofFloatImage &img)
{
    double maxval = 0.0;
    double minval = 10.0;
    
    for (int i = 0; i < img.getWidth(); i++) {
        for (int j = 0; j < img.getHeight(); j++) {
            double sum = 0;
            double scale = 1.0;
            double p[2];
            p[0] = i /(float)img.getWidth() + offset;
            p[1] = j /(float)img.getHeight();
            
            for (int k = 0; k < images.size(); k++) {
                double val = ofNoise(p[0], p[1]);
                images[k].setColor(i, j, val);
                sum += val / scale;
                scale *= alpha;
                p[0] *= beta;
                p[1] *= beta;
            }
            img.setColor(i, j, sum);
            if (sum > maxval)
                maxval = sum;
            if (sum < minval)
                minval = sum;
        }
    }
    
    if (norm) {
        for (int i = 0; i < img.getWidth(); i++) {
            for (int j = 0; j < img.getHeight(); j++) {
                float v = img.getColor(i, j).r;
                img.setColor(i, j, v/maxval);
//                img.setColor(i, j, ofMap(v, 0.0, maxval, 0.0, 1.0));
//                img.setColor(i, j, ofMap(v, minval, maxval, 0.0, 1.0));
            }
        }
    }
    
    img.update();
    
    for (ofFloatImage &i : images)
        i.update();
    
    dirty = false;
    
}
开发者ID:MrMDeluxe,项目名称:generative,代码行数:49,代码来源:testApp.cpp


示例4: renderScene

void renderScene(ofAutoShader& shader, ofFloatImage& xyz, ofFloatImage& confidence) {
    float mx = (float) ofGetMouseX() / ofGetWidth();
    float my = (float) ofGetMouseY() / ofGetHeight();
    shader.begin(); {
        shader.setUniformTexture("xyzMap", xyz, 0);
        shader.setUniformTexture("confidenceMap", confidence, 1);
        shader.setUniform1f("elapsedTime", ofGetElapsedTimef());
        shader.setUniform1i("frameNumber", ofGetFrameNum());
        shader.setUniform2f("mouse", ofVec2f(mx,my));
        xyz.draw(0, 0);
    } shader.end();
}
开发者ID:kylemcdonald,项目名称:LightLeaks,代码行数:12,代码来源:main.cpp


示例5: floor

ofFloatColor DNS::Image::Sample(const ofFloatImage & image, ofVec2f pixelCoordinate)
{
    /*
     
    (0,0)--(1,0)--(2,0)--(3,0)--(4,0)-
      |      |      |      |      |
      |      |      |      |      |
      |      |      |      |      |
    (0,1)--(1,1)--(2,1)--(3,1)--(4,1)-
      |      |      |      |      |
      |      |      |      |      |
      |      |      |      |      |
    (0,2)--(1,2)--(2,2)--(3,2)--(4,2)-
      |      |      |      |      |
     
     */
    
    int col1 = floor(pixelCoordinate.x - 0.5);
    int col2 = col1 + 1;
    col1 = MAX(0, col1);
    col2 = MIN(image.width-1, col2);
    
    int row1 = floor(pixelCoordinate.y - 0.5);
    int row2 = row1 + 1;
    row1 = MAX(0, row1);
    row2 = MIN(image.height-1, row2);
    
    float intPart;
    
    float xAmount = modf(pixelCoordinate.x - 0.5, &intPart);
    float yAmount = modf(pixelCoordinate.y - 0.5, &intPart);
    
    ofFloatColor row1Color = DNS::Color::InterpolateLinear( image.getColor(col1, row1), image.getColor(col2, row1), xAmount );
    ofFloatColor row2Color = DNS::Color::InterpolateLinear( image.getColor(col1, row2), image.getColor(col2, row2), xAmount );
    ofFloatColor finalColor = DNS::Color::InterpolateLinear( row1Color, row2Color, yAmount );
    
    return finalColor;
}
开发者ID:gimlids,项目名称:Cartobiography,代码行数:38,代码来源:Geometry.cpp


示例6: draw

//--------------------------------------------
void ofCairoRenderer::draw(const ofFloatImage & image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh) const{
	ofPixels tmp = image.getPixels();
	draw(tmp,x,y,z,w,h,sx,sy,sw,sh);
}
开发者ID:8morikazuto,项目名称:openFrameworks,代码行数:5,代码来源:ofCairoRenderer.cpp


示例7: getValueFromImagePos

float ofxShadowedTerrain::getValueFromImagePos(ofFloatImage& img, int x, int y){
    return zstretchfact * img.getColor(x,y).getBrightness();
}
开发者ID:robandrose,项目名称:ofxShadowedTerrain,代码行数:3,代码来源:ofxShadowedTerrain.cpp


示例8: draw

//--------------------------------------------------------------
void testApp::draw(){

    int disp_img_w = 153;
    int disp_img_h = 120;
    int disp_img_off_x = 250;
    int disp_img_off_y = 10;
    int spc = 10;

    for (int i = 0; i < images.size(); i++) {
        int row = i / 4;
        int col = i % 4;
        ofPushMatrix();
        ofTranslate(disp_img_off_x + (disp_img_w + spc) * col, disp_img_off_y + (disp_img_h + spc) * row);
        images[i].draw(0, 0, disp_img_w, disp_img_h);
        ofPopMatrix();
    }


    ofPushMatrix();
    ofTranslate(disp_img_off_x, (disp_img_h + spc) * 2 + spc);
    img.draw(0, 0, 640, 480);
    ofPopMatrix();
    
    gui.draw();
//    ofDrawBitmapString(ofToString(ofGetFrameRate(), 0), 20, ofGetHeight() - 20);
}
开发者ID:MrMDeluxe,项目名称:generative,代码行数:27,代码来源:testApp.cpp


示例9: setup

//--------------------------------------------------------------
void testApp::setup(){
    ofBackground(20);
    ofSetFrameRate(30);
    
    gui.setup("Perlin Noise", "", 20, 20);
    gui.add(alpha.setup("alpha", 2.0, 0.5, 10.0));
    gui.add(beta.setup("beta", 2.0, 0.5, 5.0));
    gui.add(octaveCnt.setup("octaves", 6, 1, 8));
    gui.add(norm.setup("normalize", true));
    gui.add(offset_incr.setup("speed", 0.0, 0.0, 0.2));
    alpha.addListener(this, &testApp::floatValChanged);
    beta.addListener(this, &testApp::floatValChanged);
    octaveCnt.addListener(this, &testApp::octaveCntChanged);
    norm.addListener(this, &testApp::boolValChanged);
    
    img.allocate(img_w, img_h, OF_IMAGE_GRAYSCALE);
    
    for (int i = 0; i < octaveCnt; i++) {
        ofImage tmp;
        tmp.allocate(img_w, img_h, OF_IMAGE_GRAYSCALE);
        images.push_back(tmp);
    }
    
    offset = 0;

}
开发者ID:MrMDeluxe,项目名称:generative,代码行数:27,代码来源:testApp.cpp


示例10: draw

 void draw() {
     ofEnableAlphaBlending();
     ofSetColor(255);
     ofHideCursor();
     
     renderScene(shader, xyzMap, confidenceMap);
     
     if (server->getDebug()) {
         speakerXyzMap.draw(mouseX, mouseY);
         speakerFbo.draw(mouseX, mouseY+8);
         string msg = ofToString(id) + ": " + ofToString(round(ofGetFrameRate())) + "fps";
         ofDrawBitmapString(msg, 10, 20);
     }
 }
开发者ID:kylemcdonald,项目名称:LightLeaks,代码行数:14,代码来源:main.cpp


示例11: update

//--------------------------------------------------------------
void ofApp::update(){
	//Update sound engine
	ofSoundUpdate();	
	
	//Get current spectrum with N bands
	float *val = ofSoundGetSpectrum( N ); 
	//We should not release memory of val, 
	//because it is managed by sound engine

	//Update our smoothed spectrum, 
	//by slowly decreasing its values and getting maximum with val
	//So we will have slowly falling peaks in spectrum
	for ( int i=0; i<N; i++ ) {
		spectrum[i] *= 0.95; //0.97;	//Slow decreasing
		spectrum[i] = max( spectrum[i], val[i] );
	}

	//Set spectrum to spectrumImage
	spectrumImage.setFromPixels( spectrum, N, 1, OF_IMAGE_GRAYSCALE );
}
开发者ID:firmread,项目名称:ofDemystified,代码行数:21,代码来源:ofApp.cpp


示例12: setupSpeakers

 void setupSpeakers() {
     ofVec3f speakers[n_speakers];
     // maybe need to swap dimensions here?
     // possibly change scale too
     float eps = 0.001; // needed to avoid "== 0" check in shader
     speakers[0] = ofVec3f(0,0,0)+eps; // front left
     speakers[1] = ofVec3f(0,1,0)+eps; // front right
     speakers[2] = ofVec3f(1,1,0)+eps; // rear right
     speakers[3] = ofVec3f(1,0,0)+eps; // rear left
     
     float speakerAreaSize = 0.02;
     speakerXyzMap.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
     speakerConfidenceMap.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
     
     float* xyzPixels = speakerXyzMap.getPixels().getData();
     float* confidencePixels = speakerConfidenceMap.getPixels().getData();
     for(int i = 0; i < n_speakers; i++){
         for(int j = 0; j < n_samples; j++){
             // sample a spiral
             float angle = j * TWO_PI / 20; // 20 samples per full rotation
             float radius = ((float) j / n_samples) * speakerAreaSize; // 0 to speakerAreaSize
             // might need to swap axes here too
             xyzPixels[0] = speakers[i].x + sin(angle) * radius;
             xyzPixels[1] = speakers[i].y + cos(angle) * radius;
             xyzPixels[2] = speakers[i].z;
             xyzPixels[3] = 1;
             xyzPixels += 4;
             
             confidencePixels[0] = 1;
             confidencePixels[1] = 1;
             confidencePixels[2] = 1;
             confidencePixels[3] = 1;
             confidencePixels += 4;
         }
     }
     speakerXyzMap.update();
     speakerConfidenceMap.update();
     
     speakerFbo.allocate(n_samples, n_speakers);
     speakerPixels.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
 }
开发者ID:kylemcdonald,项目名称:LightLeaks,代码行数:41,代码来源:main.cpp


示例13: draw

//--------------------------------------------------------------
void ofApp::draw(){
	ofEnableAlphaBlending();

	float time = ofGetElapsedTimef();
	float w = ofGetWidth();
	float h = ofGetHeight();

	fbo.begin();
	
	//Draw something on the screen

	//Set a gradient background from white to gray 
	//See "Sharp sphere example" in chapter "Creating in 3D with openFrameworks"
	ofBackgroundGradient( ofColor( 255 ), ofColor( 128 ) );

	ofSetColor( 255, 255, 255 );
	image.draw( 351, 221 );

	fbo.end();

	//Draw first image
	fbo2.begin();	
	ofBackground( 0, 0, 0 );
	float ang = time * 30;
	//ang = 0;

	ofPushMatrix();
	ofTranslate( w/2, h/2 );
	ofRotate( ang );
	ofFill();
	ofSetColor( 255, 255, 255 );
	ofTriangle( -200, -114, 200, -114, 0, 230 );
	ofPopMatrix();

	fbo2.end();

	//Enable shader
	shader.begin();
	
    //pass time value to shader
	shader.setUniform1f("time", time );
			
	//we also pass in the mouse position 
	//we have to transform the coords to what the shader is expecting which is 0,0 in the center and y axis flipped. 
	//shader.setUniform2f("mouse", mouseX - ofGetWidth()/2, ofGetHeight()/2-mouseY );
	shader.setUniformTexture( "texture1", fbo2.getTextureReference(), 1 ); //"1" means that it is texture 1

	shader.setUniformTexture( "texture2", spectrumImage.getTextureReference(), 2 ); //"2" means that it is texture 2

	//shader.setUniform1i( "N", N );
	shader.setUniform1fv( "specArray", spectrum, N );

	//Draw image through shader
	ofSetColor( 255, 255, 255 );
	fbo.draw( 0, 0 );

	//ofSetColor( 255, 255, 255, 128 );
	//fbo2.draw( 0, 0 );

	shader.end();

	//Draw spectrum
/*	ofFill();
	ofSetColor( 0, 255, 0 ); 
	for (int i=0; i<N; i++) {
		ofRect( w/2 + i * 7, h/2, 7, -spectrum[i] * 100 );
	}

	ofSetColor( 255, 255, 255 );
	spectrumImage.draw( w/2, 0, N*7, 50 );
	*/
}
开发者ID:firmread,项目名称:ofDemystified,代码行数:73,代码来源:ofApp.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ofFloatPixels类代码示例发布时间:2022-05-31
下一篇:
C++ ofFile类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap