graphics/drawable/static/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/VectorDrawableTest.java
private void saveVectorDrawableIntoPNG(Bitmap bitmap, int[] resIds, int index, int[] stateSet)
            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 originalFilePath = mResources.getString(resIds[index]);
            File originalFile = new File(originalFilePath);
            String fileFullName = originalFile.getName();
            String fileTitle = fileFullName.substring(0, fileFullName.lastIndexOf("."));
            String stateSetTitle = getTitleForStateSet(stateSet);
            String outputFilename = outputFolder + fileTitle + "_golden" + stateSetTitle + ".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." + index + " 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 .
private void saveVectorDrawableIntoPNG(Bitmap bitmap, int[] resIds, int index, int[] stateSet)
            throws IOException {
        FileOutputStream out = null;
        try {
            String outputFolder = "/sdcard/temp/";
            File folder = new File(outputFolder);
            if (!folder.exists()) {
                folder.mkdir();
            }
            String originalFilePath = mResources.getString(resIds[index]);
            File originalFile = new File(originalFilePath);
            String fileFullName = originalFile.getName();
            String fileTitle = fileFullName.substring(0, fileFullName.lastIndexOf("."));
            String stateSetTitle = getTitleForStateSet(stateSet);
            String outputFilename = outputFolder + fileTitle + "_golden" + stateSetTitle + ".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." + index + " to file successfully.");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                out.close();
            }
        }
    }
private void saveVectorDrawableIntoPNG ( Bitmap bitmap , int [ ] resIds , int index , int [ ] stateSet ) throws IOException { FileOutputStream out = null ; try { String outputFolder = "/sdcard/temp/" ; File folder = new File ( outputFolder ) ; if ( ! folder . exists ( ) ) { folder . mkdir ( ) ; } String originalFilePath = mResources . getString ( resIds [ index ] ) ; File originalFile = new File ( originalFilePath ) ; String fileFullName = originalFile . getName ( ) ; String fileTitle = fileFullName . substring ( 0 , fileFullName . lastIndexOf ( "." ) ) ; String stateSetTitle = getTitleForStateSet ( stateSet ) ; String outputFilename = outputFolder + fileTitle + "_golden" + stateSetTitle + ".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." + index + " 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.