I have this code, but it doesn't work: (it create an image which is all black)
eqr.create(size,CV_8UC4);
eqr.setTo( cv::Scalar(255,255,255,0)) ;
cv::imwrite("test.png", eqr);
this is also did not work: it creates an image which is all white.
eqr.create(size,CV_8UC4);
eqr.setTo( cv::Scalar(255,255,255,255)) ;
cv::imwrite("test.png", eqr);
What is the correct way to create an image with alpha channel and set all of its pixels to transparent?
You can find similar kind of example here
And if you need load transparent image(with alpha) use
imread("map.jpg",-1)
instead of
imread("map.jpg", CV_LOAD_IMAGE_COLOR)
which will load alpha, See OpenCV Doc for more info.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.