4. Image Conversion

Convert ordinary PNG images (RGB, ARGB) into watch face background files

Sample Code

//1. Initialize image conversion object
BmpConvert bmpConvert = new BmpConvert();
String inPath = "Input file path"; //Image format, png, jpg
String outPath = "Output file path"; //Output file format. Binary file
//2. Start image conversion
//User needs to select algorithm based on device chip and performance
int flag = BmpConvert.TYPE_701N_RGB;         //701N image conversion algorithm - RGB
//flag = BmpConvert.TYPE_695N_RBG;           //695N image conversion algorithm - RGB
//V1.1.0+ supported
//flag = BmpConvert.TYPE_701N_ARGB;          //701N image conversion algorithm - ARGB
//V1.2.0+ supported
//flag = BmpConvert.TYPE_701N_RGB_NO_PACK;   //701N image conversion algorithm - RGB & No packaging
//flag = BmpConvert.TYPE_701N_ARGB_NO_PACK;  //701N image conversion algorithm - ARGB & No packaging
//V1.4.0+ supported
//flag = BmpConvert.TYPE_707N_RGB;           //707N image conversion algorithm - RGB
//flag = BmpConvert.TYPE_707N_ARGB;          //707N image conversion algorithm - ARGB
//flag = BmpConvert.TYPE_707N_RGB_NO_PACK;   //707N image conversion algorithm - RGB & No packaging
//flag = BmpConvert.TYPE_707N_ARGB_NO_PACK;  //707N image conversion algorithm - ARGB & No packaging
//V1.6.0+ supported
//flag = BmpConvert.TYPE_701N_JPEG;           //701N image conversion algorithm - JPEG
//V1.6.0+ supported
//Specify output encoding format, default value: ConvertParam.FORMAT_ARGB_8565
int format = ConvertParam.FORMAT_AUTO;  //Automatically select smallest compressed format, ARGB8565 or ARGB8888
//        format = ConvertParam.FORMAT_ARGB_8565; //Specify output ARGB8565 format. If algorithm is RGB algorithm, becomes specified output RGB565 format
//        format = ConvertParam.FORMAT_ARGB_8888; //Specify output ARGB8888 format. If algorithm is RGB algorithm, becomes specified output RGB888 format
//Construct conversion parameters
ConvertParam param = new ConvertParam().setFormat(format);
//Execute image transcoding function
bmpConvert.bitmapConvert(flag, inPath, outPath, param, new OnConvertListener() {

    //Callback conversion start
    //path: Input file path
    @Override
    public void onStart(String path) {

    }

    //Callback conversion end
    //result: Conversion result
    //output: Output file path
    @Deprecated
    @Override
    public void onStop(boolean result, String output) {
        //3. When no longer using image conversion function, need to release image conversion object
        //bmpConvert.release();
    }

    //Callback conversion end
    //result: Conversion result
    //output: Output file path
    @Override
    public void onStop(ConvertResult result, String outFilePath) {
        //result.isConvertSuccess(); //Transcoding success
        //result.getAlgorithm();     //Conversion algorithm
        //result.getBufSize();       //Conversion data size
        //result.getPixelFormat();   //Conversion image format
        //result.getCompressMode();  //Compression mode

        //3. When no longer using image conversion function, need to release image conversion object
        //bmpConvert.release();
    }
});

Important

  1. Image conversion function requires importing library: BmpConvert_Vxxx-release.aar

  2. Input image dimensions cannot exceed watch screen size, Get Watch Screen Size

  3. Input image size should be as small as possible

  4. Select appropriate algorithm based on firmware SDK

  5. Output RGB images are in RGB565 format, output ARGB images are in ARGB8565 format

  6. ConvertResult

  7. OnConvertListener

4.1. ConvertResult

Image conversion result

public class ConvertResult implements Parcelable {
    /**
     * Result code
     * <p>
     * Explanation:<br/>
     * 1. Less than or equal to 0, considered as transcoding failure, negative numbers are error codes<br/>
     * 2. Greater than 0, means transcoding success
     * </p>
     */
    private int result;
    /**
     * Algorithm type
     */
    private int algorithm;
    /**
     * Data size
     */
    private int bufSize;
    /**
     * Image format
     * <p>
     * Explanation: After 707N algorithm, this field was added for handling 【no packaging algorithm】
     * </p>
     */
    private int pixelFormat;
    /**
     * Compression mode
     * <p>
     * Explanation: After 707N algorithm, this field was added for handling 【no packaging algorithm】
     * </p>
     */
    private int compressMode;
}

4.2. OnConvertListener

Conversion listener

public interface OnConvertListener {

    /**
     * Callback for conversion start
     *
     * @param inFilePath String File path
     */
    void onStart(String inFilePath);

    /**
     * Callback for conversion end
     *
     * @param isOk        boolean Conversion result
     * @param outFilePath String Output path
     */
    @Deprecated
    void onStop(boolean isOk, String outFilePath);

    /**
     * Callback for conversion end
     *
     * @param result      ConvertResult Conversion result
     * @param outFilePath String Output file path
     */
    void onStop(ConvertResult result, String outFilePath);
}

4.3. Get Watch Screen Size

//WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
final WatchManager watchManager = WatchManager.getInstance();
//Get cached watch system information
ExternalFlashMsgResponse watchSysInfo = watchManager.getExternalFlashMsg(watchManager.getConnectedDevice());
if(null == watchSysInfo) return;
int screenWidth = watchSysInfo.getScreenWidth();    //Watch screen width
int screenHeight = watchSysInfo.getScreenHeight();  //Watch screen height

4.4. Algorithm Description

Chip Series

Old Algorithm Name

New Algorithm Name

Algorithm Description

AC695N

TYPE_BR_23

TYPE_695N_RBG

AC695N-WATCH-SDK Image conversion algorithm - RGB

JL701N

TYPE_BR_28

TYPE_701N_RGB

JL701N-WATCH-SDK Image conversion algorithm - RGB

TYPE_BR_28_ALPHA

TYPE_701N_ARGB

JL701N-WATCH-SDK Image conversion algorithm - ARGB

TYPE_BR_28_RAW

TYPE_701N_RGB_NO_PACK

JL701N-WATCH-SDK Image conversion algorithm - RGB & No packaging

TYPE_BR_28_ALPHA_RAW

TYPE_701N_ARGB_NO_PACK

JL701N-WATCH-SDK Image conversion algorithm - ARGB & No packaging

AC707N

TYPE_707N_RGB

AC707N-WATCH-SDK Image conversion algorithm - RGB

TYPE_707N_ARGB

AC707N-WATCH-SDK Image conversion algorithm - ARGB

TYPE_707N_RGB_NO_PACK

AC707N-WATCH-SDK Image conversion algorithm - RGB & No packaging

TYPE_707N_ARGB_NO_PACK

AC707N-WATCH-SDK Image conversion algorithm - ARGB & No packaging