File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
android/src/main/java/fr/greweb/reactnativeviewshot Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -94,16 +94,18 @@ private void captureView (View view, OutputStream os) {
94
94
if (w <= 0 || h <= 0 ) {
95
95
throw new RuntimeException ("Impossible to snapshot the view: view is invalid" );
96
96
}
97
+ if (!view .isDrawingCacheEnabled ())
98
+ view .setDrawingCacheEnabled (true );
99
+
97
100
Bitmap bitmap = view .getDrawingCache ();
98
- if (bitmap == null )
99
- view .setDrawingCacheEnabled (true );
100
- bitmap = view .getDrawingCache ();
101
+
101
102
if (width != null && height != null && (width != w || height != h )) {
102
103
bitmap = Bitmap .createScaledBitmap (bitmap , width , height , true );
103
104
}
104
105
if (bitmap == null ) {
105
106
throw new RuntimeException ("Impossible to snapshot the view" );
106
107
}
107
108
bitmap .compress (format , (int )(100.0 * quality ), os );
109
+ view .setDrawingCacheEnabled (false );
108
110
}
109
111
}
You can’t perform that action at this time.
0 commit comments