我在快速访问无符号字符数组时遇到了一些麻烦。
我想实际将 BGRABGRA....BGRABGRA.... 逐行编码图像数组复制到使用三层的 OpenCV 版本。下面的代码运行良好,但速度很慢(640*480 图像大约需要 0.5 秒)。我指出取消引用运算符 * 使它变慢。你有任何计划如何解决这个问题吗?(提示:BYTE 是无符号字符)
// run thorugh all pixels and copy image data
for (int y = 0; y<imHeight; y++){
BYTE* pLine= vrIm->mp_buffer + y * vrIm->m_pitch;
for (int x = 0; x<imWidth; x++){
BYTE* b= pLine++; // fast pointer operation
BYTE* g= pLine++;
BYTE* r= pLine++;
BYTE* a= pLine++; // (alpha)
BYTE bc = *b; // this is really slow!
BYTE gc = *g; // this is really slow!
BYTE rc = *r; // this is really slow!
}
}
谢谢!