Hi,
I had the same problem and it seems that you have to compress the
image before saving it t the disk.
And I think you also have to flush the OutputStream.
This is how I'm doing it. Hope it helps you:
public boolean storeImage(Bitmap bitmap, int picId) {
try {
File baseDir = Environment.getExternalStorageDirectory();
File tmpDir = new File(baseDir, APP_BASE_DIR + APP_CACHE_DIR);
if (!tmpDir.exists())
tmpDir.mkdirs();
File file = new File(tmpDir,String.valueOf(picId));
BufferedOutputStream out = new BufferedOutputStream(new
FileOutputStream(file));
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
//bitmap.recycle();
return true;
} catch (IOException e) {
e.printStackTrace(); // TODO: Customize this generated block
return false;
}
}
2011/5/20 kypriakos <[email protected]>
>
> HI all,
>
> I use the mCamera.takePicture(null, null, jpegCallback); to snap
> a picture through an activity. When the callback occurs I do see the
> data (approx 1.5 MB in length) and I use the following to write it to
> the
> sdcard - but the image length written is 0. Any ideas as to why this
> occurs?
>
> String path =
> Environment.getExternalStorageDirectory().toString();
> OutputStream out = null;
> File file = new File(path, "IMAGE.jpg");
> out = new FileOutputStream(file);
> System.out.println("Wrote image to =["+path+"]");
> out.close();
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en