Bonjour et bonne année,
Je suis dans une petite impasse, je voudrais convertir un byte Array contenant les informations d'une image prise depuis la camera en string.

J'arrive a voir l'image si je l'enregistre en image (dans un FileOutputStream) mais si je passe par une ByteArrayOutputStream, non seulement, la string reçu ne correspond pas à ce qui est contenu dans le fichier image mais même la taille mémoire est 2 fois plus grande. Voici le PictureCallback que j'utilise.

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
33
34
35
 
 Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
        public void onPictureTaken(byte[] data, Camera c) {
            Log.e(TAG, "PICTURE CALLBACK: data.length = " + data.length);
           String imageString = null;
 
            FileOutputStream fOut = null; 
            OutputStreamWriter osw = null;
            ByteArrayOutputStream bos = null;
            try{ 
            	bos = new ByteArrayOutputStream() ;
 
            	Bitmap myPic = BitmapFactory.decodeByteArray( data, 0, data.length );
            	myPic.compress( Bitmap.CompressFormat.JPEG, 100, bos );
 
 
            	myPic = BitmapFactory.decodeByteArray( data, 0, data.length );
            	FileOutputStream stream = openFileOutput( "bobblePic3.jpg", MODE_PRIVATE );
            	myPic.compress( Bitmap.CompressFormat.JPEG, 100,stream );
 
                imageString = new String(bos.toString()); //
                fOut = openFileOutput("bob.jpg",MODE_PRIVATE);  
                osw = new OutputStreamWriter(fOut); 
                osw.write(imageString); 
                osw.flush();
                fOut.close();
                osw.close();
                bos.close();
 
            } 
            catch (Exception e) {       
            	Log.e("error", e.toString());
            } 
        }
    };
Je vous remercie par avance pour toutes indications.