Ask Your Question

Revision history [back]

You could create you image in RGBA8888 with the accessors of a matrix:

Mat mat = imread("myimage.png");
for( int r = 0 ; r < mat.rows ; ++r )
{
    for( int c = 0 ; c < mat.cols ; ++c )
    {
        cv::Vec4b val = mat.at<cv::Vec4b>(r,c);
        char blue = val[0];
        char green = val[1];
        char red = val[2];
        char alpha = val[3];
       //do anything you want here...
    }
}

Image in OpenCV are in BGRA, not in RGBA! Maybe you could directly used the data pointer of cv::Mat to create your image, but I probably depend on the internal organization of RGBA8888 image you want to use.