Bonjour,
Je souhaite faire une capture d'écran d'un graphique pour ensuite l'imprimer.
voici ma méthode de capture :
Bon voila le problème, c'est que premièrement je ne sais pas si la fonction "toBimap()" fonctionne, c'est une fonction de la librairie "achartengine" qui permet de retourner un Bitmap de la vue en cours.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 public static Boolean BitmapExport() { Boolean verif = false; try { Bitmap screenshot; mainView.setDrawingCacheEnabled(true); mainView.layout(0, 0, 1280, 600); screenshot = mainView.toBitmap(); mainView.setDrawingCacheEnabled(false); int width = screenshot.getWidth(); int height = screenshot.getHeight(); Toast.makeText(getContexteApplication(),"width = " + width + " height = " + height ,Toast.LENGTH_SHORT).show(); String filename = "/mtn/sdcard/test.png"; FileOutputStream out = new FileOutputStream(filename); verif = screenshot.compress(Bitmap.CompressFormat.PNG,80,out); } catch(FileNotFoundException fnfe) { System.out.println(fnfe.getMessage()); } return verif; }
remarque : je suppose que cette fonction est ok car les valeur "width" et "height" corresponde a mon layout prédéfini (1280 , 600).
Ensuite la fonction screenshot.compress (...) me retourne faux à chaque fois.
Je n’ai pas d'autres idées sur le problème, merci de votre aide !
NahMean
Partager