Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Try it like this.

        MatOfByte matOfByte = new MatOfByte();

        Highgui.imencode(".png", mGray, matOfByte);

        byte[] byteArray = matOfByte.toArray();

Try it like this.

        MatOfByte matOfByte = new MatOfByte();

        // encoding to png, so that your image does not lose information like with jpeg.
        Highgui.imencode(".png", mGray, matOfByte);
matOfByte); 

        byte[] byteArray = matOfByte.toArray();