是否有最快的方法将IplImage类型从OpenCV转换为Allegro 5.0.x的ALLEGRO_BITMAP类型,而不是将每个像素从一个转换为另一个?
像这样的2个循环:
void iplImageToBitmap(IplImage *source, ALLEGRO_BITMAP* dest) {
if(source!= NULL && dest!= NULL) {
al_set_target_bitmap(dest);
int height = source->height;
int width = source->width;
int x,y;
for( y=0; y < height ; y++ ) {
uchar* ptr = (uchar*) (
source->imageData + y * source->widthStep
);
for( x=0; x < width; x++ ) {
al_put_pixel(x,y,al_map_rgb(ptr[3*x+2],ptr[3*x+1],ptr[3*x]));
}
}
}
}