私のプロジェクトでは、プログラムを使用してピクセルを抽出し、それらのピクセルを操作して、パッケージに保存した画像があります。私が保存した方法は次のとおりです。
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 に達するとクラッシュすることを示します。
これらの書き方と読み方は正しいですか?この画像が作成されているかどうかを確認するために、エミュレータを介してディレクトリに移動できますか?
ありがとう