a new Java test to imencode() with params
authorAndrey Pavlenko <andrey.pavlenko@itseez.com>
Thu, 27 Sep 2012 15:10:06 +0000 (19:10 +0400)
committerAndrey Pavlenko <andrey.pavlenko@itseez.com>
Thu, 27 Sep 2012 15:11:02 +0000 (19:11 +0400)
modules/java/android_test/src/org/opencv/test/highgui/HighguiTest.java

index d45272b..ba6e89c 100644 (file)
@@ -1,6 +1,7 @@
 package org.opencv.test.highgui;
 
 import org.opencv.core.MatOfByte;
+import org.opencv.core.MatOfInt;
 import org.opencv.highgui.Highgui;
 import org.opencv.test.OpenCVTestCase;
 import org.opencv.test.OpenCVTestRunner;
@@ -19,7 +20,20 @@ public class HighguiTest extends OpenCVTestCase {
     }
 
     public void testImencodeStringMatListOfByteListOfInteger() {
-        fail("Not yet implemented");
+        MatOfInt  params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40);
+        MatOfInt  params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90);
+       /* or
+        MatOfInt  params = new MatOfInt();
+       params.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(buff40.total() > 0);
+        assertTrue(buff40.total() < buff90.total());
     }
 
     public void testImreadString() {