package Test;

import Yoseen.*;

/**********************************************************************************************
 *
 * TestYoseenFile
 *
 *
 **********************************************************************************************/
public class TestYoseenFile {
    public static void main(String[] args) {
        String dddDebug = YoseenSDK.getDebugDir();

        //
        int ret;
        ret = YoseenSDK.YoseenDevice.initSDK();
        YoseenSDK.YoseenFile file = new YoseenSDK.YoseenFile();
        ret = file.init();

        //
        YoseenData.TempFrameFile tff = new YoseenData.TempFrameFile();
        String fn = dddDebug + YoseenSDK.FileSeperator + "Data" + YoseenSDK.FileSeperator  + "test.jpg";
        ret = file.open(fn, YoseenUtil.xxxmediafile_jpgx, tff);

        //
        YoseenData.DataFrame dataFrame = new YoseenData.DataFrame();
        ret = file.read(0, dataFrame);

        //
        YoseenData.strech_control sc = new YoseenData.strech_control();
        sc.flags = YoseenData.strech_control.SCF_DDELevel;
        sc.dde_level = 1;
        ret = file.setImage(sc, YoseenUtil.xxxpalette_IronBow);
        ret = file.read(0, dataFrame);

        //single measure
        YoseenData.xxxmeasure mea = new YoseenData.xxxmeasure();
        YoseenData.xxxresult result = new YoseenData.xxxresult();
        mea.emmi = 97;
        mea.measuretype = YoseenUtil.xxxmeasuretype_rectangle;
        mea.xydata[0] = 100;
        mea.xydata[1] = 100;
        mea.xydata[2] = 200;
        mea.xydata[3] = 200;
        ret = YoseenSDK.YoseenMeasure.getResult(tff.dfh, tff.dfd, mea, result);
        System.out.printf("max %3.2f, avg %3.2f, min %3.2f\n", result.max, result.avg, result.min);

        //
        tff.coverImageSize = 0;
        String destPath = dddDebug + YoseenSDK.FileSeperator + "Data" + YoseenSDK.FileSeperator  + "test_save.jpg";
        ret = file.save(destPath, tff);

        //
        file.close();
        file.free();
        YoseenSDK.YoseenDevice.freeSDK();
    }
}
