5
我需要用相機拍照並同時在相機視圖頂部顯示疊加圖像。拍完照片後,我需要保存用戶在拍照時看到的內容。任何人都可以建議我嗎請。用相機拍攝的圖像疊加在android中拍攝的圖像
我需要用相機拍照並同時在相機視圖頂部顯示疊加圖像。拍完照片後,我需要保存用戶在拍照時看到的內容。任何人都可以建議我嗎請。用相機拍攝的圖像疊加在android中拍攝的圖像
public void onPictureTaken(byte[] data, Camera camera){
Bitmap cameraBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
wid = cameraBitmap.getWidth();
hgt = cameraBitmap.getHeight();
Bitmap newImage = Bitmap.createBitmap(wid , hgt , Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(newImage);
canvas.drawBitmap(cameraBitmap, 0f, 0f, null);
Drawable drawable = getResources().getDrawable(R.drawable.d);
drawable.setBounds(20 ,20, 260, 160);
drawable.draw(canvas);
File storagePath = new File(Environment.getExternalStorageDirectory() + "/Vampire Photos/");
storagePath.mkdirs();
File myImage = new File(storagePath,Long.toString(System.currentTimeMillis()) + ".jpg");
try
{
FileOutputStream out = new FileOutputStream(myImage);
newImage.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
}
catch(FileNotFoundException e)
{
Log.d("In Saving File", e + "");
}
catch(IOException e)
{
Log.d("In Saving File", e + "");
}
camera.startPreview();
drawable = null;
newImage.recycle();
newImage = null;
cameraBitmap.recycle();
cameraBitmap = null;
} };
你有沒有想過這個?我需要這樣做。已經讓相機與覆蓋層一起工作,但我無法將兩者保存爲一個圖像。 –
可能重複[在我們保存之前從攝像頭捕獲圖像並覆蓋另一個位圖](https://stackoverflow.com/questions/9938801/capturing-image-from-camera-and-overlaying-another-bitmap-before-we -保存) –