在我的项目中,我有一个图片,通过程序,我提取像素,操纵这些像素,然后将其保存在我的包中。是我救了它的方式是: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指示图像的结果为空,并且程序达到getWidth崩溃时。
这些书写和阅读方式是否正确? 我可以通过模拟器转到目录来检查是否创建了这张图片吗?
感谢