void setup(){ ofSetVerticalSync(false); w=ofGetScreenWidth(); h=ofGetScreenHeight(); ofDisableArbTex(); img.load("1.jpg"); player.load("1.mp4"); player.play(); player.setLoopState(OF_LOOP_NORMAL); gray = img; gray.setImageType(OF_IMAGE_GRAYSCALE); wc.load("wcolor.vert","wcolor.frag"); ofFbo::Settings s; s.depthStencilAsTexture=true; s.useDepth=true; s.width=w; s.height=h; fboDepth.allocate(s); fbo.allocate(w,h); fbo.begin(); ofClear(0,0,100,255); fbo.end(); gui.setup(); gui.add(stepGradient.set("step gradient", .0015, -1., 1.)); gui.add(advectStep.set("step advect", .0015, -.1, .1)); gui.add(flipHeightMap.set("flip height map", 0.7, 0., 2.)); gui.add(time.set("time", 0., 0., 1.)); gui.add(advectMatrix.set("advect matrix", ofVec4f(0.1), ofVec4f(-1.), ofVec4f(1.))); gui.add(switchVideo.set("switch video", false)); }
void makeTransparent(ofImage &img) { img.setImageType(OF_IMAGE_COLOR_ALPHA); //make sure it can have alphas for(int i = 3; i < img.height*img.width*4; i+=4){ if(img.getPixels()[i-1]==0) { //if blue is 0 make pixel transparent img.getPixels()[i]=0; } } img.update(); }
void loadImage(string filePath) { vector<string>hierarchy = ofSplitString(filePath, "/"); if (hierarchy.size() > 1) cur_file = hierarchy.back(); else cur_file = filePath; img1.loadImage(filePath); img1.resize(w, h); img1.setImageType(OF_IMAGE_GRAYSCALE); synthImage(); }
void captureApp::generateSpotlight(ofImage& img) { int diffusion = 100; img.setImageType(OF_IMAGE_GRAYSCALE); unsigned char* pixels = img.getPixels(); int w = img.getWidth(); int h = img.getHeight(); float maxDistance = (w < h ? w : h) / 2; for(int y = 0; y < h; y++) { for(int x = 0; x < w; x++) { int i = y * w + x; int xrand = ofRandom(-diffusion, diffusion); int yrand = ofRandom(-diffusion, diffusion); pixels[i] = pow(ofMap(ofDist(w / 2, h / 2, x + xrand, y + yrand), 0, maxDistance, 1, 0, true), 4) * 255; } } img.update(); }