SurfaceView 上的 Android 相机肖像并保存快照
我的api是2.2,所以我使用camera.setDisplayOrientation(90)来使预览为纵向,这个效果很好,但是当我将图片保存到sd时,图片是水平的而不是纵向。当我使用时:
@Override
protected Bitmap doInBackground(String... params) {
int w = bmp.getWidth();
int h = bmp.getHeight();
// Setting post rotate to 90
Matrix mtx = new Matrix();
mtx.postRotate(90);
// Rotating Bitmap
Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
bmp.recycle();
return rotatedBMP;
}
@Override
protected void onPostExecute(Bitmap result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
dialog.dismiss();
ivNewPhoto.setImageBitmap(result);
resultPath = ConstValue.MY_ALBUM_DIR + "/" + System.currentTimeMillis() + ".jpg";
ImageFile.writePhotoJpg(result), resultPath);
previewView.setVisibility(View.VISIBLE);
}
bmp是快照图片但我有错误:
Activity com.android.SuperPictureSearch.photo.PhotoActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43abb200 that was originally added here
你能告诉我如何保存图片为肖像,谢谢
my api is 2.2,so i used camera.setDisplayOrientation(90) to make the preview is Portrait,this work very well,but when i save the pic to sd,the pic is horizontal not Portrait.when i used :
@Override
protected Bitmap doInBackground(String... params) {
int w = bmp.getWidth();
int h = bmp.getHeight();
// Setting post rotate to 90
Matrix mtx = new Matrix();
mtx.postRotate(90);
// Rotating Bitmap
Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
bmp.recycle();
return rotatedBMP;
}
@Override
protected void onPostExecute(Bitmap result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
dialog.dismiss();
ivNewPhoto.setImageBitmap(result);
resultPath = ConstValue.MY_ALBUM_DIR + "/" + System.currentTimeMillis() + ".jpg";
ImageFile.writePhotoJpg(result), resultPath);
previewView.setVisibility(View.VISIBLE);
}
bmp is the Snapshot pic but i have mistakes:
Activity com.android.SuperPictureSearch.photo.PhotoActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43abb200 that was originally added here
can you tell me how to save the pic is Portrait,thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为照片对于相机来说太大了,所以我调整了尺寸
because the pic is too big form camera,so i size it