unsigned char* read_bmp_image(std::string filename)
{
bitmap_image image(filename);
unsigned int bytes_per_pixel = image.bytes_per_pixel();
unsigned int width = image.width();
unsigned int height = image.height();
unsigned int size = width*height*bytes_per_pixel;
unsigned char* rgb_buffer = new unsigned char[size];
image.bgr_to_rgb();
memcpy(rgb_buffer,image.data(),size);
return rgb_buffer;
}
以上是定义 ,下面这样使用这个函数可以吗?
char filePath[100];
sprintf(filePath,"C:\Users\Administrator\Desktop\预处理\temp\%d.bmp",a);
unsigned char* testinput1 = read_bmp_image(filePath);