本文整理汇总了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);
}
}
示例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);
}
示例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() );
}
示例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());
}
示例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());
}
}
示例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);
}
示例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;
}
}