Home | History | Annotate | Download | only in cameraanalyzer
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 #define LOG_NDEBUG 0
     17 
     18 #define LOG_TAG "ExposureCompensationJNI"
     19 #include <utils/Log.h>
     20 #include <vector>
     21 #include <string.h>
     22 
     23 #include "android/bitmap.h"
     24 #include "testingimage.h"
     25 #include "exposurecompensationtest.h"
     26 #include "vec2.h"
     27 
     28 #include "com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.h"
     29 
     30 jlong Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_createExposureCompensationTest(
     31       JNIEnv*      env,
     32       jobject      thiz,
     33       jint         debugHeight,
     34       jint         debugWidth) {
     35 
     36     ExposureCompensationTest* testHandler =
     37             new ExposureCompensationTest(debugHeight, debugWidth);
     38     long handlerAddress = (long)testHandler;
     39 
     40     return handlerAddress;
     41 }
     42 
     43 void Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_createExposureCompensationClass(
     44         JNIEnv*      env,
     45         jobject      thiz,
     46         jlong        inputImageAddress,
     47         jlong        inputHandlerAddress,
     48         jlong        checkerCenterAddress,
     49         jlong        checkerRadiusAddress,
     50         jfloat       exposureValue) {
     51 
     52     ALOGV("JNI createExposureCompensationClass starts!");
     53 
     54     long imageAddress = (long)inputImageAddress;
     55     long handlerAddress = (long)inputHandlerAddress;
     56 
     57     TestingImage *inputImage = (TestingImage*) imageAddress;
     58     ExposureCompensationTest *testHandler =
     59             (ExposureCompensationTest*) handlerAddress;
     60 
     61     std::vector<std::vector< Vec2f > >* checkerCenter =
     62             (std::vector<std::vector< Vec2f > >*) (long) checkerCenterAddress;
     63     std::vector<std::vector< float > >* checkerRadius =
     64             (std::vector<std::vector< float > >*) (long) checkerRadiusAddress;
     65 
     66     const std::vector<Vec3f>* checkerValue =
     67             inputImage->getColorChecker(3, 4, 0, 6,
     68                                         checkerCenter, checkerRadius);
     69     testHandler->addDataToList((float) exposureValue, checkerValue);
     70     delete inputImage;
     71     delete checkerValue;
     72 }
     73 
     74 jstring Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_processExposureCompensationTest(
     75         JNIEnv*      env,
     76         jobject      thiz,
     77         jlong        inputHandlerAddress) {
     78 
     79     long handlerAddress = (long) inputHandlerAddress;
     80     ExposureCompensationTest *testHandler =
     81             (ExposureCompensationTest*) handlerAddress;
     82 
     83     testHandler->processData();
     84 
     85     const char* nativeDebugText = testHandler->getDebugText();
     86     ALOGV("%s", nativeDebugText);
     87     return env->NewStringUTF(nativeDebugText);
     88 }
     89