Quantcast
Viewing all articles
Browse latest Browse all 41027

How to obtain Alpha from cv::mat (For wxWidgets::wxImage)

The following code is not the entire block of code , instead it is the important pieces needed to get my question across. In short: I am asking how to receive the Alpha data from CV::Mat so that I may pass it into a parameter requesting an unsigned char* as Alpha. in a scaling function, I have a cv::mat(Destination) that is built as so: cvImage = convertWxToMatWithAlpha(image); //(cvImage is a CV::Mat) wxData = (byte*) malloc(width * height * 4); dst = cv::Mat(height, width, CV_8UC4, wxData); I then re-size the image and save the results in dst which is a CV::Mat cv::resize(cvImage,dst, cv::Size(width,height), 0, 0, CV_INTER_LINEAR); I now need to create a wxImage with alpha using the dst mat. if(dst.channels() == 4) { std::vector matrixChannels; cv::split(dst,matrixChannels); image->Create(dst.cols,dst.rows,dst.data,matrixChannels[3].data,false); return true; } The constructor for wxImage I am using is specified as: wxImage(int width, int height, unsigned char *data, unsigned char *alpha, bool static_data=false) I can't for the life of me achieve the correct data for the unsigned char *alpha parameter. I know for a fact CV::Mat dst has Alpha data, but I don't know how to get to it and use it where I want to use it.. Any ideas? I'm pulling my hair out here! :(

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>