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

pull/8437/head
Chaoshuai Lu 8 years ago
parent bcac7bd6d2
commit 874fb7ae78
  1. 4
      modules/imgcodecs/src/ios_conversions.mm

@ -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,

Loading…
Cancel
Save