提交 874fb7ae 编写于 作者: C Chaoshuai Lu

Fix MatToUIImage method crash when the step is not equal to cols * elemSize()

上级 bcac7bd6
......@@ -53,7 +53,7 @@ void UIImageToMat(const UIImage* image, cv::Mat& m, bool alphaExist);
UIImage* MatToUIImage(const cv::Mat& image) {
NSData *data = [NSData dataWithBytes:image.data
length:image.elemSize()*image.total()];
length:image.step.p[0] * image.rows];
CGColorSpaceRef colorSpace;
......@@ -73,7 +73,7 @@ UIImage* MatToUIImage(const cv::Mat& image) {
// Creating CGImage from cv::Mat
CGImageRef imageRef = CGImageCreate(image.cols,
image.rows,
8,
8 * image.elemSize1(),
8 * image.elemSize(),
image.step.p[0],
colorSpace,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册