ludo82 Posted March 12, 2012 Share Posted March 12, 2012 Bonsoir, Je vous expose mon probleme, Je voudrais fusionner une photo provenant de la caméra avec une image. Je parviens à faire la photo, je la stock sur ma carte sd, mais le problème est que je ne parviens pas à récupérer la photo depuis la carte sd et à faire ma fusion. Voici le code que j'utilise: private void SavePicture() { try { SimpleDateFormat timeStampFormat = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss"); /*String*/ fileName = "photo.jpg" /*+ timeStampFormat.format(new Date())+ ".jpg"*/; // Metadata pour la photo //ContentValues values = new ContentValues(); values.put(Media.TITLE, fileName); values.put(Media.DISPLAY_NAME, fileName); values.put(Media.DESCRIPTION, "Image prise par FormationCamera"); values.put(Media.DATE_TAKEN, new Date().getTime()); values.put(Media.MIME_TYPE, "image/jpeg"); // Support de stockage Uri taken = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI,values); // Ouverture du flux pour la sauvegarde stream = (FileOutputStream) getContentResolver().openOutputStream(taken); camera.takePicture(null, pictureCallback, pictureCallback); } catch (Exception e) { // TODO: handle exception } } private void fusionImage() { Bitmap mBackImage, mTopImage, mBackground; BitmapDrawable mBitmapDrawable; String mTempDir; String mCurrent = null; FileOutputStream mFileOutputStream; mTempDir = Environment.getExternalStorageDirectory() +"/DCIM/Camera"; mCurrent = "/Test.png"; //mBackground = Bitmap.createBitmap(2248, 3264, Bitmap.Config.ARGB_8888); //mBackImage = BitmapFactory.decodeFile(mTempDir+"/"+values); mTopImage = BitmapFactory.decodeResource(getResources(), R.drawable.tete); mBackground = Bitmap.createBitmap(mTopImage.getWidth(), mTopImage.getHeight(), mTopImage.getConfig()); Canvas mComboImage = new Canvas(mBackground); //mComboImage.drawBitmap(mBackImage, 0, 0, null); mComboImage.drawBitmap(mTopImage, 0, 0, null); mFileOutputStream = null; Log.v("TAG", "Save Tab Clicked"); try { mBitmapDrawable = new BitmapDrawable(mBackground); Bitmap mNewSaving = ((BitmapDrawable)mBitmapDrawable).getBitmap(); String FtoSave = mTempDir + mCurrent; File mFile = new File(FtoSave); mFileOutputStream = new FileOutputStream(mFile); mNewSaving.compress(CompressFormat.JPEG, 95, mFileOutputStream); mFileOutputStream.flush(); mFileOutputStream.close(); } catch (FileNotFoundException e) { Log.v("TAG", "FileNotFoundExceptionError " + e.toString()); } catch (IOException e) { Log.v("TAG", "IOExceptionError " + e.toString()); } } Merci pour votre aide. Link to comment Share on other sites More sharing options...
chpil Posted March 13, 2012 Share Posted March 13, 2012 Ton code seul ne va pas nous aider à t'aider si tu ne précises pas plus en détail ce qui se passe, si tu as une erreur, quand et comment elle se produit, ... Et puis évite les blocs catch() vide dans ton code (dans SavePicture), qui ne vont pas t'aider à savoir si une erreur se produit... Link to comment Share on other sites More sharing options...
ludo82 Posted March 13, 2012 Author Share Posted March 13, 2012 J'ai résolu mon problème merci. Mon problème était de récupérer le flux de l'appareil photo. Maintenant j'ai un autre problème, je voudrais savoir comment récupérer le nom de la photo prise par l'appareil. (ex: 1234658340.jpg) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.