本文整理汇总了C++中ofPixels::getBytesPerPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPixels::getBytesPerPixel方法的具体用法?C++ ofPixels::getBytesPerPixel怎么用?C++ ofPixels::getBytesPerPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofPixels
的用法示例。
在下文中一共展示了ofPixels::getBytesPerPixel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scanSlice
//--------------------------------------------------------------
void ofApp::scanSlice(ofPixels_<float>& src, ofPixels& dst, int _offset) {
size_t bytesPerLine = (dst.getWidth() * dst.getBytesPerPixel());
size_t offset = bytesPerLine * _offset;
for (size_t i = 0; i < (dst.getWidth()-1)*dst.getBytesPerPixel(); i+=dst.getBytesPerPixel()) {
dst[i + 0] = ofClamp(255*src[offset + i + 0], 0, 255);
dst[i + 1] = ofClamp(255*src[offset + i + 1], 0, 255);
dst[i + 2] = ofClamp(255*src[offset + i + 2], 0, 255);
}
for(int l = dst.getHeight()-1; l >= 1; l--) {
memcpy(&dst[l*bytesPerLine], &dst[(l-1)*bytesPerLine], bytesPerLine);
}
}
示例2: draw
//--------------------------------------------------------------
void testApp::draw(){
ofSetHexColor(0xFFFFFF);
ofBackground(0);
if(bShowInput) grayImage.drawROI(roi.x, roi.y);
if(bShowOutput) fbo.draw(0, 0);
L.draw(pix);
if(bInfo){
ofSetHexColor(0xFF0000);
char reportStr[1024];
sprintf(reportStr, "[P] process on/off [F] snapshot [7 8 9 0] roi mask");
ofDrawBitmapString(reportStr, 20, 10);
sprintf(reportStr, "fps:%3.0f opencv:%3.2f madMapper:%3.2f", ofGetFrameRate(), t1, t2);
ofDrawBitmapString(reportStr, 20, 25);
sprintf(reportStr, "[1] show input [2] show output [i] info ");
ofDrawBitmapString(reportStr, 20, 40);
sprintf(reportStr, "[c] Contrast %.2f [b] Brightness %.2f ", contrast, brightness);
ofDrawBitmapString(reportStr, 20, 55);
sprintf(reportStr, "gray image [%4d, %4d] fbo [%4.f, %4.f] ",
roiW, roiH, fbo.getWidth(), fbo.getHeight());
int idx = (mouseY * pix.getWidth()+ mouseX) * pix.getBytesPerPixel();
sprintf(reportStr, "pixels %d", pix.getPixels()[idx]);
ofDrawBitmapString(reportStr, 20, 85);
}
}
示例3:
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());
}
}