Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Fusion d'un photo et d'une image png

Featured Replies

Posté(e)

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.

Posté(e)

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...

Posté(e)
  • Auteur

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)

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.