Ask Your Question

Revision history [back]

Please add a test program : everybody will be able to check if problem exist

Now in C++ no problem :

    Mat w(3, 3, CV_8UC4, Scalar(1, 2, 3, 0));
    w.at<Vec4b>(0, 0) = Scalar(0, 0, 0, 255);
    w.at<Vec4b>(1, 0) = Scalar(0, 0, 0, 128);
    w.at<Vec4b>(2, 0) = Scalar(0, 0, 0, 1);
    cout << w << endl;
    imwrite("w.png", w);
    cout << "After imwrite and imread\n";
    Mat x = imread("w.png", IMREAD_UNCHANGED);
    cout << x;

results :

[  0,   0,   0, 255,   1,   2,   3,   0,   1,   2,   3,   0;
   0,   0,   0, 128,   1,   2,   3,   0,   1,   2,   3,   0;
   0,   0,   0,   1,   1,   2,   3,   0,   1,   2,   3,   0]
After imwrite and imread
[  0,   0,   0, 255,   1,   2,   3,   0,   1,   2,   3,   0;
   0,   0,   0, 128,   1,   2,   3,   0,   1,   2,   3,   0;
   0,   0,   0,   1,   1,   2,   3,   0,   1,   2,   3,   0]

Please add a test program : everybody will be able to check if problem existexist. Give opencv version and platform too

Now in C++ no problem :

    Mat w(3, 3, CV_8UC4, Scalar(1, 2, 3, 0));
    w.at<Vec4b>(0, 0) = Scalar(0, 0, 0, 255);
    w.at<Vec4b>(1, 0) = Scalar(0, 0, 0, 128);
    w.at<Vec4b>(2, 0) = Scalar(0, 0, 0, 1);
    cout << w << endl;
    imwrite("w.png", w);
    cout << "After imwrite and imread\n";
    Mat x = imread("w.png", IMREAD_UNCHANGED);
    cout << x;

results :

[  0,   0,   0, 255,   1,   2,   3,   0,   1,   2,   3,   0;
   0,   0,   0, 128,   1,   2,   3,   0,   1,   2,   3,   0;
   0,   0,   0,   1,   1,   2,   3,   0,   1,   2,   3,   0]
After imwrite and imread
[  0,   0,   0, 255,   1,   2,   3,   0,   1,   2,   3,   0;
   0,   0,   0, 128,   1,   2,   3,   0,   1,   2,   3,   0;
   0,   0,   0,   1,   1,   2,   3,   0,   1,   2,   3,   0]