Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Look at the following test:

public void testImencodeStringMatListOfByteListOfInteger() {
    MatOfInt  params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40);
    MatOfInt  params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90);
    /* or
    MatOfInt  params40 = new MatOfInt();
    params40.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40);
    MatOfByte buff40 = new MatOfByte();
    MatOfByte buff90 = new MatOfByte();

    assertTrue( Highgui.imencode(".jpg", rgbLena, buff40, params40) );
    assertTrue( Highgui.imencode(".jpg", rgbLena, buff90, params90) );

    assertTrue( > 0);
    assertTrue( <;

As for the question: "And also, because imencode returns buf as a MatOfByte with a single row, how do I convert it so it has the same dimensions of input image?" - the imencode() function returns an JPEG-encoded stream; do you expect it to be the same size at the original image?