1
我想從我的相機捕捉圖像並在指定的座標下裁剪捕捉的圖像然後在另一幅圖像的中間繪製它。以下代碼不會崩潰,但由於圖像拉伸錯誤,所捕獲的圖像被擰緊,。拍攝的圖像在Android中裁剪後延伸錯誤
我哪裏錯了?
Merry X'mas!
//Get the bottom image Bitmap
Bitmap bottomImage = BitmapFactory.decodeResource(getResources(), SelectDollarActivity.selectedImageId);
//Get the captured image Bitmap
Bitmap capturedImage = BitmapFactory.decodeFile(CaptureImage.cImagePath) ;
//************ CROP THE CAPTURED IMAGE *******************
int targetBitmapWidth = bottomImage.getWidth();
int targetBitmapHeight = bottomImage.getHeight() ;
//create a Bitmap with specified width & height
Bitmap clippedBitmap = Bitmap.createBitmap(targetBitmapWidth, targetBitmapHeight, Bitmap.Config.ARGB_8888);
//Construct a canvas with the specified bitmap to draw into.
Canvas canvas = new Canvas(clippedBitmap);
//************** cropping process goes HERE.........
//Create a new rectangle with the specified coordinates
RectF rectf = new RectF(left, top, right, bottom);
//Create an empty path
Path path = new Path();
//Add a closed oval contour to the path
path.addOval(rectf, Path.Direction.CW);
//Intersect the current clip with the specified path : CROPPING
canvas.clipPath(path);
canvas.drawBitmap(capturedImage, null, new Rect(0, 0, targetBitmapWidth, targetBitmapHeight), null);
//******** MERGING PROCESS *******************
//Construct a canvas with the specified bitmap to draw into.
Canvas combo = new Canvas(bottomImage);
// Then draw the second on top of that
combo.drawBitmap(clippedBitmap, 0f, 0f, null);
// bottomImage is now a composite of the two. so, display the bottom image
//************** DISPLAY THE MERGED IMAGE ****************
((ImageView)findViewById(R.id.billImage)).setImageBitmap(bottomImage);
圖像正在伸展。那是我的問題。 – Santhosh 2011-12-23 12:50:19
我以橢圓形方式裁剪捕捉的圖像並放置在另一個/底部圖像的中間。我可以將裁剪後的圖像放在底部圖像上的適當位置。但是我得到延伸的橢圓形圖像。哪裏錯了? – Santhosh 2011-12-23 12:57:33
你有沒有得到任何解決方案兄弟?即時通訊也面臨着同樣的問題.pls回覆我 – 2014-02-14 04:31:20