# Revision history [back]

My comment to berak is badly formatted, so I post it here again:

Mat image8, image16;
image8.convertTo(image16, CV_16UC1, 255);

bool result = imwrite("c:\tmp\test.jp2", image16);

Mat imageNew8, newImage16;
newImage16.convertTo(imageNew8, CV_8UC1, 1.0/255);


results in a totally distorted image (both newImage16 and newImage8, the result variable indicates that the write went well).

The "c:\tmp\test.jp2" shown in IrfanView as just a black image (can not see the pixel values, but they are checked in the code via newImage16 to be totally wrong in something like half of the picture). That IrfanView can not display the image properly is not a problem for me, I am not the the decoder here is 100% compatible with libjasper.

My comment to berak is badly formatted, so I post it here again:

Mat image8, image16;