提交 ca318e70 编写于 作者: M Morrison

handle images with alpha better

UIImages with alpha were ending up with garbage pixels in background (random memory values).  Need to initialize matrix pixels before drawing UIImage with alpha on it.

Note: didn’t fix Grayscale image with alpha stripping alpha in UIImage -> Mat conversion.
上级 45a21555
......@@ -106,6 +106,8 @@ void UIImageToMat(const UIImage* image,
bitmapInfo = kCGImageAlphaNone;
if (!alphaExist)
bitmapInfo = kCGImageAlphaNone;
else
m = cv::Scalar(0);
contextRef = CGBitmapContextCreate(m.data, m.cols, m.rows, 8,
m.step[0], colorSpace,
bitmapInfo);
......@@ -116,6 +118,8 @@ void UIImageToMat(const UIImage* image,
if (!alphaExist)
bitmapInfo = kCGImageAlphaNoneSkipLast |
kCGBitmapByteOrderDefault;
else
m = cv::Scalar(0);
contextRef = CGBitmapContextCreate(m.data, m.cols, m.rows, 8,
m.step[0], colorSpace,
bitmapInfo);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册