Skip to content

Commit

Permalink
Fix UIImageToMat method by taking image scale information into account
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaoshuai Lu authored and Chaoshuai Lu committed Mar 23, 2017
1 parent 874fb7a commit d8a7b3e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/imgcodecs/src/ios_conversions.mm
Expand Up @@ -97,11 +97,10 @@
void UIImageToMat(const UIImage* image,
cv::Mat& m, bool alphaExist) {
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage);
CGFloat cols = image.size.width, rows = image.size.height;
CGFloat cols = CGImageGetWidth(image.CGImage), rows = CGImageGetHeight(image.CGImage);
CGContextRef contextRef;
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast;
if (CGColorSpaceGetModel(colorSpace) == kCGColorSpaceModelMonochrome)
{
if (CGColorSpaceGetModel(colorSpace) == kCGColorSpaceModelMonochrome) {
m.create(rows, cols, CV_8UC1); // 8 bits per component, 1 channel
bitmapInfo = kCGImageAlphaNone;
if (!alphaExist)
Expand Down

0 comments on commit d8a7b3e

Please sign in to comment.