我了點擊的圖像上的代碼是:當我從相機捕捉圖像時,它失去了圖像的質量?該怎麼辦?
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 300);
活動結果的代碼:攝像頭採集的演示
if (requestCode == 300) {
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File destination = new File(Environment.getExternalStorageDirectory(),
System.currentTimeMillis() + ".jpg");
FileOutputStream fo;
try {
destination.createNewFile();
fo = new FileOutputStream(destination);
fo.write(bytes.toByteArray());
fo.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(number.equalsIgnoreCase("1"))
{
imageViewOneNumber.setImageBitmap(thumbnail);
image1="";
image1= getEncoded64ImageStringFromBitmap(thumbnail);
}
else
{
RelativeLayoutImage2.setVisibility(View.GONE);
FrameImage2.setVisibility(View.VISIBLE);
imageViewTwoNumber.setImageBitmap(thumbnail);
image2="";
image2= getEncoded64ImageStringFromBitmap(thumbnail);
}
}
請幫我解決這個問題。當我點擊相機的照片時,它會減小圖像的大小。
您需要爲啓動意圖時保存的圖像設置路徑。如果你不設置路徑,API只返回縮略圖版本,因此模糊 – Shubhank
我如何設置路徑? @Shubhank – Krupa