graphics/drawable/animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java
public static void saveVectorDrawableIntoPNG(Resources resource, Bitmap bitmap, int resId,
            String filename) throws IOException {
        // Save the image to the disk.
        FileOutputStream out = null;
        try {
            String outputFolder = "/sdcard/temp/";
            File folder = new File(outputFolder);
            if (!folder.exists()) {
                folder.mkdir();
            }
            String fileTitle = "unname";
            if (resId >= 0) {
                String originalFilePath = resource.getString(resId);
                File originalFile = new File(originalFilePath);
                String fileFullName = originalFile.getName();
                fileTitle = fileFullName.substring(0, fileFullName.lastIndexOf("."));
                if (filename != null) {
                    fileTitle += "_" + filename;
                }
            } else if (filename != null) {
                fileTitle = filename;
            }
            String outputFilename = outputFolder + fileTitle + "_golden.png";
            File outputFile = new File(outputFilename);
            if (!outputFile.exists()) {
                outputFile.createNewFile();
            }

            out = new FileOutputStream(outputFile, false);
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
            Log.v(LOGTAG, "Write test No." + outputFilename + " to file successfully.");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                out.close();
            }
        }
    }
// This is only for debugging or golden image (re)generation purpose.
This is only for debugging or golden image (re)generation purpose.
This is only for debugging or golden image ( re ) generation purpose .
public static void saveVectorDrawableIntoPNG(Resources resource, Bitmap bitmap, int resId,
            String filename) throws IOException {
        FileOutputStream out = null;
        try {
            String outputFolder = "/sdcard/temp/";
            File folder = new File(outputFolder);
            if (!folder.exists()) {
                folder.mkdir();
            }
            String fileTitle = "unname";
            if (resId >= 0) {
                String originalFilePath = resource.getString(resId);
                File originalFile = new File(originalFilePath);
                String fileFullName = originalFile.getName();
                fileTitle = fileFullName.substring(0, fileFullName.lastIndexOf("."));
                if (filename != null) {
                    fileTitle += "_" + filename;
                }
            } else if (filename != null) {
                fileTitle = filename;
            }
            String outputFilename = outputFolder + fileTitle + "_golden.png";
            File outputFile = new File(outputFilename);
            if (!outputFile.exists()) {
                outputFile.createNewFile();
            }
            out = new FileOutputStream(outputFile, false);
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
            Log.v(LOGTAG, "Write test No." + outputFilename + " to file successfully.");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                out.close();
            }
        }
    }
public static void saveVectorDrawableIntoPNG ( Resources resource , Bitmap bitmap , int resId , String filename ) throws IOException { FileOutputStream out = null ; try { String outputFolder = "/sdcard/temp/" ; File folder = new File ( outputFolder ) ; if ( ! folder . exists ( ) ) { folder . mkdir ( ) ; } String fileTitle = "unname" ; if ( resId >= 0 ) { String originalFilePath = resource . getString ( resId ) ; File originalFile = new File ( originalFilePath ) ; String fileFullName = originalFile . getName ( ) ; fileTitle = fileFullName . substring ( 0 , fileFullName . lastIndexOf ( "." ) ) ; if ( filename != null ) { fileTitle += "_" + filename ; } } else if ( filename != null ) { fileTitle = filename ; } String outputFilename = outputFolder + fileTitle + "_golden.png" ; File outputFile = new File ( outputFilename ) ; if ( ! outputFile . exists ( ) ) { outputFile . createNewFile ( ) ; } out = new FileOutputStream ( outputFile , false ) ; bitmap . compress ( Bitmap . CompressFormat . PNG , 100 , out ) ; Log . v ( LOGTAG , "Write test No." + outputFilename + " to file successfully." ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { if ( out != null ) { out . close ( ) ; } } }
This is only for debugging or golden image (re)generation purpose.
This is only for debugging or golden image ( re ) generation purpose .
// Save the image to the disk.