Mods - please close this question. I found the mistake in the code. Unfortunately I can't delete this.
Is there any difference between the below two code snippets? Maybe with respect to padding? Because I am getting strange image with respect to the first ( statically allocated ). The second is ok.
Produces a distorted image ( missing blue I guess and the pixels are shifted )
function1(char *image) {
char image_data_[image_info_.imgSize];
memcpy(image_data_, image, image_info_.imgSize); // 144000 bytes
cv::Mat color_image_opencv(image_info_.height, image_info_.width, CV_8UC3, image_data_);
cv::imwrite("image.png", color_image_opencv);
}
AND ( this works )
function2(char *image) {
char *image_data_ = NULL;
image_data_ = reinterpret_cast<char*>(malloc(image_info_.imgSize));
memcpy(image_data_, image, image_info_.imgSize);
cv::Mat color_image_opencv(image_info_.height, image_info_.width, CV_8UC3, image_data_);
cv::imwrite("image.png", color_image_opencv);
}