Affichage d'une image Bitmap

hta9wa - 5 mars 2013 à 17:13
BunoCS Messages postés 15475 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 23 avril 2024 - 5 mars 2013 à 20:54
bonjour,
je veux afficher un bitmap sur android
mais j'ai pas réussir. voilà mon code
veuillez m'aide SVP


package com.example.filtre;

import java.io.File;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Menu;
import android.widget.ImageView;

public class FiltreActivity extends Activity {

ImageView img ;
Bitmap bit;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.filtre_main);
File imageFile = new File("C:/Users/DELL/Desktop/image.jpg");
if (imageFile.exists())
{
// Load the image from file
bit = BitmapFactory.decodeFile("C:/Users/DELL/Desktop/image.jpg");

// Display the image in the image viewer
img = (ImageView)findViewById(R.id.img);
if (img != null)
{
img.setImageBitmap(bit);
}
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.filtre, menu);
return true;
}
}

1 réponse

BunoCS Messages postés 15475 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 23 avril 2024 103
5 mars 2013 à 20:54
Hello,
new File("C:/Users/DELL/Desktop/image.jpg"); 

Euh...tu crois vraiment qu'il va trouver ton image?

@+
Buno, Admin CS
L'urgent est fait, l'impossible est en cours. Pour les miracles, prévoir un délai...
0
Rejoignez-nous