当前位置: 首页>>代码示例>>C++>>正文


C++ ofPixels::isAllocated方法代码示例

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


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

示例1:

ofPixels::ofPixels(const ofPixels & mom){
	bAllocated = false;
	pixels = NULL;
	if(mom.isAllocated()){
		allocate(mom.getWidth(),mom.getHeight(),mom.getImageType());
		memcpy(pixels,mom.getPixels(),mom.getWidth()*mom.getHeight()*mom.getBytesPerPixel());
	}
}
开发者ID:frogger,项目名称:openFrameworks,代码行数:8,代码来源:ofPixels.cpp

示例2: saveImageFromPixels

//----------------------------------------------------------------
void  ofImage::saveImageFromPixels(string fileName, ofPixels &pix){

	if (pix.isAllocated() == false){
		ofLog(OF_LOG_ERROR,"error saving image - pixels aren't allocated");
		return;
	}

	#ifdef TARGET_LITTLE_ENDIAN
		pix.swapRgb();
	#endif

	FIBITMAP * bmp	= getBmpFromPixels(pix);

	#ifdef TARGET_LITTLE_ENDIAN
		pix.swapRgb();
	#endif

	fileName = ofToDataPath(fileName);
	if (pix.isAllocated()){
		FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
		fif = FreeImage_GetFileType(fileName.c_str(), 0);
		if(fif == FIF_UNKNOWN) {
			// or guess via filename
			fif = FreeImage_GetFIFFromFilename(fileName.c_str());
		}
		if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
			if((FREE_IMAGE_FORMAT)fif != FIF_JPEG)
			   FreeImage_Save(fif, bmp, fileName.c_str());
			else
			   FreeImage_Save(fif, bmp, fileName.c_str(),JPEG_QUALITYSUPERB);
		}
	}

	if (bmp != NULL){
		FreeImage_Unload(bmp);
	}
}
开发者ID:emonty,项目名称:openFrameworks,代码行数:38,代码来源:ofImage.cpp

示例3: ofSaveImage

//----------------------------------------------------------------
void ofSaveImage(ofPixels & pix, string fileName, ofImageQualityType qualityLevel) {

	if (pix.isAllocated() == false){
		ofLog(OF_LOG_ERROR,"error saving image - pixels aren't allocated");
		return;
	}

	#ifdef TARGET_LITTLE_ENDIAN
		pix.swapRgb();
	#endif

	FIBITMAP * bmp	= getBmpFromPixels(pix);

	#ifdef TARGET_LITTLE_ENDIAN
		pix.swapRgb();
	#endif
	
	fileName = ofToDataPath(fileName);
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	fif = FreeImage_GetFileType(fileName.c_str(), 0);
	if(fif == FIF_UNKNOWN) {
		// or guess via filename
		fif = FreeImage_GetFIFFromFilename(fileName.c_str());
	}
	if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
		if(fif == FIF_JPEG) {
			int quality = JPEG_QUALITYSUPERB;
			switch(qualityLevel) {
				case OF_IMAGE_QUALITY_WORST: quality = JPEG_QUALITYBAD; break;
				case OF_IMAGE_QUALITY_LOW: quality = JPEG_QUALITYAVERAGE; break;
				case OF_IMAGE_QUALITY_MEDIUM: quality = JPEG_QUALITYNORMAL; break;
				case OF_IMAGE_QUALITY_HIGH: quality = JPEG_QUALITYGOOD; break;
				case OF_IMAGE_QUALITY_BEST: quality = JPEG_QUALITYSUPERB; break;
			}
			FreeImage_Save(fif, bmp, fileName.c_str(), quality);
		} else {
			if(qualityLevel != OF_IMAGE_QUALITY_BEST) {
				ofLog(OF_LOG_WARNING, "ofImageCompressionType only applies to JPEG images, ignoring value.");
			}
			FreeImage_Save(fif, bmp, fileName.c_str());
		}
	}

	if (bmp != NULL){
		FreeImage_Unload(bmp);
	}
}
开发者ID:alfredoBorboa,项目名称:openFrameworks,代码行数:48,代码来源:ofImage.cpp

示例4: critical

	//----------
	void Decoder::operator<<(const ofPixels& pixels) {
		if (frame == 0) {
			data.allocate(pixels.getWidth(), pixels.getHeight(), payload->getWidth(), payload->getHeight());
		}

		if (frame > payload->getFrameCount() - 1) {
#pragma omp critical(ofLog)
			ofLogWarning("ofxGraycode") << "Can't add more frames, we've already captured a full set. please clear()";
			return;
		}

		if (!pixels.isAllocated()) {
			ofLogError("ofxGraycode") << "Cannot add this capture as the pixels object is empty";
			return;
		}

		const ofPixels* greyPixels;
		if (pixels.getNumChannels() > 1) {
			ofPixels* downsample = new ofPixels();
			downsample->allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_MONO);
			downsample->set(0, 0);
			const uint8_t* in = pixels.getData();
			uint8_t* out = downsample->getData();
			for (int i = 0; i < pixels.size(); i++, out += (i % pixels.getNumChannels() == 0)) {
				*out += *in++ / pixels.getNumChannels();
			}
			greyPixels = downsample;
		}
		else
			greyPixels = &pixels;

		if (this->payload->isOffline())
			captures.push_back(*greyPixels);
		else
			payload->readPixels(frame, *greyPixels);

		frame++;

		if (frame >= payload->getFrameCount()) {
			calc();
			frame = payload->getFrameCount();
		}

		if (greyPixels != &pixels)
			delete greyPixels;
	}
开发者ID:elliotwoods,项目名称:ofxGraycode,代码行数:47,代码来源:Decoder.cpp

示例5: pushFrame

//------------------------------------------------------------------------------
void ofxIpVideoServerRoute::pushFrame(ofPixels& pix) {
    if(pix.isAllocated()) {
        unsigned long long timestamp = ofGetElapsedTimeMillis();
        ofPixels pixels(pix); // copy the pixels
        ofSaveImage(pixels, buffer, OF_IMAGE_FORMAT_JPEG, settings.quality);
        vector<ofxIpVideoServerFrameQueue*>::iterator iter = queues.begin();
        ofxIpVideoServerFrame::Settings settings;
        settings.quality = settings.quality;
        ofxIpVideoServerFramePtr frame = ofxIpVideoServerFramePtr(new ofxIpVideoServerFrame(buffer,
                                                                                            timestamp,
                                                                                            settings));

        while(iter != queues.end()) {
            if((*iter) != NULL && (*iter)->isActive()) {
                (*iter)->push(frame);
            }
            ++iter;
        }
            
    } else {
        ofLogError("ofxIpVideoServerRoute::pushFrame") << "Pushing unallocated pixels.";
    }
}
开发者ID:bakercp,项目名称:ofxIpVideoServer,代码行数:24,代码来源:ofxIpVideoServerRoute.cpp


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