【发布时间】:2013-12-04 09:41:10
【问题描述】:
testButton.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v)
{
imageView.setImageBitmap(Bitmap);
imageView.buildDrawingCache();
Bitmap bm =imageView.getDrawingCache();
Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "Punch");
imagesFolder.mkdirs();
String fileName = "image" + ".jpg";
File output = new File(imagesFolder, fileName);
Uri uriSavedImage = Uri.fromFile(output);
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
OutputStream fos = null;
try {
fos = getContentResolver().openOutputStream(uriSavedImage);
bm.compress(CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{}
}
});
首先,我从 sd 卡检索图像到分辨率 (640 x 480) 的图像视图。然后我再次将图像从图像视图保存到 SD 卡。但是保存的图像的分辨率是(188x113)。谁能建议我如何以相同的分辨率保存。任何建议都会很重要。
【问题讨论】:
-
您正在将 imageview 保存为图像。不是原图。您是否对要保存的图像视图进行了一些更改?
-
是的,我正在通过删除其蓝色和绿色内容来处理检索到的图像。并将图像制作成红色图像。然后我将此红色图像保存回SD卡。
-
如果Bitmap的宽度和高度大于ImageView的宽度和高度,那么ImageView会调整Bitmap(实际上不是Bitmap,它会将Bitmap转换为BitmapDrawable)的尺寸以适应它的实际大小。所以你会得到小尺寸的图片
-
我以另一种方式做到了......我在图像视图中检索到图像后立即保存了图像,即没有任何处理。我仍然发现保存的图像分辨率较低..请提供任何建议
-
@Gopal 我无法更改图像视图的高度和宽度,因为它周围有很多东西。有没有什么办法可以在保存时以与原始分辨率相同的分辨率保存回sd卡
标签: android