mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 11:40:44 +08:00
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.
This commit is contained in:
parent
45a21555c7
commit
ca318e7099
@ -106,6 +106,8 @@ void UIImageToMat(const UIImage* image,
|
|||||||
bitmapInfo = kCGImageAlphaNone;
|
bitmapInfo = kCGImageAlphaNone;
|
||||||
if (!alphaExist)
|
if (!alphaExist)
|
||||||
bitmapInfo = kCGImageAlphaNone;
|
bitmapInfo = kCGImageAlphaNone;
|
||||||
|
else
|
||||||
|
m = cv::Scalar(0);
|
||||||
contextRef = CGBitmapContextCreate(m.data, m.cols, m.rows, 8,
|
contextRef = CGBitmapContextCreate(m.data, m.cols, m.rows, 8,
|
||||||
m.step[0], colorSpace,
|
m.step[0], colorSpace,
|
||||||
bitmapInfo);
|
bitmapInfo);
|
||||||
@ -116,6 +118,8 @@ void UIImageToMat(const UIImage* image,
|
|||||||
if (!alphaExist)
|
if (!alphaExist)
|
||||||
bitmapInfo = kCGImageAlphaNoneSkipLast |
|
bitmapInfo = kCGImageAlphaNoneSkipLast |
|
||||||
kCGBitmapByteOrderDefault;
|
kCGBitmapByteOrderDefault;
|
||||||
|
else
|
||||||
|
m = cv::Scalar(0);
|
||||||
contextRef = CGBitmapContextCreate(m.data, m.cols, m.rows, 8,
|
contextRef = CGBitmapContextCreate(m.data, m.cols, m.rows, 8,
|
||||||
m.step[0], colorSpace,
|
m.step[0], colorSpace,
|
||||||
bitmapInfo);
|
bitmapInfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user