Gaëtan Renaudeau 8 лет назад
Родитель
Сommit
6089cb703d
1 измененных файлов: 0 добавлений и 17 удалений
  1. 0
    17
      android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java

+ 0
- 17
android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java Просмотреть файл

104
         }
104
         }
105
     }
105
     }
106
 
106
 
107
-    public static Bitmap loadBitmapFromView(View v)
108
-    {
109
-        Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
110
-
111
-        Canvas c = new Canvas(b);
112
-        v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
113
-        v.draw(c);
114
-        return b;
115
-    }
116
-
117
     /**
107
     /**
118
      * Screenshot a view and return the captured bitmap.
108
      * Screenshot a view and return the captured bitmap.
119
      * @param view the view to capture
109
      * @param view the view to capture
125
         if (w <= 0 || h <= 0) {
115
         if (w <= 0 || h <= 0) {
126
             throw new RuntimeException("Impossible to snapshot the view: view is invalid");
116
             throw new RuntimeException("Impossible to snapshot the view: view is invalid");
127
         }
117
         }
128
-        /*
129
-        if (!view.isDrawingCacheEnabled())
130
-          view.setDrawingCacheEnabled(true);
131
-
132
-        Bitmap bitmap = view.getDrawingCache();
133
-        */
134
         Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
118
         Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
135
         Canvas c = new Canvas(bitmap);
119
         Canvas c = new Canvas(bitmap);
136
         view.layout(0, 0, view.getLayoutParams().width, view.getLayoutParams().height);
120
         view.layout(0, 0, view.getLayoutParams().width, view.getLayoutParams().height);
143
             throw new RuntimeException("Impossible to snapshot the view");
127
             throw new RuntimeException("Impossible to snapshot the view");
144
         }
128
         }
145
         bitmap.compress(format, (int)(100.0 * quality), os);
129
         bitmap.compress(format, (int)(100.0 * quality), os);
146
-        //view.setDrawingCacheEnabled(false);
147
     }
130
     }
148
 }
131
 }