代码片段~
unsigned int* abMatBGR2ARGB(Mat imag)
{
int nCols;
int nRows;
unsigned int *pbuff = NULL;
if(imag.empty())
{
cerr << "Failed read the image data." << endl;
return NULL;
}
if (imag.dims != 2)
{
cerr << "not a image data" << endl;
return NULL;
}
nCols = imag.cols;
nRows = imag.rows;
pbuff = new unsigned int[nCols*nRows];
if (!pbuff)
{
cerr << "failed to allocate memory for the input image." << endl;
return NULL;
}
if (imag.depth()!=CV_8U || imag.channels() != 3)
{
cerr << "error type of image channels and depth." << endl;
return NULL;
}
Vec3b pix;
uchar *tp=NULL;
for (int row = 0; row < nRows; row++)
{
for (int col = 0; col < nCols; col++)
{
pix = imag.at<Vec3b>(row, col);
tp = (uchar*