Je souhaite afficher un bitmap et enregistrer le bitmap. Mais j'ai besoin de faire tout cela hors écran.Rendu Afficher en mode Bitmap hors écran dans Android
J'ai essayé ceci:
LayoutInflater inflater = getLayoutInflater();
View linearview = (View) findViewById(R.id.linearview);
linearview = inflater.inflate(R.layout.intro, null);
Bitmap bm = Bitmap.createBitmap(linearview.getMeasuredWidth(), linearview.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bm);
linearview.layout(0, 0, linearview.getLayoutParams().width, linearview.getLayoutParams().height);
linearview.draw(c);
String extStorageDirectory = Environment.getExternalStorageState().toString();
extStorageDirectory = Environment.getExternalStorageDirectory().toString();
OutputStream outStream = null;
File file = new File(extStorageDirectory, "screen1.PNG");
try {
outStream = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
EDIT: Mon accident d'application, car la doesnt vue ont une largeur ou la hauteur. (la mesure est une tentative pour résoudre ce problème)
Et srry pour le mauvais anglais.
en demandant au sujet d'un accident, vous devriez toujours poster votre trace – jqpubliq
Est-ce que dans un service –
comment puis-je définir une mise en page à un service? –