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


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

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


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

示例1: save

void ofxTurboJpeg::save(ofBuffer &buf, const ofPixels& pix, int jpegQuality)
{
	int pitch = 0, flags = 0, jpegsubsamp = 0;
	unsigned long size = 0;
	
	
	if (pix.getImageType() == OF_IMAGE_COLOR)
	{
		int bpp = 3;
		vector<unsigned char> buffer;
		buffer.resize(pix.getWidth() * pix.getHeight() * bpp);
		
		unsigned char * output = &buffer[0];
		
		tjCompress(handleCompress, (unsigned char*)(pix.getData()), pix.getWidth(), pitch, pix.getHeight(), bpp, output, &size, jpegsubsamp, jpegQuality, flags);
		
		buf.set((const char*)output, size);
	}
	else if (pix.getImageType() == OF_IMAGE_COLOR_ALPHA)
	{
		ofPixels p;
		p.allocate(pix.getWidth(), pix.getHeight(), 3);
		
		const unsigned char *src = pix.getData();
		unsigned char *dst = p.getData();
		
		int num = pix.getWidth() * pix.getHeight();
		for (int i = 0; i < num; i++)
		{
			dst[0] = src[0];
			dst[1] = src[1];
			dst[2] = src[2];
			src += 4;
			dst += 3;
		}
		
		save(buf, p, jpegQuality);
	}
	else if (pix.getImageType() == OF_IMAGE_GRAYSCALE)
	{
		ofPixels p;
		p.allocate(pix.getWidth(), pix.getHeight(), 3);
		
		const unsigned char *src = pix.getData();
		unsigned char *dst = p.getData();
		
		int num = pix.getWidth() * pix.getHeight();
		for (int i = 0; i < num; i++)
		{
			dst[0] = src[0];
			dst[1] = src[0];
			dst[2] = src[0];
			src += 1;
			dst += 3;
		}
		
		save(buf, p, jpegQuality);
	} 
}
开发者ID:fishkingsin,项目名称:ofxTurboJpeg,代码行数:59,代码来源:ofxTurboJpeg.cpp

示例2: changeTypeOfPixels

//----------------------------------------------------
void ofImage::changeTypeOfPixels(ofPixels &pix, ofImageType newType){

	
		
	if (pix.getImageType() == newType) return;

	FIBITMAP * bmp					= getBmpFromPixels(pix);
	FIBITMAP * convertedBmp			= NULL;

	// check if we need to reallocate the texture.
	bool bNeedNewTexture = false;
	int oldType = pix.getImageType();
	if (newType > oldType){ 
		bNeedNewTexture = true;
	}
	
	// new type !
	switch (newType){
			
		//------------------------------------
		case OF_IMAGE_GRAYSCALE:
			convertedBmp = FreeImage_ConvertToGreyscale(bmp);
			break;
			
		//------------------------------------
		case OF_IMAGE_COLOR:
			convertedBmp = FreeImage_ConvertTo24Bits(bmp);
			if (bNeedNewTexture){
				tex.clear();
				tex.allocate(pixels.getWidth(), pixels.getHeight(), GL_RGB);
			}
			break;
		
		//------------------------------------
		case OF_IMAGE_COLOR_ALPHA:
			convertedBmp = FreeImage_ConvertTo32Bits(bmp);
			if (bNeedNewTexture){
				tex.clear();
				tex.allocate(pixels.getWidth(), pixels.getHeight(), GL_RGBA);
			}
			break;
		default:
			ofLog(OF_LOG_ERROR,"ofImage: format not supported");
	}

	putBmpIntoPixels(convertedBmp, pix, false);

	if (bmp != NULL)				FreeImage_Unload(bmp);
	if (convertedBmp != NULL)		FreeImage_Unload(convertedBmp);

}
开发者ID:alfredoBorboa,项目名称:openFrameworks,代码行数:52,代码来源:ofImage.cpp

示例3: addImage

void ofxSlitScan::addImage(ofPixels& image){
	if(image.getImageType() != type){
		ofLog(OF_LOG_ERROR, "ofxSlitScan -- adding image of the wrong type");
		return;
	}
	addImage( image.getPixels() );
}
开发者ID:robotconscience,项目名称:ofxSlitScan,代码行数:7,代码来源:ofxSlitScan.cpp

示例4: setDelayMap

void ofxSlitScan::setDelayMap(ofPixels& map){
	if(map.getWidth() != width || map.getHeight() != height){
		ofLog(OF_LOG_ERROR,"ofxSlitScan Error -- Map dimensions do not match image dimensions. given %fx%f, need %dx%d\n", map.getWidth(), map.getHeight(), width, height);
		return;
	}
	setDelayMap(map.getPixels(), map.getImageType());
}
开发者ID:robotconscience,项目名称:ofxSlitScan,代码行数:7,代码来源:ofxSlitScan.cpp

示例5:

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

示例6: findHaarObjects

int ofxCvHaarFinder::findHaarObjects(ofPixels& input, int minWidth, int minHeight){
	ofxCvGrayscaleImage gray;
	gray.allocate(input.getWidth(), input.getHeight());

	if( input.getImageType() == OF_IMAGE_COLOR ){
		ofxCvColorImage color;
		color.allocate(input.getWidth(), input.getHeight());
		color.setFromPixels(input);
		gray = color;
	}else if( input.getImageType() == OF_IMAGE_GRAYSCALE ){
		gray.setFromPixels(input);
	}else{
		ofLog(OF_LOG_ERROR, "ofxCvHaarFinder::findHaarObjects doesn't support OF_IMAGE_RGBA ofImage");
		return 0;
	}

	return findHaarObjects(gray, minWidth, minHeight);
}
开发者ID:echa,项目名称:libopenframeworks,代码行数:18,代码来源:ofxCvHaarFinder.cpp

示例7: newFrame

void Detector::newFrame(ofPixels & pixels){
	Poco::ScopedLock<ofMutex> lock(setupMutex);
	if(state!=Running || !pixels.getPixels()) return;
	if(pixels.getImageType()==OF_IMAGE_COLOR){
		if ( overrideWidth > 0 )
		{
			ofPixels tmpPixels = pixels;
			tmpPixels.resize( overrideWidth, overrideHeight );
			colorImg = tmpPixels.getPixels();
		}
		else
		{
			colorImg = pixels.getPixels();
		}
		img = colorImg;
		fern.update(img);
		//img640.scaleIntoMe(img);
	}else{
		if ( overrideWidth > 0 )
		{
			ofPixels tmpPixels = pixels;
			tmpPixels.resize( overrideWidth, overrideHeight );
			fern.update(tmpPixels);
		}
		else
		{
			fern.update( pixels );
		}
		//img640.scaleIntoMe(img,CV_INTER_LINEAR);
	}
	isNewFrame = true;

	mutex.lock();
	findOpenCvHomography(&srcQuad[0],&fern.getLastQuad()[0],homography.getPtr());
	mutex.unlock();

	int curr_time = ofGetElapsedTimeMillis();
	frames++;
	if(curr_time - fps_time >=1000){
		fps=float(frames*1000)/(curr_time - fps_time);
		fps_time=curr_time;
		frames=0;
	}
}
开发者ID:TheArtvertiser,项目名称:TheArtvertiserCombined,代码行数:44,代码来源:Detector.cpp


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