コード例 #1
0
//--------------------------------------------------
string ofBuffer::getNextLine(){
	if(buffer.empty() || (int)(buffer.size() - 1) == nextLinePos){
		return "";
	}
	long currentLinePos = nextLinePos;
	bool lineEndWasCR = false;
	while(nextLinePos < (int)buffer.size() - 1 && buffer[nextLinePos] != '\n'){
		if(buffer[nextLinePos] != '\r'){
			nextLinePos++;
		}
		else{
			lineEndWasCR = true;
			break;
		}
	}
	string line(getBinaryBuffer() + currentLinePos, nextLinePos - currentLinePos);
	if(nextLinePos < (int)(buffer.size() - 1)){
		nextLinePos++;
	}
	// if lineEndWasCR check for CRLF
	if(lineEndWasCR && nextLinePos < (int)(buffer.size() - 1) && buffer[nextLinePos] == '\n'){
		nextLinePos++;
	}
	return line;
}
コード例 #2
0
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
	auto files = dragInfo.files;
	cout << "We need " << payload.getFrameCount() << " frames for a complete set." << endl;
	
	int width, height;
	
	for (auto filename : files) {
		ofFile file;
		file.open(filename, ofFile::ReadOnly, true);
		auto buffer = file.readToBuffer();
		
		width = 2048;
		height = buffer.size() / width;
		
		ofPixels pixels;
		pixels.allocate(width, height, 1);

		pixels.setFromExternalPixels((unsigned char * ) buffer.getBinaryBuffer(), width, height, 1);
		decoder << pixels;
		cout << "Added file " << filename << endl;
		//ofSaveImage(pixels, filename + ".png");
	}
	
	median.allocate(width, height, OF_IMAGE_GRAYSCALE);
	memcpy(median.getPixels(), decoder.getMedian().getPixels(), width * height);
	median.update();
}
コード例 #3
0
//--------------------------------------------------
string ofBuffer::getNextLine(){
	if( buffer.empty() || int(buffer.size()-1)==nextLinePos) return "";
	long currentLinePos = nextLinePos;
	while(nextLinePos<(int)buffer.size()-1 && buffer[nextLinePos]!='\n') nextLinePos++;
	string line(getBinaryBuffer() + currentLinePos,nextLinePos-currentLinePos);
	if(nextLinePos<(int)buffer.size()-1) nextLinePos++;
	return line;
}
コード例 #4
0
//----------
void ofxWatermark::init(string filename, string hash) {
	ofFile file(filename);
	auto buffer = file.readToBuffer();
	
	unsigned char fileHash[MD5_DIGEST_LENGTH];
	MD5((unsigned char *)buffer.getBinaryBuffer(), buffer.size(), fileHash);

	if (hashToString(fileHash) != hash) {
		ofSystemAlertDialog("The watermark hash does not match. Tamper alert! Quitting!");
		ofExit();
	}

	this->loadImage(buffer);
}
コード例 #5
0
//--------------------------------------------------
void ofBuffer::set(const char * _buffer, int _size){
	clear();
	buffer.resize(_size+1);
	memcpy(getBinaryBuffer(), _buffer, _size);
	buffer[_size]=0;
}