Ejemplo n.º 1
0
//--------------------------------------------------------------
void LiveCamGlitch::glitchUpdate(ofPixels _p) {
    
    string compressedFilename = "compressed.jpg";
    
    unsigned char * _c = _p.getData();
    
    float coin = ofRandom(100);
    if (coin > 95) {
        _c = _p.getData() + (int)ofRandom(100);
    }
    
    imgDirectGlitch.setImageType(OF_IMAGE_COLOR);
    
    float _w = baseArch->fassadeCorner[1].x - baseArch->fassadeCorner[0].x;
    float _h = baseArch->fassadeCorner[2].y - baseArch->fassadeCorner[0].y;
    imgDirectGlitch.setFromPixels(_c, videoW * 0.5, videoH, OF_IMAGE_COLOR);
    
    imgDirectGlitch.save(compressedFilename, quality);
    
    ofBuffer file = ofBufferFromFile(compressedFilename);
    int fileSize = file.size();
    char * buffer = file.getData();
    
    int whichByte = (int) ofRandom(fileSize);
    int whichBit = ofRandom(8);
    
    char bitMask;
    if ( whichBit >4 ) {
        bitMask = 1 << whichBit;
    } else {
        bitMask = 7 << whichBit;
    }
    
    buffer[whichByte] |= bitMask;
    
    ofBufferToFile(compressedFilename, file);
    imgDirectGlitch.load(compressedFilename);
    
    //    float coin = ofRandom(100);
    //    if (coin > 95) {
    //        reset();
    //    }
 
}
Ejemplo n.º 2
0
bool ofxPulseSensor::saveBuffer(string _csvFile){

    ofBuffer buffer;
    buffer.append("second,value,BPM,IBI\n");

    for(int i = 0; i < data.size();i++){
        string line;
        line = ofToString(data[i].sec)+","+ofToString(data[i].val)+","+ofToString(data[i].BPM)+","+ofToString(data[i].IBI)+"\n";
        buffer.append(line);
    }
    
    if(ofBufferToFile(_csvFile, buffer)){
        ofLogNotice("Data Saved!");
        return true;
    }else{
        ofLogWarning("failed to save data!");
        return false;
    }
}
Ejemplo n.º 3
0
//--------------------------------------------------------------
void ofApp::update() {
    string curFilename = "compressed.jpg";
    
    int size = img.getWidth();
    
    // keeps the image from getting too big
    if(size < maxSize) {
        img.save(curFilename, quality);
        
        if(ofGetKeyPressed('g')) {
            // this portion glitches the jpeg file
            // first loading the file (as binary)
            ofBuffer file = ofBufferFromFile(curFilename, true);
            int fileSize = file.size();
            char * buffer = file.getData();
            
            // pick a byte offset that is somewhere near the end of the file
            int whichByte = (int) ofRandom(fileSize * glitchStart, fileSize);
            // and pick a bit in that byte to turn on
            int whichBit = ofRandom(8);
            char bitMask = 1 << whichBit;
            // using the OR operator |, if the bit isn't already on this will turn it on
            buffer[whichByte] |= bitMask;
            
            // write the file out like nothing happened
            ofBufferToFile(curFilename, file, true);
            img.load(curFilename);
        } else {
            img.load(curFilename);
            
            // this if switches every other frame
            // resizing up and down breaks the 8x8 JPEG blocks
            if(ofGetFrameNum() % 2 == 0) {
                // resize a little bigger
                img.resize(size + addX, size + addY);
            } else {
                // then resize a little smaller
                img.resize(size - subX, size - subY);
            }
        }
        generation++;
    }
}
Ejemplo n.º 4
0
void ramActorsScene::setupControlPanel()
{
	mLocalPanel = ramGetGUI().getCurrentUIContext();
	rebuildControlPanel();
	
	ofAddListener(mLocalPanel->newGUIEvent, this, &ramActorsScene::onValueChanged);
	
// ignore win32
#ifndef TARGET_WIN32
	/// load Ando_1.tsv if this is the first launch of this application
	string initial_file_path = "Settings/presets/preset.init.xml";
	if (!ofFile::doesFileExist( ramToResourcePath(initial_file_path) ))
	{
		ofBuffer buf("hello ram!");
		ofBufferToFile(ramToResourcePath(initial_file_path), buf);
		loadFile(ramToResourcePath("MotionData/Ando_1.tsv"));
	}
#endif
}
Ejemplo n.º 5
0
//--------------------------------------------------------------
void ofApp::update(){
    videos[0].update();
    videos[0].setSpeed(videoSpeed);
    
    sec = 0;
    
    if (videos[0].getCurrentFrame() >= oneMin) {
        sec = videos[0].getCurrentFrame() / oneMin;
        if (sec == 10) {
            beforeRate = rates[sec][1].asInt();
        }
    }
    videoSpeed = 10;
    currentCluster = cls[sec];

    currentRate = rates[sec][1].asInt();
    scoreRate =  ofMap(currentRate, minMaxRate.x , minMaxRate.y , -1.0, 1.0);
    
    currentTaion = taions[sec][1].asFloat();
    scoreTaion = ofMap(currentTaion, minMaxTaion.x , minMaxTaion.y, -1.0, 1.0);
    myGlitch.ShadeVal[0] =  scoreTaion / 2;
    //cout << myGlitch.ShadeVal[0] << endl;
    
    myGlitch.setFx(OFXPOSTGLITCH_CONVERGENCE,true);

    if (currentCluster == choosedCluster) {
        fileName = targetDate + "_" + ofToString(choosedCluster) + "_frame.csv";
        ofBuffer buffer = ofBufferFromFile(fileName);
        buffer.append(ofBuffer(ofToString(videos[0].getCurrentFrame()) + "\r\n" ));
        
        ofBufferToFile( fileName, buffer );
        videoSpeed = 1;
        myGlitch.setFx(OFXPOSTGLITCH_CONVERGENCE,false);
    }
    
    fbos[0].begin();
    videos[0].draw(0, 0, videoSize.x, videoSize.y);
    fbos[0].end();
}
Ejemplo n.º 6
0
void ScriptReader::readTXTWithoutReturn(string url)
{
    ofFile file;
    
    file.open(ofToDataPath(url), ofFile::ReadWrite, false);
    
    buffer = file.readToBuffer();
    
    string theText = buffer.getText();
    
    std::cout<<"text: "<<theText<<endl;
    
    for (int i = 1; i < theText.size(); i++) {
        if (theText[i] == ' ') {
            if (theText[i-1] == ',' || theText[i-1] == '.') {
                theText[i] = '\n';
            }
        }
    }
    
    std::cout<<"text: "<<theText<<endl;
    
    ofBuffer newBuffer;
    
    newBuffer.set(theText.c_str(), theText.size());
    
    int k = 0;
    while(!newBuffer.isLastLine()){
        k++;
        std::cout<<"k = "<<k<<endl;
        newBuffer.getNextLine();
    }
    
    
    std::cout<<"ofToDataPath(url): "<<ofToDataPath(url)<<endl;
    bool filewritten = ofBufferToFile(ofToDataPath(url), newBuffer);
    std::cout<<"Written? "<<(filewritten?"Yes":"No")<<endl;
}
Ejemplo n.º 7
0
void BookView::savePageLayout(){
    ofBuffer buff;
    string wholeXML;
    ofFile outFile;
    
    for(int i=0;i<mediaPages.size();i++){
        string myString;
        ofxXmlSettings xml = mediaPages.at(i)->getXML();
        xml.copyXmlToString(myString);
        wholeXML += myString;
    }
    cout << wholeXML << endl;
    
    buff.set(wholeXML);
    
    bool written = ofBufferToFile("settings/book.xml", buff);
    
    if (written) {
        ofLogNotice() << "Media object positions saved to book.xml";
    }
    else {
        ofLogNotice() << "Error writing media object positions to positions.xml";
    }
}
Ejemplo n.º 8
0
//--------------------------------------------------------------
void testApp::update(){
	kinect.update(); //kinectの更新
	bd.updateFFT(); //beatDetect の更新
	
    //kinectRectDraw における矩形の大きさ
	if (step < 1) {
		step = 1;
	}
	
    //tweetの毎フレームごとの更新
	for (int i = 0; i < ofxBMath.size(); i++) {
		ofxBMath[i].update();
	}

    //tweetの音と同期した更新
	if (bd.isKick() || bd.isSnare() || bd.isHat()) {
		for (int i = 0; i < ofxBMath.size(); i++) {
			ofxBMath[i].update();
		}
	}
	
	if (stringShow) {
		alpha += 3;
	} else {
		alpha = 0;
	}

	kinectVJ.distanceUpdate(_distance);
	kinectVJ.getMoveReset();

    //サーチワードの位置の計算
	ofRectangle searchRect = font_title.getStringBoundingBox(wSearch, 0,0);
	searchX -= 3;
	searchY = ofGetHeight() / 2 + searchRect.height / 2;
	if (searchX < 0 - searchRect.width) {
		searchX = searchRect.width;
	}
    
    //tweet表示のチックをなくす
	kick_timer++;

    //グリッチ処理
	if (glitch_on) {
		//Jpeg圧縮したデータの保存ファイル名
		string compressedFilename = "Glitch.jpg";
		
		//イメージデータをJpeg圧縮して保存
		img.saveImage(compressedFilename, quality);
		
		ofBuffer file = ofBufferFromFile(compressedFilename);
		int fileSize = file.size();
		char * buffer = file.getBinaryBuffer();
		
		//データを破壊する場所をランダムに決定
		int whichByte = (int) ofRandom(fileSize);
		int whichBit = ofRandom(8);
		char bitMask = 1 << whichBit;
		buffer[whichByte] |= bitMask;
		
		//glitchしたファイルをまた再度読込み
		ofBufferToFile(compressedFilename, file);
		img.loadImage(compressedFilename);
	}

}
Ejemplo n.º 9
0
void ofApp::saveRects(){
    
    string _filename = "boxFile";
    ofFile outFile;
    string text;
    
    //add standard header data
    text += "<dataset>\n";
    text += "<name>Training People from overhead</name>\n";
    text += "<comment>These are images from me.</comment>\n";
    
    text += "<images>\n";
    
   
    //check if we already have such a file and read its data
    bool bSuccess = outFile.open(ofToDataPath(_filename+".xml"), ofFile::ReadWrite, false);
    if(bSuccess == true){
         ofBuffer old_textBuffer = outFile.readToBuffer();
        
        if(old_textBuffer.size()) {
            bool startAdding = false;
            
            for (ofBuffer::Line it = old_textBuffer.getLines().begin(), end = old_textBuffer.getLines().end(); it != end; ++it) {
                
                string line = *it;
                
                // copy the line to draw later
                // make sure its not a empty line
    
                
            
                if(line == "</images>"){
                    startAdding = false;
                }
                
                if(line.empty() == false && startAdding == true) {
                    text += line;
                    text += "\n";
                    // print out the line
                    cout << line << endl;
                }else{
                     cout <<"---bad line--"<< line << endl;
                }
                
                if(line == "<images>"){
                    startAdding = true;
                }
                
              
                
            }
            
        }
    }
    
   
   //append new data
    string bmpFileName;
    bmpFileName = imageFileNames[currentIndex];
    text += "<image file='"+bmpFileName+"'>\n";
    
    for(int i=0; i<allRects.size();i++){
        text += "<box top='" + ofToString(allRects[i].y) + "' left='" + ofToString(allRects[i].x) + "' width='" + ofToString(allRects[i].getWidth())+ "' height='" + ofToString(allRects[i].getHeight())+"'/>\n";
    }
    text += "</image>\n";
    
    
    text += "</images>\n";
    text += "</dataset>\n";
    
 ofBuffer new_textBuffer;
    new_textBuffer.set(text);
    // fill the buffer with something important
    bool fileWritten = ofBufferToFile(_filename+".xml", new_textBuffer);
    
    allRects.clear();

}
void BaseEngine::writeFile()
{
	//TODO not currently setup to allow recording after setup
	if (!omxCameraSettings.doRecording) 
	{
		return;
	}
	//format is raw H264 NAL Units
	ofLogVerbose(__func__) << "START";
	stopThread();
	ofLogVerbose(__func__) << "THREAD STOPPED";
	stringstream fileName;
	fileName << ofGetTimestampString() << "_";
	
	fileName << omxCameraSettings.width << "x";
	fileName << omxCameraSettings.height << "_";
	fileName << omxCameraSettings.framerate << "fps_";
	
	fileName << numMBps << "MBps_";
	
	fileName << recordedFrameCounter << "numFrames";
	
	string mkvFilePath = fileName.str() + ".mkv";
	
	fileName << ".h264";
	
	string filePath;
	
	if (omxCameraSettings.recordingFilePath == "") 
	{
		filePath = ofToDataPath(fileName.str(), true);
	}else
	{
		filePath = omxCameraSettings.recordingFilePath;
	}
	
	didWriteFile = ofBufferToFile(filePath, recordingFileBuffer, true);
	if(didWriteFile)
	{
		ofLogVerbose(__func__) << filePath  << " WRITE PASS";
		if (omxCameraSettings.doConvertToMKV) 
		{
			ofFile mkvmerge("/usr/bin/mkvmerge");
			if(mkvmerge.exists())
			{
				string mkvmergePath = ofToDataPath("/usr/bin/mkvmerge", true);
				ofLogVerbose(__func__) << filePath << " SUCCESS";
				stringstream commandString;
				commandString << "/usr/bin/mkvmerge -o ";
				commandString << ofToDataPath(mkvFilePath, true);
				commandString << " " << filePath;
				commandString << " &";
				string commandName = commandString.str();
				ofLogVerbose(__func__) << "commandName: " << commandName;
				//ofSystem(commandName);
				
				int commandResult = system(commandName.c_str());
				ofLogVerbose(__func__) << "commandResult: " << commandResult;
			}else 
			{
				ofLogError(__func__) << "COULD NOT FIND mkvmerge, try: sudo apt-get install mkvtoolnix";
			}
			
		}
		
		
	}else
	{
		ofLogVerbose(__func__) << filePath << " FAIL";
	}
}
Ejemplo n.º 11
0
bool ramTSVCoder::encode(ramSession &src)
{
	if (src.getNumFrames() <= 0)
	{
		cout << "session seems not to have any data to save." << endl;
		return false;
	}
	
	ofBuffer buf;
	
	ramNodeArray& sample = src.getFrame(0);
	
	
	const string timestampStr = ofGetTimestampString("%Y.%m.%d_%H.%M.%S");
	const string address = sample.isActor() ? RAM_OSC_ADDR_ACTOR : RAM_OSC_ADDR_RIGID_BODY;
	const string entityName = sample.getName() + " " + timestampStr;
	const string numJoints = ofToString( sample.getNumNode() );
	
	for(int i=0; i<src.getNumFrames(); i++)
	{
		ramNodeArray &nodeArray = src.getFrame(i);
		stringstream frame;
		frame << address << "\t" << entityName << "\t" << numJoints << "\t";
		
		for(int j=0; j<nodeArray.getNumNode(); j++)
		{
			const ramNode& node = nodeArray.getNode(j);
			const string& name = node.getName();
			const ofVec3f &pos = node.getPosition();
			float qangle, qx, qy, qz;
			node.getOrientationQuat().getRotate(qangle, qx, qy, qz);
			
			frame
			<< name << "\t"
			<< ofToString(pos.x) << "\t"
			<< ofToString(pos.y) << "\t"
			<< ofToString(pos.z) << "\t"
			<< ofToString(qangle) << "\t"
			<< ofToString(qx) << "\t"
			<< ofToString(qy) << "\t"
			<< ofToString(qz) << "\t";
		}
		
		const float timestamp = nodeArray.getTimestamp();
		frame << ofToString(timestamp) << "\n";
		
		buf.append(frame.str().c_str(), frame.str().length());
	}
	
	const string fileName = mFileName.empty() ? timestampStr + "_" + entityName + ".tsv" : mFileName;

	const bool succeeded = ofBufferToFile(fileName, buf, true);
	
	if (succeeded)
	{
		cout << "[" << __FUNCTION__ << "] " << "Save succeeded! " << endl;
		cout << "[" << __FUNCTION__ << "] " << "File name:" << fileName << endl;
		cout << "[" << __FUNCTION__ << "] " << "Duration: " << src.getDuration() << "sec"<< endl;
		cout << "[" << __FUNCTION__ << "] " << "Frames: " << src.getNumFrames() << endl;
		cout << "[" << __FUNCTION__ << "] " << "Size: " << buf.size() * 0.001 << "KB" << endl << endl;
	}
	else
	{
		cout << "[" << __FUNCTION__ << "] " << "save failed.";
	}
	
	return succeeded;
}
Ejemplo n.º 12
0
	bool Camera::savePhoto(string filename) {
		return ofBufferToFile(filename, photoBuffer, true);
	}
Ejemplo n.º 13
0
void testApp::logEnd(){
	ofBufferToFile(logFilename, log);	
}
Ejemplo n.º 14
0
void ofApp::exit() {
	ofBufferToFile("log.txt", log);
	sendCommand("stop");
}
Ejemplo n.º 15
0
void Project::_saveFile(const Json::Value& fileData)
{
    ofBuffer fileBuffer(fileData["fileContents"].asString());
    ofBufferToFile(getPath() + "/sketch/" + fileData["fileName"].asString(), fileBuffer);
}
Ejemplo n.º 16
0
void testApp::update() {
    //mCurrentTime = mTime->getTimeSecs();
    if(bSetup){
        cameraOne->update();
        if(mNumCameras == 0){
            mNumCameras = cameraOne->numCameras();
            mCameraMap = cameraOne->getSerialMap();
            mCaptureSize.set((ofGetWidth())/mNumCameras, 0);
            gui->addSpacer(255-2*OFX_UI_GLOBAL_WIDGET_SPACING, 2);
            gui->addWidgetDown(new ofxUILabel("CAMERAS", OFX_UI_FONT_MEDIUM));
            for(map<int, string>::iterator itr = mCameraMap.begin(); itr!=mCameraMap.end(); ++itr){
                CameraMapping[itr->second] = "";
                
                gui->addWidgetDown(new ofxUIButton("Cameria:"+ofToString(itr->first)+" serial: "+itr->second, false, 16, 16));
                //gui->addWidget(new ofxUITextInput(itr->second, ofToString(itr->first), OFX_UI_FONT_MEDIUM));
            }
            gui->autoSizeToFitWidgets();
        }
        if(cameraOne->isPhotoNew()) {
            mNewPhoto = true;
            map<string, ofBuffer> images = cameraOne->getImages();
            string dir = ofGetTimestampString();
            ofDirectory::createDirectory(ofGetTimestampString(), true);
            for(map<string, ofBuffer>::iterator itr = images.begin(); itr!=images.end(); ++itr){
                string filename = itr->first;
                if(itr->first == "292074032994"){
                    filename = "1";
                }else if(itr->first == "292074032993"){
                    filename = "2";
                }
                else if(itr->first == "292074032992"){
                    filename = "3";
                }
                
                else if(itr->first == "292074032989"){
                    filename = "4";
                }
                
                else if(itr->first == "342074067873"){
                    filename = "5";
                }
                
                else if(itr->first == "292074036327"){
                    filename = "6";
                }
                
                else if(itr->first == "342074067877"){
                    filename = "7";
                }
                
                else if(itr->first == "292074032991"){
                    filename = "8";
                }
                
                else if(itr->first == "322074063646"){
                    filename = "9";
                }
                
                else if(itr->first == "322074067491"){
                    filename = "10";
                }
                
                else if(itr->first == "322074062352"){
                    filename = "11";
                }
                
                else if(itr->first == "322074067417"){
                    filename = "12";
                }
                
                ofBufferToFile(dir+"/"+filename+".png", itr->second, true);
                ofImage foo;
                foo.loadImage(itr->second);
                captures.push_back(foo);
            }
        }else{
            mNewPhoto = false;
        }
        if(captures.size() > mNumCameras){
            captures.pop_front();
        }
        if(captures.size() > 0 && ofGetFrameNum()%16==0){
            mCurrentIndex++;
            if(mCurrentIndex>=mNumCameras){
                mCurrentIndex = 0;
            }
        }
    }
}
Ejemplo n.º 17
0
//--------------------------------------------------------------
void testApp::draw(){
    
    ofBackgroundGradient(ofColor(40,40,40), ofColor(20,20,20), OF_GRADIENT_CIRCULAR);

    if(stage != 1){
        gui->toggleVisible();
        gui2->toggleVisible();
    }
    
    if (stage == 0) {
        ofSetColor(255);
        helveticafont30.drawString("DO YOU HAVE SOMETHING TO HIDE?", ofGetWindowWidth()/2-340 , ofGetWindowHeight()/2);
        helveticafont30.drawString("LET THE NSA KNOW WHERE YOU ARE!", ofGetWindowWidth()/2-345 , ofGetWindowHeight()/2 + 45);
        
    } else if (stage == 1) {
        ofSetColor(255);
        helveticafont30.drawString("IS IN NEW YORK", ofGetWindowWidth()/2 - 142 , ofGetWindowHeight()/2);
        helfont15.drawString("Latitude: 40.704196  | Longitude: -74.042358", ofGetWindowWidth()/2 - 132, ofGetWindowHeight()/2 + 25);
        
    } else if (stage == 2) {
        helveticafont30.drawString("THANK YOU FOR YOUR COOPERATION.", ofGetWindowWidth()/2 - 310 , ofGetWindowHeight()/2);
        if(counter >= 140) stage = 0;
    }
    
    if(tracker.getFound()) {
        bFirst = false;
        
        if(counter >= 100 && stage == 0) {
            stage = 1;
        }
        
        if (bSnapshot == true){
            
            unsigned char *camPixels = cam.getPixels();
            img.setFromPixels(camPixels, cam.width, cam.height, OF_IMAGE_COLOR);
            img.crop(tracker.getPosition().x-150, tracker.getPosition().y-150, 300,300);
            string fileName;
//            string dir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/PhotoFace/bin/data/img/";
//            string dir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/faces/";
            
            string dir = "/Users/gusfaria11/Documents/ofx_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/faces/";
            
//            if(typeStr == ""){
//                fileName = "snapshot_"+ofToString(10000+snapCounter)+".png";
//            } else {
                fileName = typeStr+".png";
//            }

            img.saveImage(dir+fileName);
            sprintf(snapString, "saved %s", fileName.c_str());
            
            //send text to another file.
//            string mydir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/train2.txt";
            string mydir = "/Users/gusfaria11/Documents/ofx_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/train2.txt";
//            myfile.open(mydir);
//            string str = "HELLO its me again!\n";
//            cout << str.length() << endl;
//            buffer.allocate(fileName.length());
//            buffer.append(fileName+"\n");
//            myfile.writeFromBuffer(buffer);

//            bool fileWritten = ofBufferToFile(mydir, buffer);
//            buffer.append(fileName+"\n");
//            myfile.close();
            

            
            snapCounter++;
            
            bSnapshot = false;
            bClick = false;
            bFirst = true;

            cam.draw(ofGetWindowWidth(),0);
            buffer = ofBufferFromFile(mydir);
            buffer.append(fileName+"\n");
            ofBufferToFile(mydir, buffer);
            typeStr.clear();
            
            stage = 2;
        }
    }

    if(bDebug){
//DEBUGGING
    ofDrawBitmapStringHighlight("stage: " + ofToString(stage), ofPoint(10,40));
    ofDrawBitmapString(ofToString(counter), ofPoint(10,ofGetWindowHeight()-70));
    ofDrawBitmapString(typeStr, ofPoint(10,ofGetWindowHeight()-50));
    ofPushMatrix();
    ofScale(0.25, 0.25);
    cam.draw(0,0);
    tracker.draw();
    ofPopMatrix();
    }

}
Ejemplo n.º 18
0
//--------------------------------------------------------------//
void ofApp::keyPressed(int key){
  //-----------------------First Menu---------------------------//
  //------------------------------------------------------------//
    /*---employ a big switch case statement here-----*/

    switch(unit){
    case 0:

    if ( key == OF_KEY_DOWN && game_search.size() > 0)
    {
      currentFile++;
      currentFile %= game_search.size();
    }
    else if( key == OF_KEY_UP && game_search.size() > 0)
    {
      currentFile--;
      currentFile %= game_search.size();
    }
    else if(key == OF_KEY_RETURN && game_search.size() > 0)
    {
      //Takes current file and searches for suffix and passes it to .info update
      string g = game_search.getName(currentFile);
      int lastIndex = g.find_last_of(".");
      string name = g.substr(lastIndex + 1);
      ofLogVerbose(g.substr(lastIndex + 1));
      
      //Holds results from suffix parse on .info directory
      vector<string> inf_res = patternUpdate(name);
      
      //Holds results of .info and emulator name parse which is path to emulator
      emu_res = emuUpdate(inf_res);
      

      //reads string path to selected file to in games search to a .txt file
      //--->will need to setup bash script to copy
      //------------------------------------------------------
      game_selection = '"' + game_search.getName(currentFile) + '"';
      ofBuffer msg(game_selection.c_str(), game_selection.length());
      ofFile gameName(ofToDataPath("game_select.txt"), ofFile::WriteOnly);
      gameName.create();
      ofBufferToFile("game_select.txt", msg);
      msg.clear();
      gameName.close();
      ofLogVerbose("written out and closed first time");
      unit = 2;
    }
    break;
    case 2:
    //----------------------------Second Menu-------------------------------//
    //----------------------------------------------------------------------//
    if(key == OF_KEY_DOWN && emu_res.size() > 0)
    {
      currentFile1++;
      currentFile1 %= emu_res.size();
    }
    else if(key == OF_KEY_UP && emu_res.size() > 0){
      currentFile1--;
      currentFile1 %= emu_res.size();
    }
    else if(key == OF_KEY_RETURN && emu_res.size() > 0){
       emu_selection.push_back(emu_res[currentFile1]);
       
       ofFile emuName(ofToDataPath("emu_select.txt"), ofFile::WriteOnly);
       emuName.create();
       ofLogVerbose("file opened");

       ofBuffer msg(emu_res[currentFile1]);
       ofBufferToFile("emu_select.txt", msg);
       msg.clear();
       emuName.close();
       ofLogVerbose("Written to out and closed ,second Tiem!");
       unit = 3;
       /* Work on opening file here and putting emu_selection into it */
    }
    break;
    case 3:

    if(key == OF_KEY_RETURN && emu_res.size() > 0)
    {
      openChildApp();
    }
  }//end of switch 
}
Ejemplo n.º 19
0
	void Camera::savePhoto(string filename) {
		ofBufferToFile(filename, photoBuffer, true);
	}
Ejemplo n.º 20
0
void ofxTurboJpeg::save(string path, const ofPixels& pix, int jpegQuality)
{
	ofBuffer buf;
	save(buf, pix, jpegQuality);
	ofBufferToFile(path, buf, true);
}
Ejemplo n.º 21
0
void Project::_saveAddons()
{
    ofBuffer buffer(ofJoinString(_addons, "\n"));
    ofBufferToFile(_path + "/addons.make", buffer);
}