私のプロジェクトでは、プログラムを通して、ピクセルを抽出し、それらのピクセルを操作して、それをパッケージに保存しました。私はそれを保存する方法、である:今Android:ビットマップイメージをデコードする際の問題
private void createPicture()
{
System.out.println("Inside createPicture");
System.out.println(contextPath);
try{
FileOutputStream fos = new FileOutputStream(contextPath + "/" + picName);
DataOutputStream dos = new DataOutputStream(fos);
for(int i=0; i<splitedPixel.length; i++)
dos.writeByte(splitedPixel[i]);
dos.flush();
dos.close();
}
catch(IOException e){
System.out.println("IOException : " + e);
}
System.out.println("Picture Created.");
}
ので、それはこのディレクトリに私の写真が保存されます
/data/data/my_package_name/files/myPic.bmp
、私はこの新しい画像を読んで、この画像のピクセルを抽出したい。私はこの方法を使用しました:
public Stego(Context context)
{
//Instantiate an ImageView and define its properties
contextPath = context.getFilesDir().getAbsolutePath();
image = BitmapFactory.decodeFile(contextPath + "/" + picName);
System.out.println("Image= " + image);
imWidth = image.getWidth();
imHeight = image.getHeight();
getMaxMessageChars();
System.out.println("Width: " + imWidth);
}
ここでプログラムがクラッシュします。 logcatは、イメージの結果がnullであり、プログラムがgetWidthに達するとクラッシュすることを示します。
これらの方法で正しい書き込みと読み込みができますか? エミュレータでディレクトリに移動して、この画像が作成されているかどうかを確認できますか?
おかげ