Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

convert png transparent pixels to white

I have a png as a base64 that contains some transparent pixels. I read the image through:

    vector<uchar> vectordata(string.begin(), strong.end());
    mat = imdecode(vectordata, IMREAD_UNCHANGED);

Then I change the pixels, by going one by one in the mat array and converting rgb values of the transparent pixels and fixing their transparency back to 255. Is there a faster way to do that? Like composting with a white image ?

convert png transparent pixels to white

I have a png as a base64 that contains some transparent pixels. pixels whose rgb is (0,0,0). I want to convert the rgb of these pixels to white and set the alpha to 255. I read the image through:

    vector<uchar> vectordata(string.begin(), strong.end());
    mat = imdecode(vectordata, IMREAD_UNCHANGED);

Then I change the pixels, by going one by one in the mat array and converting rgb values of the transparent pixels and fixing their transparency back to 255. Is there a faster way to do that? Like composting with a white image ?